Add objectClear & objectSpread (#1157)

* Add objectClear & objectSpread

* Allow null/undefined as a source
This commit is contained in:
Jaco
2021-11-04 08:16:55 +02:00
committed by GitHub
parent 08ac55d7cd
commit 733d7c1948
13 changed files with 105 additions and 35 deletions
+7 -10
View File
@@ -5,6 +5,7 @@ import type { ToBnOptions } from '../types';
import { BN } from '../bn/bn';
import { isBoolean } from '../is/boolean';
import { objectSpread } from '../object/spread';
import { hexStripPrefix } from './stripPrefix';
function reverse (value: string): string {
@@ -36,16 +37,12 @@ export function hexToBn (value?: string | null, options: ToBnOptions | boolean =
return new BN(0);
}
const _options: ToBnOptions = {
isLe: false,
isNegative: false,
// Backwards-compatibility
...(
isBoolean(options)
? { isLe: options }
: options
)
};
const _options: ToBnOptions = objectSpread(
{ isLe: false, isNegative: false },
isBoolean(options)
? { isLe: options }
: options
);
const _value = hexStripPrefix(value);
// FIXME: Use BN's 3rd argument `isLe` once this issue is fixed