本文整理汇总了TypeScript中bignumber.js.default.isBigNumber方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default.isBigNumber方法的具体用法?TypeScript js.default.isBigNumber怎么用?TypeScript js.default.isBigNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bignumber.js.default
的用法示例。
在下文中一共展示了js.default.isBigNumber方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: writeVarUInt
/**
* Calculate the size of a variable-length unsigned integer.
*/
writeVarUInt (_value: BigNumber.Value) {
if (!isInteger(_value)) {
throw new Error('UInt must be an integer')
}
let lengthOfValue
if (typeof _value === 'number') {
if (_value < 0) {
throw new Error('UInt must be positive')
}
// Fast path for numbers.
lengthOfValue = getUIntBufferSize(_value)
} else {
// Don't clone an existing BigNumber, since it will not be modified.
const value = BigNumber.isBigNumber(_value) ? _value as BigNumber : new BigNumber(_value)
if (value.isNegative()) {
throw new Error('UInt must be positive')
}
lengthOfValue = getBigUIntBufferSize(value)
}
this.skipVarOctetString(lengthOfValue)
}
示例2: if
const mapped = _.map(row, (value: BigNumber | number | null, key: string): Array<any> => {
const previousValue = result[key];
if (sumFields.indexOf(key) === -1 || typeof previousValue === "undefined" || value === null || typeof value === "undefined") {
return [key, value];
} else if (BigNumber.isBigNumber(value)) {
return [key, (value as BigNumber).plus(result[key] as BigNumber)];
} else {
return [key, value + previousValue];
}
}) as Array<any>;
示例3: isInteger
export function isInteger (value: any) {
if (BigNumber.isBigNumber(value)) {
return value.isFinite()
&& value.isInteger()
} else if (typeof value === 'number') {
return isFinite(value) && Math.floor(value) === value
} else if (typeof value === 'string') {
return !!INTEGER_REGEX.exec(value)
} else {
return false
}
}
示例4: writeVarInt
/**
* Calculate the size of a variable-length integer.
*/
writeVarInt (_value: BigNumber.Value) {
if (!isInteger(_value)) {
throw new Error('UInt must be an integer')
}
let lengthOfValue
if (typeof _value === 'number') {
lengthOfValue = getIntBufferSize(_value)
} else {
const value = BigNumber.isBigNumber(_value) ? _value as BigNumber : new BigNumber(_value)
lengthOfValue = getBigIntBufferSize(value)
}
this.skipVarOctetString(lengthOfValue)
}