New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@polkadot/types-codec

Package Overview
Dependencies
Maintainers
2
Versions
511
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polkadot/types-codec - npm Package Compare versions

Comparing version

to
9.4.1

19

abstract/Int.js
// Copyright 2017-2022 @polkadot/types-codec authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isBn, isHex, isNumber, isString, isU8a, u8aToBn, u8aToNumber } from '@polkadot/util';
import { BN, BN_BILLION, BN_HUNDRED, BN_MILLION, BN_QUINTILL, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isBn, isFunction, isHex, isNumber, isObject, isString, isU8a, u8aToBn, u8aToNumber } from '@polkadot/util';
export const DEFAULT_UINT_BITS = 64; // Maximum allowed integer for JS is 2^53 - 1, set limit at 52

@@ -39,2 +39,19 @@ // In this case however, we always print any >32 as hex

return value.toString();
} else if (isObject(value) && !isFunction(value.toBn)) {
// Allow the construction from an object with a single top-level key. This means that
// single key objects can be treated equivalently to numbers, assuming they meet the
// specific requirements. (This is useful in Weights 1.5 where Objects are compact)
const keys = Object.keys(value);
if (keys.length !== 1) {
throw new Error('Unable to construct number from multi-key object');
}
const inner = value[keys[0]];
if (!isString(inner) && !isNumber(inner)) {
throw new Error('Unable to construct from object with non-string/non-number value');
}
return decodeAbstractInt(inner, isNegative);
}

@@ -41,0 +58,0 @@

@@ -48,2 +48,19 @@ "use strict";

return value.toString();
} else if ((0, _util.isObject)(value) && !(0, _util.isFunction)(value.toBn)) {
// Allow the construction from an object with a single top-level key. This means that
// single key objects can be treated equivalently to numbers, assuming they meet the
// specific requirements. (This is useful in Weights 1.5 where Objects are compact)
const keys = Object.keys(value);
if (keys.length !== 1) {
throw new Error('Unable to construct number from multi-key object');
}
const inner = value[keys[0]];
if (!(0, _util.isString)(inner) && !(0, _util.isNumber)(inner)) {
throw new Error('Unable to construct from object with non-string/non-number value');
}
return decodeAbstractInt(inner, isNegative);
}

@@ -50,0 +67,0 @@

2

cjs/packageInfo.js

@@ -14,4 +14,4 @@ "use strict";

type: 'cjs',
version: '9.3.3'
version: '9.4.1'
};
exports.packageInfo = packageInfo;

@@ -23,3 +23,3 @@ {

"type": "module",
"version": "9.3.3",
"version": "9.4.1",
"main": "./cjs/index.js",

@@ -438,6 +438,6 @@ "module": "./index.js",

"dependencies": {
"@babel/runtime": "^7.18.9",
"@polkadot/util": "^10.1.7",
"@polkadot/x-bigint": "^10.1.7"
"@babel/runtime": "^7.19.0",
"@polkadot/util": "^10.1.8",
"@polkadot/x-bigint": "^10.1.8"
}
}

@@ -8,3 +8,3 @@ // Copyright 2017-2022 @polkadot/types-codec authors & contributors

type: 'esm',
version: '9.3.3'
version: '9.4.1'
};