Socket
Socket
Sign inDemoInstall

@glif/filecoin-number

Package Overview
Dependencies
Maintainers
3
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glif/filecoin-number - npm Package Compare versions

Comparing version 2.0.54 to 2.0.56

7

dist/FilecoinNumber.d.ts

@@ -16,6 +16,5 @@ /// <reference types="node" />

export declare class FilecoinNumber extends BigNumber {
private static zeroCtMap;
private static zeroCtUnitMap;
private readonly _ct?;
private readonly _unit?;
private static zeroMap;
private readonly _coinType;
private readonly _unit;
constructor(value: BigNumber.Value, denom: FilecoinDenomination, coinType?: CoinType, unit?: string);

@@ -22,0 +21,0 @@ /**

@@ -24,3 +24,3 @@ "use strict";

var _defineProperty4 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -31,7 +31,7 @@ var _bignumber = require("bignumber.js");

var _defineProperty2, _defineProperty3;
var _defineProperty2;
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty4["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty3["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

@@ -88,13 +88,14 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }

// Stores static FilecoinNumber(0, 'fil') instances per CoinType
// Stores static FilecoinNumber(0, 'fil') instances per CoinType and unit
// Static FilecoinNumber(0, 'fil') instances for each CoinType and unit
// Constructor params
function FilecoinNumber(value, denom, coinType, unit) {
function FilecoinNumber(value, denom) {
var _this;
var coinType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : CoinType.MAIN;
var unit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'FIL';
(0, _classCallCheck2["default"])(this, FilecoinNumber);
_this = _super.call(this, toBigNumberValue(value, denom));
(0, _defineProperty4["default"])((0, _assertThisInitialized2["default"])(_this), "_ct", void 0);
(0, _defineProperty4["default"])((0, _assertThisInitialized2["default"])(_this), "_unit", void 0);
_this._ct = coinType;
(0, _defineProperty3["default"])((0, _assertThisInitialized2["default"])(_this), "_coinType", void 0);
(0, _defineProperty3["default"])((0, _assertThisInitialized2["default"])(_this), "_unit", void 0);
_this._coinType = coinType;
_this._unit = unit;

@@ -116,6 +117,4 @@ return _this;

value: function getDenomUnit(denom) {
var _this$_unit;
var unitDenom = denom.replace(/fil$/, '');
return unitDenom ? "".concat(unitDenom).concat((_this$_unit = this._unit) !== null && _this$_unit !== void 0 ? _this$_unit : 'FIL') : this.unit;
return unitDenom ? "".concat(unitDenom).concat(this._unit) : this.unit;
}

@@ -220,3 +219,3 @@ /**

value: function clone() {
return new FilecoinNumber(this, 'fil', this._ct, this._unit);
return new FilecoinNumber(this, 'fil', this._coinType, this._unit);
}

@@ -230,3 +229,3 @@ /**

value: function abs() {
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "abs", this).call(this), 'fil', this._ct, this._unit);
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "abs", this).call(this), 'fil', this._coinType, this._unit);
}

@@ -249,3 +248,3 @@ /**

value: function negated() {
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "negated", this).call(this), 'fil', this._ct, this._unit);
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "negated", this).call(this), 'fil', this._coinType, this._unit);
}

@@ -259,3 +258,3 @@ /**

value: function div(n) {
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "div", this).call(this, n), 'fil', this._ct, this._unit);
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "div", this).call(this, n), 'fil', this._coinType, this._unit);
}

@@ -278,3 +277,3 @@ /**

value: function times(n) {
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "times", this).call(this, n), 'fil', this._ct, this._unit);
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "times", this).call(this, n), 'fil', this._coinType, this._unit);
}

@@ -300,3 +299,3 @@ /**

console.warn('FilecoinNumber.plus(n) should be passed a FilecoinNumber');
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "plus", this).call(this, n), 'fil', this._ct, this._unit);
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "plus", this).call(this, n), 'fil', this._coinType, this._unit);
}

@@ -313,3 +312,3 @@ /**

console.warn('FilecoinNumber.minus(n) should be passed a FilecoinNumber');
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "minus", this).call(this, n), 'fil', this._ct, this._unit);
return new FilecoinNumber((0, _get2["default"])((0, _getPrototypeOf2["default"])(FilecoinNumber.prototype), "minus", this).call(this, n), 'fil', this._coinType, this._unit);
}

@@ -323,5 +322,4 @@ }, {

get: function get() {
var _this$_unit2;
return (_this$_unit2 = this._unit) !== null && _this$_unit2 !== void 0 ? _this$_unit2 : "".concat(this._ct === CoinType.TEST ? 't' : '', "FIL");
var addT = this._coinType === CoinType.TEST && this._unit === 'FIL';
return "".concat(addT ? 't' : '').concat(this._unit);
}

@@ -339,7 +337,7 @@ }], [{

key: "zero",
value: function zero(coinType, unit) {
var ct = coinType !== null && coinType !== void 0 ? coinType : CoinType.MAIN;
if (unit === undefined) return this.zeroCtMap[ct];
if (this.zeroCtUnitMap[ct][unit] === undefined) this.zeroCtUnitMap[ct][unit] = new FilecoinNumber(0, 'fil', ct, unit);
return this.zeroCtUnitMap[ct][unit];
value: function zero() {
var coinType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CoinType.MAIN;
var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'FIL';
if (this.zeroMap[coinType][unit] === undefined) this.zeroMap[coinType][unit] = new FilecoinNumber(0, 'fil', coinType, unit);
return this.zeroMap[coinType][unit];
}

@@ -351,4 +349,3 @@ }]);

exports.FilecoinNumber = FilecoinNumber;
(0, _defineProperty4["default"])(FilecoinNumber, "zeroCtMap", (_defineProperty2 = {}, (0, _defineProperty4["default"])(_defineProperty2, CoinType.MAIN, new FilecoinNumber(0, 'fil', CoinType.MAIN)), (0, _defineProperty4["default"])(_defineProperty2, CoinType.TEST, new FilecoinNumber(0, 'fil', CoinType.TEST)), _defineProperty2));
(0, _defineProperty4["default"])(FilecoinNumber, "zeroCtUnitMap", (_defineProperty3 = {}, (0, _defineProperty4["default"])(_defineProperty3, CoinType.MAIN, {}), (0, _defineProperty4["default"])(_defineProperty3, CoinType.TEST, {}), _defineProperty3));
(0, _defineProperty3["default"])(FilecoinNumber, "zeroMap", (_defineProperty2 = {}, (0, _defineProperty3["default"])(_defineProperty2, CoinType.MAIN, {}), (0, _defineProperty3["default"])(_defineProperty2, CoinType.TEST, {}), _defineProperty2));
//# sourceMappingURL=FilecoinNumber.js.map

@@ -10,3 +10,3 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";

var _defineProperty2, _defineProperty3;
var _defineProperty2;

@@ -66,8 +66,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

// Stores static FilecoinNumber(0, 'fil') instances per CoinType
// Stores static FilecoinNumber(0, 'fil') instances per CoinType and unit
// Static FilecoinNumber(0, 'fil') instances for each CoinType and unit
// Constructor params
function FilecoinNumber(value, denom, coinType, unit) {
function FilecoinNumber(value, denom) {
var _this;
var coinType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : CoinType.MAIN;
var unit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'FIL';
_classCallCheck(this, FilecoinNumber);

@@ -77,7 +79,7 @@

_defineProperty(_assertThisInitialized(_this), "_ct", void 0);
_defineProperty(_assertThisInitialized(_this), "_coinType", void 0);
_defineProperty(_assertThisInitialized(_this), "_unit", void 0);
_this._ct = coinType;
_this._coinType = coinType;
_this._unit = unit;

@@ -99,6 +101,4 @@ return _this;

value: function getDenomUnit(denom) {
var _this$_unit;
var unitDenom = denom.replace(/fil$/, '');
return unitDenom ? "".concat(unitDenom).concat((_this$_unit = this._unit) !== null && _this$_unit !== void 0 ? _this$_unit : 'FIL') : this.unit;
return unitDenom ? "".concat(unitDenom).concat(this._unit) : this.unit;
}

@@ -203,3 +203,3 @@ /**

value: function clone() {
return new FilecoinNumber(this, 'fil', this._ct, this._unit);
return new FilecoinNumber(this, 'fil', this._coinType, this._unit);
}

@@ -213,3 +213,3 @@ /**

value: function abs() {
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "abs", this).call(this), 'fil', this._ct, this._unit);
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "abs", this).call(this), 'fil', this._coinType, this._unit);
}

@@ -232,3 +232,3 @@ /**

value: function negated() {
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "negated", this).call(this), 'fil', this._ct, this._unit);
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "negated", this).call(this), 'fil', this._coinType, this._unit);
}

@@ -242,3 +242,3 @@ /**

value: function div(n) {
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "div", this).call(this, n), 'fil', this._ct, this._unit);
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "div", this).call(this, n), 'fil', this._coinType, this._unit);
}

@@ -261,3 +261,3 @@ /**

value: function times(n) {
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "times", this).call(this, n), 'fil', this._ct, this._unit);
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "times", this).call(this, n), 'fil', this._coinType, this._unit);
}

@@ -283,3 +283,3 @@ /**

console.warn('FilecoinNumber.plus(n) should be passed a FilecoinNumber');
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "plus", this).call(this, n), 'fil', this._ct, this._unit);
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "plus", this).call(this, n), 'fil', this._coinType, this._unit);
}

@@ -296,3 +296,3 @@ /**

console.warn('FilecoinNumber.minus(n) should be passed a FilecoinNumber');
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "minus", this).call(this, n), 'fil', this._ct, this._unit);
return new FilecoinNumber(_get(_getPrototypeOf(FilecoinNumber.prototype), "minus", this).call(this, n), 'fil', this._coinType, this._unit);
}

@@ -306,5 +306,4 @@ }, {

get: function get() {
var _this$_unit2;
return (_this$_unit2 = this._unit) !== null && _this$_unit2 !== void 0 ? _this$_unit2 : "".concat(this._ct === CoinType.TEST ? 't' : '', "FIL");
var addT = this._coinType === CoinType.TEST && this._unit === 'FIL';
return "".concat(addT ? 't' : '').concat(this._unit);
}

@@ -322,7 +321,7 @@ }], [{

key: "zero",
value: function zero(coinType, unit) {
var ct = coinType !== null && coinType !== void 0 ? coinType : CoinType.MAIN;
if (unit === undefined) return this.zeroCtMap[ct];
if (this.zeroCtUnitMap[ct][unit] === undefined) this.zeroCtUnitMap[ct][unit] = new FilecoinNumber(0, 'fil', ct, unit);
return this.zeroCtUnitMap[ct][unit];
value: function zero() {
var coinType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CoinType.MAIN;
var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'FIL';
if (this.zeroMap[coinType][unit] === undefined) this.zeroMap[coinType][unit] = new FilecoinNumber(0, 'fil', coinType, unit);
return this.zeroMap[coinType][unit];
}

@@ -334,5 +333,3 @@ }]);

_defineProperty(FilecoinNumber, "zeroCtMap", (_defineProperty2 = {}, _defineProperty(_defineProperty2, CoinType.MAIN, new FilecoinNumber(0, 'fil', CoinType.MAIN)), _defineProperty(_defineProperty2, CoinType.TEST, new FilecoinNumber(0, 'fil', CoinType.TEST)), _defineProperty2));
_defineProperty(FilecoinNumber, "zeroCtUnitMap", (_defineProperty3 = {}, _defineProperty(_defineProperty3, CoinType.MAIN, {}), _defineProperty(_defineProperty3, CoinType.TEST, {}), _defineProperty3));
_defineProperty(FilecoinNumber, "zeroMap", (_defineProperty2 = {}, _defineProperty(_defineProperty2, CoinType.MAIN, {}), _defineProperty(_defineProperty2, CoinType.TEST, {}), _defineProperty2));
//# sourceMappingURL=FilecoinNumber.js.map

@@ -48,13 +48,12 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";

export class FilecoinNumber extends BigNumber {
// Stores static FilecoinNumber(0, 'fil') instances per CoinType
// Stores static FilecoinNumber(0, 'fil') instances per CoinType and unit
// Static FilecoinNumber(0, 'fil') instances for each CoinType and unit
// Constructor params
constructor(value, denom, coinType, unit) {
constructor(value, denom, coinType = CoinType.MAIN, unit = 'FIL') {
super(toBigNumberValue(value, denom));
_defineProperty(this, "_ct", void 0);
_defineProperty(this, "_coinType", void 0);
_defineProperty(this, "_unit", void 0);
this._ct = coinType;
this._coinType = coinType;
this._unit = unit;

@@ -76,7 +75,5 @@ }

static zero(coinType, unit) {
const ct = coinType ?? CoinType.MAIN;
if (unit === undefined) return this.zeroCtMap[ct];
if (this.zeroCtUnitMap[ct][unit] === undefined) this.zeroCtUnitMap[ct][unit] = new FilecoinNumber(0, 'fil', ct, unit);
return this.zeroCtUnitMap[ct][unit];
static zero(coinType = CoinType.MAIN, unit = 'FIL') {
if (this.zeroMap[coinType][unit] === undefined) this.zeroMap[coinType][unit] = new FilecoinNumber(0, 'fil', coinType, unit);
return this.zeroMap[coinType][unit];
}

@@ -89,3 +86,4 @@ /**

get unit() {
return this._unit ?? `${this._ct === CoinType.TEST ? 't' : ''}FIL`;
const addT = this._coinType === CoinType.TEST && this._unit === 'FIL';
return `${addT ? 't' : ''}${this._unit}`;
}

@@ -99,3 +97,3 @@ /**

const unitDenom = denom.replace(/fil$/, '');
return unitDenom ? `${unitDenom}${this._unit ?? 'FIL'}` : this.unit;
return unitDenom ? `${unitDenom}${this._unit}` : this.unit;
}

@@ -191,3 +189,3 @@ /**

clone() {
return new FilecoinNumber(this, 'fil', this._ct, this._unit);
return new FilecoinNumber(this, 'fil', this._coinType, this._unit);
}

@@ -200,3 +198,3 @@ /**

abs() {
return new FilecoinNumber(super.abs(), 'fil', this._ct, this._unit);
return new FilecoinNumber(super.abs(), 'fil', this._coinType, this._unit);
}

@@ -217,3 +215,3 @@ /**

negated() {
return new FilecoinNumber(super.negated(), 'fil', this._ct, this._unit);
return new FilecoinNumber(super.negated(), 'fil', this._coinType, this._unit);
}

@@ -226,3 +224,3 @@ /**

div(n) {
return new FilecoinNumber(super.div(n), 'fil', this._ct, this._unit);
return new FilecoinNumber(super.div(n), 'fil', this._coinType, this._unit);
}

@@ -243,3 +241,3 @@ /**

times(n) {
return new FilecoinNumber(super.times(n), 'fil', this._ct, this._unit);
return new FilecoinNumber(super.times(n), 'fil', this._coinType, this._unit);
}

@@ -263,3 +261,3 @@ /**

console.warn('FilecoinNumber.plus(n) should be passed a FilecoinNumber');
return new FilecoinNumber(super.plus(n), 'fil', this._ct, this._unit);
return new FilecoinNumber(super.plus(n), 'fil', this._coinType, this._unit);
}

@@ -275,3 +273,3 @@ /**

console.warn('FilecoinNumber.minus(n) should be passed a FilecoinNumber');
return new FilecoinNumber(super.minus(n), 'fil', this._ct, this._unit);
return new FilecoinNumber(super.minus(n), 'fil', this._coinType, this._unit);
}

@@ -281,8 +279,3 @@

_defineProperty(FilecoinNumber, "zeroCtMap", {
[CoinType.MAIN]: new FilecoinNumber(0, 'fil', CoinType.MAIN),
[CoinType.TEST]: new FilecoinNumber(0, 'fil', CoinType.TEST)
});
_defineProperty(FilecoinNumber, "zeroCtUnitMap", {
_defineProperty(FilecoinNumber, "zeroMap", {
[CoinType.MAIN]: {},

@@ -289,0 +282,0 @@ [CoinType.TEST]: {}

{
"name": "@glif/filecoin-number",
"version": "2.0.54",
"version": "2.0.56",
"description": "a javascript package to handle Filecoin numbers like Fil and AttoFil",

@@ -50,3 +50,3 @@ "main": "./dist/index.js",

},
"gitHead": "d53070e8a8dde9857461304851d674774f875521"
"gitHead": "b2c970bc3e2fd6434480fa59969ad158edca7a19"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc