@agoric/store
Advanced tools
Comparing version 0.6.9-dev-0c5d62c.0 to 0.6.9-dev-0cb192c.0
{ | ||
"name": "@agoric/store", | ||
"version": "0.6.9-dev-0c5d62c.0+0c5d62c", | ||
"version": "0.6.9-dev-0cb192c.0+0cb192c", | ||
"description": "Wrapper for JavaScript map", | ||
@@ -33,9 +33,9 @@ "type": "module", | ||
"dependencies": { | ||
"@agoric/assert": "0.3.16-dev-0c5d62c.0+0c5d62c", | ||
"@agoric/eventual-send": "0.14.1-dev-0c5d62c.0+0c5d62c", | ||
"@agoric/promise-kit": "0.2.30-dev-0c5d62c.0+0c5d62c", | ||
"@agoric/assert": "0.3.16-dev-0cb192c.0+0cb192c", | ||
"@agoric/eventual-send": "0.14.1-dev-0cb192c.0+0cb192c", | ||
"@agoric/promise-kit": "0.2.30-dev-0cb192c.0+0cb192c", | ||
"@endo/marshal": "^0.5.4" | ||
}, | ||
"devDependencies": { | ||
"@agoric/swingset-vat": "0.24.2-dev-0c5d62c.0+0c5d62c", | ||
"@agoric/swingset-vat": "0.24.2-dev-0cb192c.0+0cb192c", | ||
"ava": "^3.12.1" | ||
@@ -65,3 +65,3 @@ }, | ||
}, | ||
"gitHead": "0c5d62ceebe0e7a6e2a385256ab059637b83d01d" | ||
"gitHead": "0cb192c1acc892de975c5cc4c38bd75bf7c83d9f" | ||
} |
@@ -59,2 +59,8 @@ // @ts-check | ||
export { compareRank, isRankSorted, sortByRank } from './patterns/rankOrder.js'; | ||
export { | ||
makeDecodeKey, | ||
makeEncodeKey, | ||
zeroPad, | ||
BIGINT_TAG_LEN, | ||
} from './patterns/encodeKey.js'; | ||
@@ -61,0 +67,0 @@ export { makeScalarWeakSetStore } from './stores/scalarWeakSetStore.js'; |
@@ -6,3 +6,3 @@ // @ts-check | ||
import { passStyleOf, getTag } from '@endo/marshal'; | ||
import { compareRank } from '../patterns/rankOrder.js'; | ||
import { compareRank, recordParts } from '../patterns/rankOrder.js'; | ||
import { assertKey } from './checkKey.js'; | ||
@@ -13,3 +13,2 @@ import { bagCompare } from './merge-bag-operators.js'; | ||
const { details: X, quote: q } = assert; | ||
const { ownKeys } = Reflect; | ||
@@ -76,4 +75,5 @@ /** @type {KeyCompare} */ | ||
// Pareto partial order comparison. | ||
const leftNames = harden(ownKeys(left).sort()); | ||
const rightNames = harden(ownKeys(right).sort()); | ||
const [leftNames, leftValues] = recordParts(left); | ||
const [rightNames, rightValues] = recordParts(right); | ||
// eslint-disable-next-line no-use-before-define | ||
@@ -91,4 +91,4 @@ if (!keyEQ(leftNames, rightNames)) { | ||
let result = 0; | ||
for (const name of leftNames) { | ||
const comp = compareKeys(left[name], right[name]); | ||
for (let i = 0; i < leftValues.length; i += 1) { | ||
const comp = compareKeys(leftValues[i], rightValues[i]); | ||
if (Number.isNaN(comp)) { | ||
@@ -95,0 +95,0 @@ return NaN; |
@@ -12,6 +12,6 @@ // @ts-check | ||
import { | ||
compareAntiRank, | ||
compareRank, | ||
getPassStyleCover, | ||
intersectRankCovers, | ||
recordParts, | ||
unionRankCovers, | ||
@@ -34,4 +34,2 @@ } from './rankOrder.js'; | ||
// const { entries, fromEntries } = Object; // XXX TEMP | ||
const { ownKeys } = Reflect; | ||
const { quote: q, details: X } = assert; | ||
@@ -298,4 +296,4 @@ | ||
} | ||
const specNames = harden(ownKeys(specimen).sort(compareAntiRank)); | ||
const pattNames = harden(ownKeys(patt).sort(compareAntiRank)); | ||
const [specNames, specValues] = recordParts(specimen); | ||
const [pattNames, pattValues] = recordParts(patt); | ||
if (!keyEQ(specNames, pattNames)) { | ||
@@ -307,4 +305,2 @@ return check( | ||
} | ||
const specValues = harden(specNames.map(name => specimen[name])); | ||
const pattValues = harden(pattNames.map(name => patt[name])); | ||
return checkMatches(specValues, pattValues, check); | ||
@@ -311,0 +307,0 @@ } |
// @ts-check | ||
import { assert, details as X, q } from '@agoric/assert'; | ||
import { getTag, nameForPassableSymbol, passStyleOf } from '@endo/marshal'; | ||
import { | ||
assertRecord, | ||
getTag, | ||
nameForPassableSymbol, | ||
passStyleOf, | ||
} from '@endo/marshal'; | ||
@@ -69,2 +74,14 @@ const { fromEntries, entries, setPrototypeOf, is } = Object; | ||
export const recordParts = record => { | ||
assertRecord(record); | ||
// TODO Measure which is faster: a reverse sort by sorting and | ||
// reversing, or by sorting with an inverse comparison function. | ||
// If it makes a significant difference, use the faster one. | ||
const names = ownKeys(record).sort().reverse(); | ||
// @ts-expect-error It thinks name might be a symbol, which it doesn't like. | ||
const vals = names.map(name => record[name]); | ||
return harden([names, vals]); | ||
}; | ||
harden(recordParts); | ||
/** | ||
@@ -78,3 +95,3 @@ * @param {RankCompare=} compareRemotables | ||
*/ | ||
const makeComparatorKit = (compareRemotables = (_x, _y) => 0) => { | ||
export const makeComparatorKit = (compareRemotables = (_x, _y) => 0) => { | ||
/** @type {RankCompare} */ | ||
@@ -149,11 +166,5 @@ const comparator = (left, right) => { | ||
// then record X will have an earlier rank and sort to the left of Y. | ||
const leftNames = harden( | ||
ownKeys(left) | ||
.sort() | ||
// TODO Measure which is faster: a reverse sort by sorting and | ||
// reversing, or by sorting with an inverse comparison function. | ||
// If it makes a significant difference, use the faster one. | ||
.reverse(), | ||
); | ||
const rightNames = harden(ownKeys(right).sort().reverse()); | ||
const [leftNames, leftValues] = recordParts(left); | ||
const [rightNames, rightValues] = recordParts(right); | ||
const result = comparator(leftNames, rightNames); | ||
@@ -163,4 +174,2 @@ if (result !== 0) { | ||
} | ||
const leftValues = harden(leftNames.map(name => left[name])); | ||
const rightValues = harden(rightNames.map(name => right[name])); | ||
return comparator(leftValues, rightValues); | ||
@@ -167,0 +176,0 @@ } |
@@ -36,2 +36,3 @@ // @ts-check | ||
() => jsmap.keys(), | ||
k => jsmap.has(k), | ||
compareRank, | ||
@@ -38,0 +39,0 @@ assertKVOkToAdd, |
@@ -29,2 +29,3 @@ // @ts-check | ||
() => jsset.keys(), | ||
k => jsset.has(k), | ||
compareRank, | ||
@@ -55,2 +56,4 @@ assertKeyOkToAdd, | ||
values: keys, | ||
snapshot: (keyPatt = undefined) => makeCopySet(keys(keyPatt)), | ||
@@ -57,0 +60,0 @@ |
@@ -18,2 +18,3 @@ // @ts-check | ||
* @param {() => Iterable<K>} getRawKeys | ||
* @param {(k: K) => boolean} checkHas | ||
* @param {RankCompare} compare | ||
@@ -27,2 +28,3 @@ * @param {(k: K, v?: V) => void} assertOkToAdd | ||
getRawKeys, | ||
checkHas, | ||
compare, | ||
@@ -42,13 +44,3 @@ assertOkToAdd, | ||
const assertUpdateOnDelete = | ||
assertOkToDelete === undefined | ||
? _k => { | ||
updateCount += 1; | ||
sortedKeysMemo = undefined; | ||
} | ||
: k => { | ||
assertOkToDelete(k); | ||
updateCount += 1; | ||
sortedKeysMemo = undefined; | ||
}; | ||
const assertUpdateOnDelete = k => assertOkToDelete && assertOkToDelete(k); | ||
@@ -77,8 +69,12 @@ const getSortedKeys = () => { | ||
// we started with. | ||
if (i < len) { | ||
const result = harden({ done: false, value: sortedKeysMemo[i] }); | ||
i += 1; | ||
return result; | ||
} else { | ||
return harden({ done: true, value: undefined }); | ||
for (;;) { | ||
if (i < len) { | ||
const value = sortedKeysMemo[i]; | ||
i += 1; | ||
if (checkHas(value)) { | ||
return harden({ done: false, value }); | ||
} | ||
} else { | ||
return harden({ done: true, value: undefined }); | ||
} | ||
} | ||
@@ -85,0 +81,0 @@ }, |
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
181502
25
4524