Skip to content

Endo API documentation - v0.2.0 / Exports / @endo/patterns

Module: @endo/patterns

Table of contents

Interfaces

Type Aliases

Variables

Functions

Type Aliases

ArgGuard

Ƭ ArgGuard: AwaitArgGuard | RawGuard | Pattern

Defined in

patterns/src/types.js:624


AwaitArgGuard

Ƭ AwaitArgGuard: CopyTagged<"guard:awaitArgGuard", AwaitArgGuardPayload>

Defined in

patterns/src/types.js:611


AwaitArgGuardPayload

Ƭ AwaitArgGuardPayload: Object

Type declaration

NameType
argGuardPattern

Defined in

patterns/src/types.js:607


CheckPattern

Ƭ CheckPattern: (allegedPattern: Passable, check: Checker) => boolean

Type declaration

▸ (allegedPattern, check): boolean

Parameters
NameType
allegedPatternPassable
checkChecker
Returns

boolean

Defined in

patterns/src/types.js:213


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 or false and rarely throws.
  • A validator throws an informative diagnostic when the predicate would have returned false, and simply returns undefined normally when the predicate would have returned true.
  • 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 in assertChecker which is a trivial wrapper around assert.

See the various uses for good examples.

Type declaration

▸ (cond, details?): boolean

Parameters
NameType
condboolean
details?ses
Returns

boolean

Defined in

pass-style/src/types.js:143


CopyArray

Ƭ CopyArray<T>: T[]

A Passable sequence of Passable values.

Type parameters

NameType
Textends Passable = Passable

Defined in

pass-style/src/types.js:91


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

NameType
Kextends Key = Key

Defined in

patterns/src/types.js:122


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

NameType
Kextends Key = Key
Vextends Passable = Passable

Defined in

patterns/src/types.js:132


CopyRecord

Ƭ CopyRecord<T>: Record<string, T>

A Passable dictionary in which each key is a string and each value is Passable.

Type parameters

NameType
Textends Passable = Passable

Defined in

pass-style/src/types.js:98


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

NameType
Kextends Key = Key

Defined in

patterns/src/types.js:114


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

NameType
Tagextends string = string
Payloadextends Passable = Passable

Index signature

▪ [passStyle: symbol]: "tagged" | string

Type declaration

NameType
[toStringTag]Tag
payloadPayload

Defined in

pass-style/src/types.js:110


DefaultGuardType

Ƭ DefaultGuardType: undefined | "passable" | "raw"

Defined in

patterns/src/types.js:466


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

patterns/src/types.js:155


GetRankCover

Ƭ GetRankCover: (payload: Passable, encodePassable: KeyToDBKey) => RankCover

Type declaration

▸ (payload, encodePassable): RankCover

Parameters
NameType
payloadPassable
encodePassableKeyToDBKey
Returns

RankCover

Defined in

patterns/src/types.js:51


InterfaceGuard

Ƭ InterfaceGuard<T>: CopyTagged<"guard:interfaceGuard", InterfaceGuardPayload<T>>

Type parameters

NameType
Textends Record<PropertyKey, MethodGuard> = Record<PropertyKey, MethodGuard>

Defined in

patterns/src/types.js:549


InterfaceGuardPayload

Ƭ InterfaceGuardPayload<T>: Object

Type parameters

NameType
Textends Record<PropertyKey, MethodGuard> = Record<PropertyKey, MethodGuard>

Type declaration

NameType
defaultGuards?DefaultGuardType
interfaceNamestring
methodGuardsOmit<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

patterns/src/types.js:544


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

patterns/src/types.js:25


KeyCollection

Ƭ KeyCollection: CopySet | CopyBag | CopyMap

CopySet, CopyBag, and CopyMap all store Keys in reverse rankOrder, which supports generalized utilities.

Defined in

patterns/src/types.js:140


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
NameType
leftKey
rightKey
Returns

KeyComparison

Defined in

patterns/src/types.js:189


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

patterns/src/types.js:183


KeyToDBKey

Ƭ KeyToDBKey: (key: Key) => string

Type declaration

▸ (key): string

Parameters
NameType
keyKey
Returns

string

Defined in

patterns/src/types.js:58


Limits

