@agoric/marshal
Advanced tools
Comparing version 0.5.1-dev-9551cb4.0 to 0.5.1-dev-98ecefe.0
@@ -7,2 +7,3 @@ export { mapIterable, filterIterable } from './src/helpers/iter-helpers.js'; | ||
getTag, | ||
hasOwnPropertyOf, | ||
} from './src/helpers/passStyle-helpers.js'; | ||
@@ -21,8 +22,3 @@ | ||
export { | ||
passStyleOf, | ||
assertPassable, | ||
everyPassableChild, | ||
somePassableChild, | ||
} from './src/passStyleOf.js'; | ||
export { passStyleOf, assertPassable } from './src/passStyleOf.js'; | ||
@@ -29,0 +25,0 @@ export { pureCopy, sameValueZero } from './src/pureCopy.js'; |
{ | ||
"name": "@agoric/marshal", | ||
"version": "0.5.1-dev-9551cb4.0+9551cb4", | ||
"version": "0.5.1-dev-98ecefe.0+98ecefe", | ||
"description": "marshal", | ||
@@ -37,10 +37,10 @@ "type": "module", | ||
"dependencies": { | ||
"@agoric/assert": "0.3.16-dev-9551cb4.0+9551cb4", | ||
"@agoric/eventual-send": "0.14.1-dev-9551cb4.0+9551cb4", | ||
"@agoric/assert": "0.3.16-dev-98ecefe.0+98ecefe", | ||
"@agoric/eventual-send": "0.14.1-dev-98ecefe.0+98ecefe", | ||
"@agoric/nat": "^4.1.0", | ||
"@agoric/promise-kit": "0.2.30-dev-9551cb4.0+9551cb4" | ||
"@agoric/promise-kit": "0.2.30-dev-98ecefe.0+98ecefe" | ||
}, | ||
"devDependencies": { | ||
"@agoric/lockdown": "0.1.2-dev-9551cb4.0+9551cb4", | ||
"@endo/ses-ava": "^0.2.8", | ||
"@agoric/lockdown": "0.1.2-dev-98ecefe.0+98ecefe", | ||
"@endo/ses-ava": "^0.2.13", | ||
"ava": "^3.12.1", | ||
@@ -72,3 +72,3 @@ "c8": "^7.7.2" | ||
}, | ||
"gitHead": "9551cb4e0decec83a3aa85fba6c7261c74593d7f" | ||
"gitHead": "98ecefeda616ed10b8ddf0bb9db1b7fb0b324bf3" | ||
} |
@@ -8,14 +8,6 @@ // @ts-check | ||
/** | ||
* @typedef {Array} CopyArray | ||
*/ | ||
/** | ||
* @typedef {Record<string, Passable>} CopyRecord | ||
*/ | ||
/** | ||
* Check whether the argument is a pass-by-copy array, AKA a "copyArray" | ||
* in @agoric/marshal terms | ||
* | ||
* @param {CopyArray} array | ||
* @param {CopyArray<any>} array | ||
* @returns {boolean} | ||
@@ -30,3 +22,3 @@ */ | ||
* | ||
* @param {CopyRecord} record | ||
* @param {CopyRecord<any>} record | ||
* @returns {boolean} | ||
@@ -50,3 +42,3 @@ */ | ||
* | ||
* @param {CopyArray} array | ||
* @param {CopyArray<any>} array | ||
* @param {string=} optNameOfArray | ||
@@ -70,3 +62,3 @@ * @returns {void} | ||
* | ||
* @param {CopyRecord} record | ||
* @param {CopyRecord<any>} record | ||
* @param {string=} optNameOfRecord | ||
@@ -73,0 +65,0 @@ * @returns {void} |
@@ -47,9 +47,4 @@ // @ts-check | ||
// Recursively validate that each member is passable. | ||
CopyArrayHelper.every(candidate, v => !!passStyleOfRecur(v)); | ||
candidate.every(v => !!passStyleOfRecur(v)); | ||
}, | ||
every: (passable, fn) => | ||
// Note that we explicitly call `fn` with only the arguments we want | ||
// to provide. | ||
passable.every((v, i) => fn(v, i)), | ||
}); |
@@ -21,3 +21,2 @@ // @ts-check | ||
getOwnPropertyDescriptors, | ||
entries, | ||
prototype: objectPrototype, | ||
@@ -66,9 +65,4 @@ } = Object; | ||
// Recursively validate that each member is passable. | ||
CopyRecordHelper.every(candidate, v => !!passStyleOfRecur(v)); | ||
Object.values(candidate).every(v => !!passStyleOfRecur(v)); | ||
}, | ||
every: (passable, fn) => | ||
// Note that we explicitly call `fn` with only the arguments we want | ||
// to provide. | ||
entries(passable).every(([k, v]) => fn(v, k)), | ||
}); |
@@ -98,4 +98,2 @@ // @ts-check | ||
}, | ||
every: (_passable, _fn) => true, | ||
}); | ||
@@ -102,0 +100,0 @@ |
@@ -30,8 +30,2 @@ // @ts-check | ||
* ) => void} assertValid | ||
* | ||
* @property {(passable: Passable, | ||
* fn: (passable: Passable, index: any) => boolean | ||
* ) => boolean} every | ||
* For recuring through the nested passable structure. Like | ||
* `Array.prototype.every`, return `false` to stop early. | ||
*/ |
@@ -54,6 +54,4 @@ // @ts-check | ||
// Recursively validate that each member is passable. | ||
TaggedHelper.every(candidate, v => !!passStyleOfRecur(v)); | ||
!!passStyleOfRecur(candidate.payload); | ||
}, | ||
every: (passable, fn) => fn(passable.payload, 'payload'), | ||
}); |
@@ -31,5 +31,5 @@ // @ts-check | ||
* accidents. | ||
* @returns {{passStyleOf: PassStyleOf, HelperTable: any}} | ||
* @returns {PassStyleOf} | ||
*/ | ||
const makePassStyleOfKit = passStyleHelpers => { | ||
const makePassStyleOf = passStyleHelpers => { | ||
const HelperTable = { | ||
@@ -183,6 +183,6 @@ __proto__: null, | ||
}; | ||
return harden({ passStyleOf, HelperTable }); | ||
return harden(passStyleOf); | ||
}; | ||
const { passStyleOf, HelperTable } = makePassStyleOfKit([ | ||
export const passStyleOf = makePassStyleOf([ | ||
CopyArrayHelper, | ||
@@ -194,3 +194,2 @@ CopyRecordHelper, | ||
]); | ||
export { passStyleOf }; | ||
@@ -201,17 +200,1 @@ export const assertPassable = val => { | ||
harden(assertPassable); | ||
export const everyPassableChild = (passable, fn) => { | ||
const passStyle = passStyleOf(passable); | ||
const helper = HelperTable[passStyle]; | ||
if (helper) { | ||
// everyPassable guards .every so that each helper only gets a | ||
// genuine passable of its own flavor. | ||
return helper.every(passable, fn); | ||
} | ||
return true; | ||
}; | ||
harden(everyPassableChild); | ||
export const somePassableChild = (passable, fn) => | ||
!everyPassableChild(passable, (v, i) => !fn(v, i)); | ||
harden(somePassableChild); |
@@ -101,2 +101,12 @@ // @ts-nocheck TODO Fix the recursive types to it checks. Will this | ||
/** | ||
* @template T | ||
* @typedef {T[]} CopyArray | ||
*/ | ||
/** | ||
* @template T | ||
* @typedef {Record<string, T>} CopyRecord | ||
*/ | ||
/** | ||
* @typedef {{ | ||
@@ -103,0 +113,0 @@ * [PASS_STYLE]: 'tagged', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
135213
2890