@exodus/models
Advanced tools
Comparing version 11.0.0 to 11.1.0
@@ -22,6 +22,7 @@ "use strict"; | ||
const vals = arr.map(addr => { | ||
if (typeof addr === 'string') return _address.default.create(addr);else if (typeof addr === 'object') return _address.default.fromJSON(addr);else if (addr instanceof _address.default) return addr;else { | ||
console.dir(addr); | ||
throw new Error(`AddressSet#fromArray(): unknown type`); | ||
} | ||
if (typeof addr === 'string') return _address.default.create(addr); | ||
if (typeof addr === 'object') return _address.default.fromJSON(addr); | ||
if (addr instanceof _address.default) return addr; | ||
console.dir(addr); | ||
throw new Error(`AddressSet#fromArray(): unknown type`); | ||
}); | ||
@@ -90,6 +91,9 @@ const ac = new AddressSet(); | ||
const p2 = a2.pathArray; | ||
if (p1[0] < p2[0]) return -1;else if (p1[0] > p2[0]) return 1;else if (p1[0] === p2[0]) { | ||
if (p1[1] < p2[1]) return -1;else if (p1[1] > p2[1]) return 1; | ||
if (p1[0] < p2[0]) return -1; | ||
if (p1[0] > p2[0]) return 1; | ||
if (p1[0] === p2[0]) { | ||
if (p1[1] < p2[1]) return -1; | ||
if (p1[1] > p2[1]) return 1; | ||
return 0; | ||
} | ||
}); |
@@ -12,17 +12,8 @@ "use strict"; | ||
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); } | ||
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); } | ||
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } } | ||
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); } | ||
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; } | ||
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; } | ||
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; } | ||
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); } | ||
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } } | ||
const FACTORY_SYMBOL = Symbol('FiatOrderSet'); | ||
var _items = new WeakMap(); | ||
var _sortOrder = new WeakMap(); | ||
var _txMap = new WeakMap(); | ||
var _getIdsByTx = new WeakSet(); | ||
@@ -38,20 +29,8 @@ var _getSortedIdAt = new WeakSet(); | ||
_classPrivateMethodInitSpec(this, _getIdsByTx); | ||
_classPrivateFieldInitSpec(this, _items, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
_classPrivateFieldInitSpec(this, _sortOrder, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
_classPrivateFieldInitSpec(this, _txMap, { | ||
writable: true, | ||
value: void 0 | ||
}); | ||
(0, _minimalisticAssert.default)(initSymbol === FACTORY_SYMBOL, 'please use FiatOrderSet.EMPTY or FiatOrderSet.fromArray()'); | ||
const itemArray = [...items.values()]; | ||
itemArray.sort((a, b) => b.date - a.date); | ||
_classPrivateFieldSet(this, _items, items); | ||
_classPrivateFieldSet(this, _sortOrder, itemArray.map(tx => tx.orderId)); | ||
_classPrivateFieldSet(this, _txMap, new Map()); | ||
this._items = items; | ||
this._sortOrder = itemArray.map(tx => tx.orderId); | ||
this._txMap = new Map(); | ||
for (const item of itemArray) { | ||
@@ -65,3 +44,3 @@ if (!item.txId) { | ||
} | ||
_classPrivateFieldGet(this, _txMap).set(item.txId, [...oids, String(item)]); | ||
this._txMap.set(item.txId, [...oids, String(item)]); | ||
} | ||
@@ -107,6 +86,6 @@ } | ||
has(item) { | ||
return _classPrivateFieldGet(this, _items).has(String(item)); | ||
return this._items.has(String(item)); | ||
} | ||
get(item) { | ||
return _classPrivateFieldGet(this, _items).get(String(item)); | ||
return this._items.get(String(item)); | ||
} | ||
@@ -127,6 +106,6 @@ getAt(index) { | ||
[_Symbol$iterator]() { | ||
return _classPrivateFieldGet(this, _items).values(); | ||
return this._items.values(); | ||
} | ||
get size() { | ||
return _classPrivateFieldGet(this, _items).size; | ||
return this._items.size; | ||
} | ||
@@ -160,6 +139,6 @@ union(otherSet) { | ||
function _getIdsByTx2(txId) { | ||
return _classPrivateFieldGet(this, _txMap).get(txId) || []; | ||
return this._txMap.get(txId) || []; | ||
} | ||
function _getSortedIdAt2(index) { | ||
return _classPrivateFieldGet(this, _sortOrder)[index]; | ||
return this._sortOrder[index]; | ||
} | ||
@@ -166,0 +145,0 @@ _defineProperty(FiatOrderSet, "EMPTY", new FiatOrderSet({ |
@@ -178,8 +178,8 @@ "use strict"; | ||
return this[key].toISOString() === value.toISOString(); | ||
} else if ((0, _currency.isNumberUnit)(value)) { | ||
} | ||
if ((0, _currency.isNumberUnit)(value)) { | ||
var _this$key; | ||
return (_this$key = this[key]) === null || _this$key === void 0 ? void 0 : _this$key.equals(value); | ||
} else { | ||
return (0, _lodash.isEqual)(this[key], fields[key]); | ||
} | ||
return (0, _lodash.isEqual)(this[key], fields[key]); | ||
}); | ||
@@ -186,0 +186,0 @@ } |
@@ -140,3 +140,4 @@ "use strict"; | ||
function isObjectOrConvert(obj) { | ||
if (obj instanceof _order.default) return obj;else return _order.default.fromJSON(obj); | ||
if (obj instanceof _order.default) return obj; | ||
return _order.default.fromJSON(obj); | ||
} | ||
@@ -143,0 +144,0 @@ function addToTxMap(txMap, txId, orderId) { |
@@ -227,3 +227,4 @@ "use strict"; | ||
if (Array.isArray(utxos)) { | ||
if (utxos.length === 0) return this.removeAddressUtxos(address);else return UtxoCollection.fromArray(utxos, { | ||
if (utxos.length === 0) return this.removeAddressUtxos(address); | ||
return UtxoCollection.fromArray(utxos, { | ||
...this, | ||
@@ -230,0 +231,0 @@ addressMap |
{ | ||
"name": "@exodus/models", | ||
"version": "11.0.0", | ||
"version": "11.1.0", | ||
"description": "Exodus models", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@exodus/assets": "^8.0.93", | ||
"@exodus/assets": "^9.0.1", | ||
"@exodus/assets-base": "^8.1.1", | ||
@@ -43,3 +43,3 @@ "bs58check": "^2.1.2", | ||
}, | ||
"gitHead": "233626769037f490aee3e4b9e07c34d6028316a0" | ||
"gitHead": "fb38ca09b1e5a5e55e2f7d338e2e27a4e5cf1960" | ||
} |
98923
2522