Ƭ Limits: Partial<AllLimits>

Defined in

patterns/src/types.js:233


MakeInterfaceGuard

Ƭ MakeInterfaceGuard: MakeInterfaceGuardStrict & MakeInterfaceGuardSloppy & MakeInterfaceGuardGeneral

Defined in

patterns/src/types.js:490


MakeInterfaceGuardGeneral

Ƭ MakeInterfaceGuardGeneral: <M>(interfaceName: string, methodGuards: M, options?: { defaultGuards?: DefaultGuardType ; sloppy?: boolean }) => InterfaceGuard<M>

Type declaration

▸ <M>(interfaceName, methodGuards, options?): InterfaceGuard<M>

Type parameters
NameType
Mextends Record<PropertyKey, MethodGuard>
Parameters
NameType
interfaceNamestring
methodGuardsM
options?Object
options.defaultGuards?DefaultGuardType
options.sloppy?boolean
Returns

InterfaceGuard<M>

Defined in

patterns/src/types.js:488


MakeInterfaceGuardSloppy

Ƭ MakeInterfaceGuardSloppy: (interfaceName: string, methodGuards: any, options: { defaultGuards?: "passable" | "raw" ; sloppy?: true }) => InterfaceGuard<any>

Type declaration

▸ (interfaceName, methodGuards, options): InterfaceGuard<any>

Parameters
NameType
interfaceNamestring
methodGuardsany
optionsObject
options.defaultGuards?"passable" | "raw"
options.sloppy?true
Returns

InterfaceGuard<any>

Defined in

patterns/src/types.js:481


MakeInterfaceGuardStrict

Ƭ MakeInterfaceGuardStrict: <M>(interfaceName: string, methodGuards: M, options: { defaultGuards?: undefined ; sloppy?: false }) => InterfaceGuard<M>

Type declaration

▸ <M>(interfaceName, methodGuards, options): InterfaceGuard<M>

Type parameters
NameType
Mextends Record<PropertyKey, MethodGuard>
Parameters
NameType
interfaceNamestring
methodGuardsM
optionsObject
options.defaultGuards?undefined
options.sloppy?false
Returns

InterfaceGuard<M>

Defined in

patterns/src/types.js:474


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

patterns/src/types.js:148


MatcherNamespace

Ƭ MatcherNamespace: PatternMatchers & GuardMakers

Defined in

patterns/src/types.js:529


Method

Ƭ Method: (...args: any[]) => any

Type declaration

▸ (...args): any

Parameters
NameType
...argsany[]
Returns

any

Defined in

patterns/src/types.js:532


MethodGuard

Ƭ MethodGuard: CopyTagged<"guard:methodGuard", MethodGuardPayload>

Defined in

patterns/src/types.js:601


MethodGuardMaker

Ƭ MethodGuardMaker: MethodGuardOptional & MethodGuardRestReturns

A method name and parameter/return signature like:

js
  foo(a, b, c = d, ...e) => f

should be guarded by something like:

js
{
  ...otherMethodGuards,
  foo: M.call(AShape, BShape).optional(CShape).rest(EShape).returns(FShape),
}

