Endo API documentation - v0.2.0 / Exports / @endo/patterns
Module: @endo/patterns
Table of contents
Interfaces
- AllLimits
- FullComparatorKit
- GuardMakers
- MethodGuardOptional
- MethodGuardRest
- MethodGuardReturns
- PatternMatchers
- RankComparatorKit
Type Aliases
- ArgGuard
- AwaitArgGuard
- AwaitArgGuardPayload
- CheckPattern
- Checker
- CopyArray
- CopyBag
- CopyMap
- CopyRecord
- CopySet
- CopyTagged
- DefaultGuardType
- FullCompare
- GetRankCover
- InterfaceGuard
- InterfaceGuardPayload
- Key
- KeyCollection
- KeyCompare
- KeyComparison
- KeyToDBKey
- Limits
- MakeInterfaceGuard
- MakeInterfaceGuardGeneral
- MakeInterfaceGuardSloppy
- MakeInterfaceGuardStrict
- Matcher
- MatcherNamespace
- Method
- MethodGuard
- MethodGuardMaker
- MethodGuardPayload
- MethodGuardRestReturns
- PassStyle
- Passable
- Pattern
- RankCompare
- RankCover
- RawGuard
- RawGuardPayload
- SyncValueGuard
Variables
Functions
- assertAwaitArgGuard
- assertCopyBag
- assertCopyMap
- assertCopySet
- assertInterfaceGuard
- assertKey
- assertMethodGuard
- assertPattern
- assertRawGuard
- assertScalarKey
- bagCompare
- bagDisjointSubtract
- bagIntersection
- bagIsSuperbag
- bagUnion
- coerceToBagEntries
- coerceToElements
- compareKeys
- elementsCompare
- elementsDisjointSubtract
- elementsDisjointUnion
- elementsIntersection
- elementsIsDisjoint
- elementsIsSuperset
- elementsUnion
- getAwaitArgGuardPayload
- getCopyBagEntries
- getCopyMapEntries
- getCopySetKeys
- getInterfaceGuardPayload
- getInterfaceMethodKeys
- getMethodGuardPayload
- getRankCover
- isAwaitArgGuard
- isCopyBag
- isCopyMap
- isCopySet
- isKey
- isPattern
- isRawGuard
- keyEQ
- keyGT
- keyGTE
- keyLT
- keyLTE
- kindOf
- listDifference
- makeCopyBag
- makeCopyBagFromElements
- makeCopyMap
- makeCopySet
- matches
- mustMatch
- objectMap
- setCompare
- setDisjointSubtract
- setDisjointUnion
- setIntersection
- setIsDisjoint
- setIsSuperset
- setUnion
Type Aliases
ArgGuard
Ƭ ArgGuard: AwaitArgGuard
| RawGuard
| Pattern
Defined in
AwaitArgGuard
Ƭ AwaitArgGuard: CopyTagged
<"guard:awaitArgGuard"
, AwaitArgGuardPayload
>
Defined in
AwaitArgGuardPayload
Ƭ AwaitArgGuardPayload: Object
Type declaration
Name | Type |
---|---|
argGuard | Pattern |
Defined in
CheckPattern
Ƭ CheckPattern: (allegedPattern
: Passable
, check
: Checker
) => boolean
Type declaration
▸ (allegedPattern
, check
): boolean
Parameters
Name | Type |
---|---|
allegedPattern | Passable |
check | Checker |
Returns
boolean
Defined in
Checker
Ƭ Checker: (cond
: boolean
, details?
: ses
) => boolean
Internal to a useful pattern for writing checking logic (a "checkFoo" function) that can be used to implement a predicate (an "isFoo" function) or a validator (an "assertFoo" function).
- A predicate ideally only returns
true
orfalse
and rarely throws. - A validator throws an informative diagnostic when the predicate would have returned
false
, and simply returnsundefined
normally when the predicate would have returnedtrue
. - The internal checking function that they share is parameterized by a
Checker
that determines how to proceed with a failure condition. Predicates pass in an identity function as checker. Validators pass inassertChecker
which is a trivial wrapper aroundassert
.
See the various uses for good examples.
Type declaration
▸ (cond
, details?
): boolean
Parameters
Name | Type |
---|---|
cond | boolean |
details? | ses |
Returns
boolean
Defined in
CopyArray
Ƭ CopyArray<T
>: T
[]
A Passable sequence of Passable values.
Type parameters
Name | Type |
---|---|
T | extends Passable = Passable |
Defined in
CopyBag
Ƭ CopyBag<K
>: CopyTagged
<"copyBag"
, [K
, bigint
][]>
A Passable collection of entries with Keys that are all mutually distinguishable according to the key distributed equality semantics exposed by keyEQ
, each with a corresponding positive cardinality.
Type parameters
Name | Type |
---|---|
K | extends Key = Key |
Defined in
CopyMap
Ƭ CopyMap<K
, V
>: CopyTagged
<"copyMap"
, { keys
: K
[] ; values
: V
[] }>
A Passable collection of entries with Keys that are all mutually distinguishable according to the key distributed equality semantics exposed by keyEQ
, each with a corresponding Passable value.
Type parameters
Name | Type |
---|---|
K | extends Key = Key |
V | extends Passable = Passable |
Defined in
CopyRecord
Ƭ CopyRecord<T
>: Record
<string
, T
>
A Passable dictionary in which each key is a string and each value is Passable.
Type parameters
Name | Type |
---|---|
T | extends Passable = Passable |
Defined in
CopySet
Ƭ CopySet<K
>: CopyTagged
<"copySet"
, K
[]>
A Passable collection of Keys that are all mutually distinguishable according to the key distributed equality semantics exposed by keyEQ
.
Type parameters
Name | Type |
---|---|
K | extends Key = Key |
Defined in
CopyTagged
Ƭ CopyTagged<Tag
, Payload
>: Object
A Passable "tagged record" with semantics specific to the tag identified in the [Symbol.toStringTag]
property (such as 'copySet', 'copyBag', or 'copyMap'). It must have a property with key equal to the PASS_STYLE
export and value 'tagged' and no other properties except [Symbol.toStringTag]
and payload
.
TODO But TypeScript complains about a declaration like [PASS_STYLE]: 'tagged'
because importing packages do not know what PASS_STYLE
is, so we appease it with a looser but less accurate definition using symbol index properties and | string
.
Type parameters
Name | Type |
---|---|
Tag | extends string = string |
Payload | extends Passable = Passable |
Index signature
▪ [passStyle: symbol
]: "tagged"
| string
Type declaration
Name | Type |
---|---|
[toStringTag] | Tag |
payload | Payload |
Defined in
DefaultGuardType
Ƭ DefaultGuardType: undefined
| "passable"
| "raw"
Defined in
FullCompare
Ƭ FullCompare: RankCompare
A FullCompare
function satisfies all the invariants stated below for RankCompare
's relation with KeyCompare. In addition, its equality is as precise as the KeyCompare
comparison defined below, in that, for all Keys x
and y
, FullCompare(x, y) === 0
iff KeyCompare(x, y) === 0
.
For non-Key inputs, a FullCompare
should be exactly as imprecise as RankCompare
. For example, both will treat all errors as in the same equivalence class. Both will treat all promises as in the same equivalence class. Both will order tagged records the same way, which is admittedly weird because some (such as CopySets, CopyBags, and CopyMaps) will be considered Keys while others will be considered non-Keys.
Defined in
GetRankCover
Ƭ GetRankCover: (payload
: Passable
, encodePassable
: KeyToDBKey
) => RankCover
Type declaration
▸ (payload
, encodePassable
): RankCover
Parameters
Name | Type |
---|---|
payload | Passable |
encodePassable | KeyToDBKey |
Returns
Defined in
InterfaceGuard
Ƭ InterfaceGuard<T
>: CopyTagged
<"guard:interfaceGuard"
, InterfaceGuardPayload
<T
>>
Type parameters
Name | Type |
---|---|
T | extends Record <PropertyKey , MethodGuard > = Record <PropertyKey , MethodGuard > |
Defined in
InterfaceGuardPayload
Ƭ InterfaceGuardPayload<T
>: Object
Type parameters
Name | Type |
---|---|
T | extends Record <PropertyKey , MethodGuard > = Record <PropertyKey , MethodGuard > |
Type declaration
Name | Type |
---|---|
defaultGuards? | DefaultGuardType |
interfaceName | string |
methodGuards | Omit <T , symbol > & Partial <{ [K in Extract<keyof T, symbol>]: never }> |
sloppy? | boolean |
symbolMethodGuards? | CopyMap <Extract <keyof T , symbol >, T [Extract <keyof T , symbol >]> |
Defined in
Key
Ƭ Key: Passable
Keys are Passable arbitrarily-nested pass-by-copy containers (CopyArray, CopyRecord, CopySet, CopyBag, CopyMap) in which every non-container leaf is either a Passable primitive value or a Remotable (a remotely-accessible object or presence for a remote object), or such leaves in isolation with no container.
Keys are so named because they can be used as keys in CopyMaps and agoric-sdk Stores, and as elements in CopySets and CopyBags.
Keys cannot contain promises or errors, as these do not have useful distributed equality semantics. Keys also cannot contain any CopyTagged except for those recognized as CopySets, CopyBags, and CopyMaps.
Be aware that we may recognize more CopyTaggeds over time, including CopyTaggeds recognized as Keys.
Distributed equality is location independent. The same two Keys, passed to another location, will be keyEQ
there iff they are keyEQ
here. (keyEQ
tests equality according to the key distributed equality semantics.)
Defined in
KeyCollection
Ƭ KeyCollection: CopySet
| CopyBag
| CopyMap
CopySet, CopyBag, and CopyMap all store Keys in reverse rankOrder, which supports generalized utilities.
Defined in
KeyCompare
Ƭ KeyCompare: (left
: Key
, right
: Key
) => KeyComparison
compareKeys
implements a partial order over Keys --- it defines relative position between two Keys but leaves some pairs incomparable (for example, subsets over sets is a partial order in which {} precedes {x} and {y}, which are mutually incomparable but both precede {x, y}). As with the rank ordering produced by compareRank
, -1, 0, and 1 respectively mean "less than", "equivalent to", and "greater than". NaN means "incomparable" --- the first key is not less, equivalent, or greater than the second.
By using NaN for "incomparable", the normal equivalence for using the return value in a comparison is preserved. compareKeys(left, right) >= 0
iff left
is greater than or equivalent to right
in the partial ordering.
Key order (a partial order) and rank order (a total preorder) are co-designed to support efficient range search for Key-based queries (@see ../README.md#rank-order-and-key-order).
Type declaration
▸ (left
, right
): KeyComparison
Parameters
Name | Type |
---|---|
left | Key |
right | Key |
Returns
Defined in
KeyComparison
Ƭ KeyComparison: -1
| 0
| 1
| NaN
The result of a KeyCompare
function that defines a meaningful and meaningfully precise partial order of Key values. See KeyCompare
.
Defined in
KeyToDBKey
Ƭ KeyToDBKey: (key
: Key
) => string
Type declaration
▸ (key
): string
Parameters
Name | Type |
---|---|
key | Key |
Returns
string
Defined in
Limits
Ƭ Limits: Partial
<AllLimits
>
Defined in
MakeInterfaceGuard
Ƭ MakeInterfaceGuard: MakeInterfaceGuardStrict
& MakeInterfaceGuardSloppy
& MakeInterfaceGuardGeneral
Defined in
MakeInterfaceGuardGeneral
Ƭ MakeInterfaceGuardGeneral: <M>(interfaceName
: string
, methodGuards
: M
, options?
: { defaultGuards?
: DefaultGuardType
; sloppy?
: boolean
}) => InterfaceGuard
<M
>
Type declaration
▸ <M
>(interfaceName
, methodGuards
, options?
): InterfaceGuard
<M
>
Type parameters
Name | Type |
---|---|
M | extends Record <PropertyKey , MethodGuard > |
Parameters
Name | Type |
---|---|
interfaceName | string |
methodGuards | M |
options? | Object |
options.defaultGuards? | DefaultGuardType |
options.sloppy? | boolean |
Returns
Defined in
MakeInterfaceGuardSloppy
Ƭ MakeInterfaceGuardSloppy: (interfaceName
: string
, methodGuards
: any
, options
: { defaultGuards?
: "passable"
| "raw"
; sloppy?
: true
}) => InterfaceGuard
<any
>
Type declaration
▸ (interfaceName
, methodGuards
, options
): InterfaceGuard
<any
>
Parameters
Name | Type |
---|---|
interfaceName | string |
methodGuards | any |
options | Object |
options.defaultGuards? | "passable" | "raw" |
options.sloppy? | true |
Returns
InterfaceGuard
<any
>
Defined in
MakeInterfaceGuardStrict
Ƭ MakeInterfaceGuardStrict: <M>(interfaceName
: string
, methodGuards
: M
, options
: { defaultGuards?
: undefined
; sloppy?
: false
}) => InterfaceGuard
<M
>
Type declaration
▸ <M
>(interfaceName
, methodGuards
, options
): InterfaceGuard
<M
>
Type parameters
Name | Type |
---|---|
M | extends Record <PropertyKey , MethodGuard > |
Parameters
Name | Type |
---|---|
interfaceName | string |
methodGuards | M |
options | Object |
options.defaultGuards? | undefined |
options.sloppy? | false |
Returns
Defined in
Matcher
Ƭ Matcher: CopyTagged
<`match:${string}`, Passable
>
A Pattern representing the predicate characterizing a category of Passables, such as strings or 8-bit unsigned integer numbers or CopyArrays of Remotables.
Defined in
MatcherNamespace
Ƭ MatcherNamespace: PatternMatchers
& GuardMakers
Defined in
Method
Ƭ Method: (...args
: any
[]) => any
Type declaration
▸ (...args
): any
Parameters
Name | Type |
---|---|
...args | any [] |
Returns
any
Defined in
MethodGuard
Ƭ MethodGuard: CopyTagged
<"guard:methodGuard"
, MethodGuardPayload
>
Defined in
MethodGuardMaker
Ƭ MethodGuardMaker: MethodGuardOptional
& MethodGuardRestReturns
A method name and parameter/return signature like:
foo(a, b, c = d, ...e) => f
should be guarded by something like:
{
...otherMethodGuards,
foo: M.call(AShape, BShape).optional(CShape).rest(EShape).returns(FShape),
}
/**
Defined in
MethodGuardPayload
Ƭ MethodGuardPayload: Object
Type declaration
Name | Type |
---|---|
argGuards | ArgGuard [] |
callKind | "sync" | "async" |
optionalArgGuards? | ArgGuard [] |
restArgGuard? | SyncValueGuard |
returnGuard | SyncValueGuard |
Defined in
MethodGuardRestReturns
Ƭ MethodGuardRestReturns: MethodGuardRest
& MethodGuardReturns
Mandatory and optional arguments have been specified, now specify rest
, or finish with returns
.
Defined in
PassStyle
Ƭ PassStyle: PrimitiveStyle
| "copyRecord"
| "copyArray"
| "tagged"
| "remotable"
| "error"
| "promise"
Defined in
Passable
Ƭ Passable: any
A Passable is acyclic data that can be marshalled. It must be hardened to remain stable (even if some components are proxies; see PureData restriction below), and is classified by PassStyle:
- Atomic primitive values have a PrimitiveStyle (PassStyle 'undefined' | 'null' | 'boolean' | 'number' | 'bigint' | 'string' | 'symbol').
- Containers aggregate other Passables into
- sequences as CopyArrays (PassStyle 'copyArray'), or
- string-keyed dictionaries as CopyRecords (PassStyle 'copyRecord'), or
- higher-level types as CopyTaggeds (PassStyle 'tagged').
- PassableCaps (PassStyle 'remotable' | 'promise') expose local values to remote interaction.
- As a special case to support system observability, error objects are Passable (PassStyle 'error').
A Passable is essentially a pass-by-copy superstructure with a pass-by-reference exit point at the site of each PassableCap (which marshalling represents using 'slots').
Defined in
Pattern
Ƭ Pattern: Passable
Patterns are Passable arbitrarily-nested pass-by-copy containers (CopyArray, CopyRecord, CopySet, CopyBag, CopyMap) in which every non-container leaf is either a Key or a Matcher, or such leaves in isolation with no container.
A Pattern acts as a declarative total predicate over Passables, where each Passable is either matched or not matched by it. Every Key is also a Pattern that matches only "itself", i.e., Keys that are keyEQ
to it according to the key distributed equality semantics.
Patterns cannot contain promises or errors, as these do not have useful distributed equality or matching semantics. Likewise, no Pattern can distinguish among promises, or distinguish among errors. Patterns also cannot contain any CopyTaggeds except for those recognized as CopySets, CopyBags, CopyMaps, or Matchers.
Be aware that we may recognize more CopyTaggeds over time, including CopyTaggeds recognized as Patterns.
Whether a Passable is matched by a given Pattern is location independent. If a given Passable and Pattern are passed to another location, the Passable will be matched by the Pattern there iff the Passable is matched by the Pattern here.
Patterns are often used in a type-like manner, to represent the category of Passables that the Pattern is intended* to match. To keep this distinction clear, we often use the suffix "Shape" rather than "Pattern" to avoid confusion when the Pattern itself represents some category of Pattern. For example, an "AmountShape" represents the category of Amounts. And "AmountPatternShape" represents the category of Patterns over Amounts.
- We say "intended" above because Patterns, in order to be declarative and Passable, cannot have the generality of predicates written in a Turing-universal programming language. Rather, to represent the category of things intended to be a Foo, a FooShape should reliably accept all Foos and reject only non-Foos. However, a FooShape may also accept non-Foos that "look like" or "have the same shape as" genuine Foos. An accurate predicate for e.g. input validation would need to supplement the Pattern check with code to detect the residual cases. We hope the "Shape" metaphor helps remind us of this type-like imprecision of Patterns.
Defined in
RankCompare
Ƭ RankCompare: (left
: any
, right
: any
) => RankComparison
Returns -1
, 0
, or 1
depending on whether the rank of left
is respectively before, tied-with, or after the rank of right
.
This comparison function is valid as argument to Array.prototype.sort
. This is sometimes described as a "total order" but, depending on your definitions, this is technically incorrect because it may return 0
to indicate that two distinguishable elements such as -0
and 0
are tied (i.e., are in the same equivalence class for the purposes of this ordering). If each such equivalence class is a rank and ranks are disjoint, then this "rank order" is a true total order over these ranks. In mathematics this goes by several other names such as "total preorder".
This function establishes a total rank order over all passables. To do so it makes arbitrary choices, such as that all strings are after all numbers. Thus, this order is not intended to be used directly as a comparison with useful semantics. However, it must be closely enough related to such comparisons to aid in implementing lookups based on those comparisons. For example, in order to get a total order among ranks, we put NaN
after all other JavaScript "number" values (i.e., IEEE 754 floating-point values). But otherwise, we rank JavaScript numbers by signed magnitude, with 0
and -0
tied. A semantically useful ordering would also compare magnitudes, and so agree with the rank ordering of all values other than NaN
. An array sorted by rank would enable range queries by magnitude.
Type declaration
▸ (left
, right
): RankComparison
Parameters
Name | Type | Description |
---|---|---|
left | any | a Passable |
right | any | a Passable |
Returns
Defined in
RankCover
Ƭ RankCover: [string
, string
]
RankCover represents the inclusive lower bound and inclusive upper bound of a string-comparison range that covers all possible encodings for a set of values.
Defined in
RawGuard
Ƭ RawGuard: CopyTagged
<"guard:rawGuard"
, RawGuardPayload
>
Defined in
RawGuardPayload
Ƭ RawGuardPayload: Object
Defined in
SyncValueGuard
Ƭ SyncValueGuard: RawGuard
| Pattern
Defined in
Variables
M
• M: MatcherNamespace
Defined in
patterns/src/patterns/patternMatchers.js:1758
Functions
assertAwaitArgGuard
▸ assertAwaitArgGuard(specimen
): asserts specimen is AwaitArgGuard
Parameters
Name | Type |
---|---|
specimen | any |
Returns
asserts specimen is AwaitArgGuard
Defined in
patterns/src/patterns/patternMatchers.js:1785
assertCopyBag
▸ assertCopyBag(b
): asserts b is CopyBag<any>
Parameters
Name | Type |
---|---|
b | any |
Returns
asserts b is CopyBag<any>
Defined in
patterns/src/keys/checkKey.js:279
assertCopyMap
▸ assertCopyMap(m
): asserts m is CopyMap<any, any>
Parameters
Name | Type |
---|---|
m | any |
Returns
asserts m is CopyMap<any, any>
Defined in
patterns/src/keys/checkKey.js:406
assertCopySet
▸ assertCopySet(s
): asserts s is CopySet<any>
Parameters
Name | Type |
---|---|
s | any |
Returns
asserts s is CopySet<any>
Defined in
patterns/src/keys/checkKey.js:195
assertInterfaceGuard
▸ assertInterfaceGuard(specimen
): asserts specimen is InterfaceGuard<Record<PropertyKey, MethodGuard>>
Parameters
Name | Type |
---|---|
specimen | any |
Returns
asserts specimen is InterfaceGuard<Record<PropertyKey, MethodGuard>>
Defined in
patterns/src/patterns/patternMatchers.js:1923
assertKey
▸ assertKey(val
): void
Parameters
Name | Type |
---|---|
val | any |
Returns
void
Defined in
patterns/src/keys/checkKey.js:144
assertMethodGuard
▸ assertMethodGuard(specimen
): asserts specimen is MethodGuard
Parameters
Name | Type |
---|---|
specimen | any |
Returns
asserts specimen is MethodGuard
Defined in
patterns/src/patterns/patternMatchers.js:1856
assertPattern
▸ assertPattern(patt
): void
Parameters
Name | Type |
---|---|
patt | any |
Returns
void
Defined in
patterns/src/patterns/patternMatchers.js:1755
assertRawGuard
▸ assertRawGuard(specimen
): void
Parameters
Name | Type |
---|---|
specimen | any |
Returns
void
Defined in
patterns/src/patterns/patternMatchers.js:1811
assertScalarKey
▸ assertScalarKey(val
): void
Parameters
Name | Type |
---|---|
val | any |
Returns
void
Defined in
patterns/src/keys/checkKey.js:96
bagCompare
▸ bagCompare<K
>(left
, right
): number
CopyBag X is smaller than CopyBag Y iff all of these conditions hold (where count(A, a)
is shorthand for the count associated with a
in A
):
- For every x in X, x is also in Y and count(X, x) <= count(Y, x).
- There is a y in Y such that y is not in X or count(X, y) < count(Y, y).
X is equivalent to Y iff the condition 1 holds but condition 2 does not.
Type parameters
Name |
---|
K |
Parameters
Name | Type |
---|---|
left | CopyBag <K > |
right | CopyBag <K > |
Returns
number
Defined in
patterns/src/keys/compareKeys.js:46
bagDisjointSubtract
▸ bagDisjointSubtract(xbag
, ybag
): CopyBag
<any
>
Parameters
Name | Type |
---|---|
xbag | any |
ybag | any |
Returns
CopyBag
<any
>
Defined in
patterns/src/keys/merge-bag-operators.js:289
bagIntersection
▸ bagIntersection(xbag
, ybag
): CopyBag
<any
>
Parameters
Name | Type |
---|---|
xbag | any |
ybag | any |
Returns
CopyBag
<any
>
Defined in
patterns/src/keys/merge-bag-operators.js:288
bagIsSuperbag
▸ bagIsSuperbag(xbag
, ybag
): any
Parameters
Name | Type |
---|---|
xbag | any |
ybag | any |
Returns
any
Defined in
patterns/src/keys/merge-bag-operators.js:285
bagUnion
▸ bagUnion(xbag
, ybag
): CopyBag
<any
>
Parameters
Name | Type |
---|---|
xbag | any |
ybag | any |
Returns
CopyBag
<any
>
Defined in
patterns/src/keys/merge-bag-operators.js:287
coerceToBagEntries
▸ coerceToBagEntries(bagEntriesList
): [any
, bigint
][]
Parameters
Name | Type |
---|---|
bagEntriesList | any |
Returns
[any
, bigint
][]
Defined in
patterns/src/keys/copyBag.js:117
coerceToElements
▸ coerceToElements(elementsList
): any
[]
Parameters
Name | Type |
---|---|
elementsList | any |
Returns
any
[]
Defined in
patterns/src/keys/copySet.js:91
compareKeys
▸ compareKeys(left
, right
): number
Parameters
Name | Type |
---|---|
left | any |
right | any |
Returns
number
Defined in
patterns/src/keys/compareKeys.js:90
elementsCompare
▸ elementsCompare(xelements
, yelements
): any
Parameters
Name | Type |
---|---|
xelements | any |
yelements | any |
Returns
any
Defined in
patterns/src/keys/merge-set-operators.js:307
elementsDisjointSubtract
▸ elementsDisjointSubtract(xelements
, yelements
): any
Parameters
Name | Type |
---|---|
xelements | any |
yelements | any |
Returns
any
Defined in
patterns/src/keys/merge-set-operators.js:311
elementsDisjointUnion
▸ elementsDisjointUnion(xelements
, yelements
): any
Parameters
Name | Type |
---|---|
xelements | any |
yelements | any |
Returns
any
Defined in
patterns/src/keys/merge-set-operators.js:309
elementsIntersection
▸ elementsIntersection(xelements
, yelements
): any
Parameters
Name | Type |
---|---|
xelements | any |
yelements | any |
Returns
any
Defined in
patterns/src/keys/merge-set-operators.js:310
elementsIsDisjoint
▸ elementsIsDisjoint(xelements
, yelements
): any
Parameters
Name | Type |
---|---|
xelements | any |
yelements | any |
Returns
any
Defined in
patterns/src/keys/merge-set-operators.js:306
elementsIsSuperset
▸ elementsIsSuperset(xelements
, yelements
): any
Parameters
Name | Type |
---|---|
xelements | any |
yelements | any |
Returns
any
Defined in
patterns/src/keys/merge-set-operators.js:305
elementsUnion
▸ elementsUnion(xelements
, yelements
): any
Parameters
Name | Type |
---|---|
xelements | any |
yelements | any |
Returns
any
Defined in
patterns/src/keys/merge-set-operators.js:308
getAwaitArgGuardPayload
▸ getAwaitArgGuardPayload(awaitArgGuard
): AwaitArgGuardPayload
By using this abstraction rather than accessing the properties directly, we smooth the transition to https://github.com/endojs/endo/pull/1712, tolerating both the legacy and current guard shapes.
Note that technically, tolerating the old LegacyAwaitArgGuardShape is an exploitable bug, in that a record that matches this shape is also a valid parameter pattern that should allow an argument that matches that pattern, i.e., a copyRecord argument that at least contains a klass: 'awaitArgGuard'
property.
Parameters
Name | Type |
---|---|
awaitArgGuard | AwaitArgGuard |
Returns
Defined in
patterns/src/patterns/getGuardPayloads.js:64
getCopyBagEntries
▸ getCopyBagEntries<K
>(b
): [K
, bigint
][]
Type parameters
Name |
---|
K |
Parameters
Name | Type |
---|---|
b | CopyBag <K > |
Returns
[K
, bigint
][]
Defined in
patterns/src/keys/checkKey.js:289
getCopyMapEntries
▸ getCopyMapEntries<K
, V
>(m
): Iterable
<[K
, V
]>
Type parameters
Name | Type |
---|---|
K | extends unknown |
V | extends unknown |
Parameters
Name | Type |
---|---|
m | CopyMap <K , V > |
Returns
Iterable
<[K
, V
]>
Defined in
patterns/src/keys/checkKey.js:458
getCopySetKeys
▸ getCopySetKeys<K
>(s
): K
[]
Type parameters
Name |
---|
K |
Parameters
Name | Type |
---|---|
s | CopySet <K > |
Returns
K
[]
Defined in
patterns/src/keys/checkKey.js:205
getInterfaceGuardPayload
▸ getInterfaceGuardPayload<T
>(interfaceGuard
): InterfaceGuardPayload
<T
>
By using this abstraction rather than accessing the properties directly, we smooth the transition to https://github.com/endojs/endo/pull/1712, tolerating both the legacy and current guard shapes.
Unlike LegacyAwaitArgGuardShape, tolerating LegacyInterfaceGuardShape does not seem like a currently exploitable bug, because there is not currently any context where either an interfaceGuard or a copyRecord would both be meaningful.
Type parameters
Name | Type |
---|---|
T | extends Record <PropertyKey , MethodGuard > = Record <PropertyKey , MethodGuard > |
Parameters
Name | Type |
---|---|
interfaceGuard | InterfaceGuard <T > |
Returns
InterfaceGuardPayload
<T
>
Defined in
patterns/src/patterns/getGuardPayloads.js:241
getInterfaceMethodKeys
▸ getInterfaceMethodKeys(interfaceGuard
): (string
| symbol
)[]
Parameters
Name | Type |
---|---|
interfaceGuard | InterfaceGuard <Record <PropertyKey , MethodGuard >> |
Returns
(string
| symbol
)[]
Defined in
patterns/src/patterns/getGuardPayloads.js:270
getMethodGuardPayload
▸ getMethodGuardPayload(methodGuard
): MethodGuardPayload
By using this abstraction rather than accessing the properties directly, we smooth the transition to https://github.com/endojs/endo/pull/1712, tolerating both the legacy and current guard shapes.
Unlike LegacyAwaitArgGuardShape, tolerating LegacyMethodGuardShape does not seem like a currently exploitable bug, because there is not currently any context where either a methodGuard or a copyRecord would both be meaningful.
Parameters
Name | Type |
---|---|
methodGuard | MethodGuard |
Returns
Defined in
patterns/src/patterns/getGuardPayloads.js:148
getRankCover
▸ getRankCover(payload
, encodePassable
): RankCover
Parameters
Name | Type |
---|---|
payload | any |
encodePassable | KeyToDBKey |
Returns
Defined in
patterns/src/patterns/patternMatchers.js:1757
isAwaitArgGuard
▸ isAwaitArgGuard(specimen
): specimen is AwaitArgGuard
Parameters
Name | Type |
---|---|
specimen | any |
Returns
specimen is AwaitArgGuard
Defined in
patterns/src/patterns/patternMatchers.js:1777
isCopyBag
▸ isCopyBag(b
): b is CopyBag<any>
Parameters
Name | Type |
---|---|
b | any |
Returns
b is CopyBag<any>
Defined in
patterns/src/keys/checkKey.js:269
isCopyMap
▸ isCopyMap(m
): m is CopyMap<any, any>
Parameters
Name | Type |
---|---|
m | any |
Returns
m is CopyMap<any, any>
Defined in
patterns/src/keys/checkKey.js:396
isCopySet
▸ isCopySet(s
): s is CopySet<any>
Parameters
Name | Type |
---|---|
s | any |
Returns
s is CopySet<any>
Defined in
patterns/src/keys/checkKey.js:185
isKey
▸ isKey(val
): boolean
Parameters
Name | Type |
---|---|
val | any |
Returns
boolean
Defined in
patterns/src/keys/checkKey.js:138
isPattern
▸ isPattern(patt
): boolean
Parameters
Name | Type |
---|---|
patt | any |
Returns
boolean
Defined in
patterns/src/patterns/patternMatchers.js:1756
isRawGuard
▸ isRawGuard(specimen
): boolean
Parameters
Name | Type |
---|---|
specimen | any |
Returns
boolean
Defined in
patterns/src/patterns/patternMatchers.js:1809
keyEQ
▸ keyEQ(left
, right
): boolean
Parameters
Name | Type |
---|---|
left | any |
right | any |
Returns
boolean
Defined in
patterns/src/keys/compareKeys.js:228
keyGT
▸ keyGT(left
, right
): boolean
Parameters
Name | Type |
---|---|
left | any |
right | any |
Returns
boolean
Defined in
patterns/src/keys/compareKeys.js:234
keyGTE
▸ keyGTE(left
, right
): boolean
Parameters
Name | Type |
---|---|
left | any |
right | any |
Returns
boolean
Defined in
patterns/src/keys/compareKeys.js:231
keyLT
▸ keyLT(left
, right
): boolean
Parameters
Name | Type |
---|---|
left | any |
right | any |
Returns
boolean
Defined in
patterns/src/keys/compareKeys.js:222
keyLTE
▸ keyLTE(left
, right
): boolean
Parameters
Name | Type |
---|---|
left | any |
right | any |
Returns
boolean
Defined in
patterns/src/keys/compareKeys.js:225
kindOf
▸ kindOf(specimen
, check?
): undefined
| Kind
Parameters
Name | Type |
---|---|
specimen | any |
check? | Checker |
Returns
undefined
| Kind
Defined in
patterns/src/patterns/patternMatchers.js:1759
listDifference
▸ listDifference<V
>(leftList
, rightList
): V
[]
Return a list of all the elements present in the leftList
and not in the rightList
. Return in the order of their appearance in leftList
. Uses the comparison built into Set
membership (SameValueZero) which is like JavaScript's ===
except that it judges any NaN
to be the same as any NaN
and it judges 0
to be the same a -0
.
This is often used on lists of names that should match, in order to generate useful diagnostics about the unmatched names.
Type parameters
Name | Type |
---|---|
V | extends unknown |
Parameters
Name | Type |
---|---|
leftList | V [] |
rightList | V [] |
Returns
V
[]
Defined in
makeCopyBag
▸ makeCopyBag<K
>(bagEntryIter
): CopyBag
<K
>
Type parameters
Name |
---|
K |
Parameters
Name | Type |
---|---|
bagEntryIter | Iterable <[K , bigint ]> |
Returns
CopyBag
<K
>
Defined in
patterns/src/keys/checkKey.js:310
makeCopyBagFromElements
▸ makeCopyBagFromElements<K
>(elementIter
): CopyBag
<K
>
Type parameters
Name |
---|
K |
Parameters
Name | Type |
---|---|
elementIter | Iterable <K > |
Returns
CopyBag
<K
>
Defined in
patterns/src/keys/checkKey.js:322
makeCopyMap
▸ makeCopyMap<K
, V
>(entries
): CopyMap
<K
, V
>
Type parameters
Name | Type |
---|---|
K | extends unknown |
V | extends unknown |
Parameters
Name | Type |
---|---|
entries | Iterable <[K , V ]> |
Returns
CopyMap
<K
, V
>
Defined in
patterns/src/keys/checkKey.js:525
makeCopySet
▸ makeCopySet<K
>(elementIter
): CopySet
<K
>
Type parameters
Name |
---|
K |
Parameters
Name | Type |
---|---|
elementIter | Iterable <K > |
Returns
CopySet
<K
>
Defined in
patterns/src/keys/checkKey.js:226
matches
▸ matches(specimen
, patt
): boolean
Parameters
Name | Type |
---|---|
specimen | any |
patt | any |
Returns
boolean
Defined in
patterns/src/patterns/patternMatchers.js:1753
mustMatch
▸ mustMatch(specimen
, patt
, label?
): void
Parameters
Name | Type |
---|---|
specimen | any |
patt | any |
label? | string | number |
Returns
void
Defined in
patterns/src/patterns/patternMatchers.js:1754
objectMap
▸ objectMap<O
, R
>(original
, mapFn
): Record
<keyof O
, R
>
By analogy with how Array.prototype.map
will map the elements of an array to transformed elements of an array of the same shape, objectMap
will do likewise for the string-named own enumerable properties of an object.
Typical usage applies objectMap
to a CopyRecord, i.e., an object for which passStyleOf(original) === 'copyRecord'
. For these, none of the following edge cases arise. The result will be a CopyRecord with exactly the same property names, whose values are the mapped form of the original's values.
When the original is not a CopyRecord, some edge cases to be aware of
- No matter how mutable the original object, the returned object is hardened.
- Only the string-named enumerable own properties of the original are mapped. All other properties are ignored.
- If any of the original properties were accessors,
Object.entries
will cause itsgetter
to be called and will use the resulting value. - No matter whether the original property was an accessor, writable, or configurable, all the properties of the returned object will be non-writable, non-configurable, data properties.
- No matter what the original object may have inherited from, and no matter whether it was a special kind of object such as an array, the returned object will always be a plain object inheriting directly from
Object.prototype
and whose state is only these new mapped own properties.
With these differences, even if the original object was not a CopyRecord, if all the mapped values are Passable, then the returned object will be a CopyRecord.
Type parameters
Name | Type | Description |
---|---|---|
O | extends Record <string , any > | - |
R | R | map result |
Parameters
Name | Type |
---|---|
original | O |
mapFn | (value : O [keyof O ], key : keyof O ) => R |
Returns
Record
<keyof O
, R
>
Defined in
setCompare
▸ setCompare<K
>(left
, right
): number
CopySet X is smaller than CopySet Y iff all of these conditions hold:
- For every x in X, x is also in Y.
- There is a y in Y that is not in X.
X is equivalent to Y iff the condition 1 holds but condition 2 does not.
Type parameters
Name | Type |
---|---|
K | extends unknown |
Parameters
Name | Type |
---|---|
left | CopySet <K > |
right | CopySet <K > |
Returns
number
Defined in
patterns/src/keys/compareKeys.js:29
setDisjointSubtract
▸ setDisjointSubtract(xset
, yset
): CopySet
<any
>
Parameters
Name | Type |
---|---|
xset | any |
yset | any |
Returns
CopySet
<any
>
Defined in
patterns/src/keys/merge-set-operators.js:324
setDisjointUnion
▸ setDisjointUnion(xset
, yset
): CopySet
<any
>
Parameters
Name | Type |
---|---|
xset | any |
yset | any |
Returns
CopySet
<any
>
Defined in
patterns/src/keys/merge-set-operators.js:322
setIntersection
▸ setIntersection(xset
, yset
): CopySet
<any
>
Parameters
Name | Type |
---|---|
xset | any |
yset | any |
Returns
CopySet
<any
>
Defined in
patterns/src/keys/merge-set-operators.js:323
setIsDisjoint
▸ setIsDisjoint(xset
, yset
): any
Parameters
Name | Type |
---|---|
xset | any |
yset | any |
Returns
any
Defined in
patterns/src/keys/merge-set-operators.js:320
setIsSuperset
▸ setIsSuperset(xset
, yset
): any
Parameters
Name | Type |
---|---|
xset | any |
yset | any |
Returns
any
Defined in
patterns/src/keys/merge-set-operators.js:319
setUnion
▸ setUnion(xset
, yset
): CopySet
<any
>
Parameters
Name | Type |
---|---|
xset | any |
yset | any |
Returns
CopySet
<any
>