/**

Defined in

patterns/src/types.js:553


MethodGuardPayload

Ƭ MethodGuardPayload: Object

Type declaration

NameType
argGuardsArgGuard[]
callKind"sync" | "async"
optionalArgGuards?ArgGuard[]
restArgGuard?SyncValueGuard
returnGuardSyncValueGuard

Defined in

patterns/src/types.js:597


MethodGuardRestReturns

Ƭ MethodGuardRestReturns: MethodGuardRest & MethodGuardReturns

Mandatory and optional arguments have been specified, now specify rest, or finish with returns.

Defined in

patterns/src/types.js:579


PassStyle

Ƭ PassStyle: PrimitiveStyle | "copyRecord" | "copyArray" | "tagged" | "remotable" | "error" | "promise"

Defined in

pass-style/src/types.js:14


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

pass-style/src/types.js:21


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

patterns/src/types.js:64


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
NameTypeDescription
leftanya Passable
rightanya Passable
Returns

RankComparison

Defined in

marshal/src/types.js:151


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

marshal/src/types.js:137


RawGuard

Ƭ RawGuard: CopyTagged<"guard:rawGuard", RawGuardPayload>

Defined in

patterns/src/types.js:619


RawGuardPayload

Ƭ RawGuardPayload: Object

Defined in

patterns/src/types.js:615


SyncValueGuard

Ƭ SyncValueGuard: RawGuard | Pattern

Defined in

patterns/src/types.js:622

Variables

M

M: MatcherNamespace

Defined in

patterns/src/patterns/patternMatchers.js:1758

Functions

assertAwaitArgGuard

assertAwaitArgGuard(specimen): asserts specimen is AwaitArgGuard

Parameters

NameType
specimenany

Returns

asserts specimen is AwaitArgGuard

Defined in

patterns/src/patterns/patternMatchers.js:1785


assertCopyBag

assertCopyBag(b): asserts b is CopyBag<any>

Parameters

NameType
bany

Returns

asserts b is CopyBag<any>

Defined in

patterns/src/keys/checkKey.js:279


assertCopyMap

assertCopyMap(m): asserts m is CopyMap<any, any>

Parameters

NameType
many

Returns

asserts m is CopyMap<any, any>

Defined in

patterns/src/keys/checkKey.js:406


assertCopySet

assertCopySet(s): asserts s is CopySet<any>

Parameters

NameType
sany

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

NameType
specimenany

Returns

asserts specimen is InterfaceGuard<Record<PropertyKey, MethodGuard>>

Defined in

patterns/src/patterns/patternMatchers.js:1923


assertKey

assertKey(val): void

Parameters

NameType
valany

Returns

void

Defined in

patterns/src/keys/checkKey.js:144


assertMethodGuard

assertMethodGuard(specimen): asserts specimen is MethodGuard

Parameters

NameType
specimenany

Returns

asserts specimen is MethodGuard

Defined in

patterns/src/patterns/patternMatchers.js:1856


assertPattern

assertPattern(patt): void

Parameters

NameType
pattany

Returns

void

Defined in

patterns/src/patterns/patternMatchers.js:1755


assertRawGuard

assertRawGuard(specimen): void

Parameters

NameType
specimenany

Returns

void

Defined in

patterns/src/patterns/patternMatchers.js:1811


assertScalarKey

assertScalarKey(val): void

Parameters

NameType
valany

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):

  1. For every x in X, x is also in Y and count(X, x) <= count(Y, x).
  2. 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

NameType
leftCopyBag<K>
rightCopyBag<K>

Returns

number

Defined in

patterns/src/keys/compareKeys.js:46


bagDisjointSubtract

bagDisjointSubtract(xbag, ybag): CopyBag<any>

Parameters

NameType
xbagany
ybagany

Returns

CopyBag<any>

Defined in

patterns/src/keys/merge-bag-operators.js:289


bagIntersection

bagIntersection(xbag, ybag): CopyBag<any>

Parameters

NameType
xbagany
ybagany

Returns

CopyBag<any>

Defined in

patterns/src/keys/merge-bag-operators.js:288


bagIsSuperbag

bagIsSuperbag(xbag, ybag): any

Parameters

NameType
xbagany
ybagany

Returns

any

Defined in

patterns/src/keys/merge-bag-operators.js:285


bagUnion

bagUnion(xbag, ybag): CopyBag<any>

Parameters

NameType
xbagany
ybagany

Returns

CopyBag<any>

Defined in

patterns/src/keys/merge-bag-operators.js:287


coerceToBagEntries

coerceToBagEntries(bagEntriesList): [any, bigint][]

Parameters

NameType
bagEntriesListany

Returns

[any, bigint][]

Defined in

patterns/src/keys/copyBag.js:117


coerceToElements

coerceToElements(elementsList): any[]

Parameters

NameType
elementsListany

Returns

any[]

Defined in

patterns/src/keys/copySet.js:91


compareKeys

compareKeys(left, right): number

Parameters

NameType
leftany
rightany

Returns

number

Defined in

patterns/src/keys/compareKeys.js:90


elementsCompare

elementsCompare(xelements, yelements): any

Parameters

NameType
xelementsany
yelementsany

Returns

any

Defined in

patterns/src/keys/merge-set-operators.js:307


elementsDisjointSubtract

elementsDisjointSubtract(xelements, yelements): any

Parameters

NameType
xelementsany
yelementsany

Returns

any

Defined in

patterns/src/keys/merge-set-operators.js:311


elementsDisjointUnion

elementsDisjointUnion(xelements, yelements): any

Parameters

NameType
xelementsany
yelementsany

Returns

any

Defined in

patterns/src/keys/merge-set-operators.js:309


elementsIntersection

elementsIntersection(xelements, yelements): any

Parameters

NameType
xelementsany
yelementsany

Returns

any

Defined in

patterns/src/keys/merge-set-operators.js:310


elementsIsDisjoint

elementsIsDisjoint(xelements, yelements): any

Parameters

NameType
xelementsany
yelementsany

Returns

any

Defined in

patterns/src/keys/merge-set-operators.js:306


elementsIsSuperset

elementsIsSuperset(xelements, yelements): any

Parameters

NameType
xelementsany
yelementsany

Returns

any

Defined in

patterns/src/keys/merge-set-operators.js:305


elementsUnion

elementsUnion(xelements, yelements): any

Parameters

NameType
xelementsany
yelementsany

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

NameType
awaitArgGuardAwaitArgGuard

Returns

AwaitArgGuardPayload

Defined in

patterns/src/patterns/getGuardPayloads.js:64


getCopyBagEntries

getCopyBagEntries<K>(b): [K, bigint][]

Type parameters

Name
K

Parameters

NameType
bCopyBag<K>

Returns

[K, bigint][]

Defined in

patterns/src/keys/checkKey.js:289


getCopyMapEntries

getCopyMapEntries<K, V>(m): Iterable<[K, V]>

Type parameters

NameType
Kextends unknown
Vextends unknown

Parameters

NameType
mCopyMap<K, V>

Returns

Iterable<[K, V]>

Defined in

patterns/src/keys/checkKey.js:458


getCopySetKeys

getCopySetKeys<K>(s): K[]

Type parameters

Name
K

Parameters

NameType
sCopySet<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

NameType
Textends Record<PropertyKey, MethodGuard> = Record<PropertyKey, MethodGuard>

Parameters

NameType
interfaceGuardInterfaceGuard<T>

Returns

InterfaceGuardPayload<T>

Defined in

patterns/src/patterns/getGuardPayloads.js:241


getInterfaceMethodKeys

getInterfaceMethodKeys(interfaceGuard): (string | symbol)[]

Parameters

NameType
interfaceGuardInterfaceGuard<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

NameType
methodGuardMethodGuard

Returns

MethodGuardPayload

Defined in

patterns/src/patterns/getGuardPayloads.js:148


getRankCover

getRankCover(payload, encodePassable): RankCover

Parameters

NameType
payloadany
encodePassableKeyToDBKey

Returns

RankCover

Defined in

patterns/src/patterns/patternMatchers.js:1757


isAwaitArgGuard

isAwaitArgGuard(specimen): specimen is AwaitArgGuard

Parameters

NameType
specimenany

Returns

specimen is AwaitArgGuard

Defined in

patterns/src/patterns/patternMatchers.js:1777


isCopyBag

isCopyBag(b): b is CopyBag<any>

Parameters

NameType
bany

Returns

b is CopyBag<any>

Defined in

patterns/src/keys/checkKey.js:269


isCopyMap

isCopyMap(m): m is CopyMap<any, any>

Parameters

NameType
many

Returns

m is CopyMap<any, any>

Defined in

patterns/src/keys/checkKey.js:396


isCopySet

isCopySet(s): s is CopySet<any>

Parameters

NameType
sany

Returns

s is CopySet<any>

Defined in

patterns/src/keys/checkKey.js:185


isKey

isKey(val): boolean

Parameters

NameType
valany

Returns

boolean

Defined in

patterns/src/keys/checkKey.js:138


isPattern

isPattern(patt): boolean

Parameters

NameType
pattany

Returns

boolean

Defined in

patterns/src/patterns/patternMatchers.js:1756


isRawGuard

isRawGuard(specimen): boolean

Parameters

NameType
specimenany

Returns

boolean

Defined in

patterns/src/patterns/patternMatchers.js:1809


keyEQ

keyEQ(left, right): boolean

Parameters

NameType
leftany
rightany

Returns

boolean

Defined in

patterns/src/keys/compareKeys.js:228


keyGT

keyGT(left, right): boolean

Parameters

NameType
leftany
rightany

Returns

boolean

Defined in

patterns/src/keys/compareKeys.js:234


keyGTE

keyGTE(left, right): boolean

Parameters

NameType
leftany
rightany

Returns

boolean

Defined in

patterns/src/keys/compareKeys.js:231


keyLT

keyLT(left, right): boolean

Parameters

NameType
leftany
rightany

Returns

boolean

Defined in

patterns/src/keys/compareKeys.js:222


keyLTE

keyLTE(left, right): boolean

Parameters

NameType
leftany
rightany

Returns

boolean

Defined in

patterns/src/keys/compareKeys.js:225


kindOf

kindOf(specimen, check?): undefined | Kind

Parameters

NameType
specimenany
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

NameType
Vextends unknown

Parameters

NameType
leftListV[]
rightListV[]

Returns

V[]

Defined in

common/list-difference.js:15


makeCopyBag

makeCopyBag<K>(bagEntryIter): CopyBag<K>

Type parameters

Name
K

Parameters

NameType
bagEntryIterIterable<[K, bigint]>

Returns

CopyBag<K>

Defined in

patterns/src/keys/checkKey.js:310


makeCopyBagFromElements

makeCopyBagFromElements<K>(elementIter): CopyBag<K>

Type parameters

Name
K

Parameters

NameType
elementIterIterable<K>

Returns

CopyBag<K>

Defined in

patterns/src/keys/checkKey.js:322


makeCopyMap

makeCopyMap<K, V>(entries): CopyMap<K, V>

Type parameters

NameType
Kextends unknown
Vextends unknown

Parameters

NameType
entriesIterable<[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

NameType
elementIterIterable<K>

Returns

CopySet<K>

Defined in

patterns/src/keys/checkKey.js:226


matches

matches(specimen, patt): boolean

Parameters

NameType
specimenany
pattany

Returns

boolean

Defined in

patterns/src/patterns/patternMatchers.js:1753


mustMatch

mustMatch(specimen, patt, label?): void

Parameters

NameType
specimenany
pattany
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 its getter 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

NameTypeDescription
Oextends Record<string, any>-
RRmap result

Parameters

NameType
originalO
mapFn(value: O[keyof O], key: keyof O) => R

Returns

Record<keyof O, R>

Defined in

common/object-map.js:42


setCompare

setCompare<K>(left, right): number

CopySet X is smaller than CopySet Y iff all of these conditions hold:

  1. For every x in X, x is also in Y.
  2. 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

NameType
Kextends unknown

Parameters

NameType
leftCopySet<K>
rightCopySet<K>

Returns

number

Defined in

patterns/src/keys/compareKeys.js:29


setDisjointSubtract

setDisjointSubtract(xset, yset): CopySet<any>

Parameters

NameType
xsetany
ysetany

Returns

CopySet<any>

Defined in

patterns/src/keys/merge-set-operators.js:324


setDisjointUnion

setDisjointUnion(xset, yset): CopySet<any>

Parameters

NameType
xsetany
ysetany

Returns

CopySet<any>

Defined in

patterns/src/keys/merge-set-operators.js:322


setIntersection

setIntersection(xset, yset): CopySet<any>

Parameters

NameType
xsetany
ysetany

Returns

CopySet<any>

Defined in

patterns/src/keys/merge-set-operators.js:323


setIsDisjoint

setIsDisjoint(xset, yset): any

Parameters

NameType
xsetany
ysetany

Returns

any

Defined in

patterns/src/keys/merge-set-operators.js:320


setIsSuperset

setIsSuperset(xset, yset): any

Parameters

NameType
xsetany
ysetany

Returns

any

Defined in

patterns/src/keys/merge-set-operators.js:319


setUnion

setUnion(xset, yset): CopySet<any>

Parameters

NameType
xsetany
ysetany

Returns

CopySet<any>

Defined in

patterns/src/keys/merge-set-operators.js:321