MCPcopy Index your code
hub / github.com/formatjs/formatjs / getMultiInternalSlots

Function getMultiInternalSlots

packages/ecma402-abstract/utils.ts:44–64  ·  view source on GitHub ↗
(
  map: WeakMap<Instance, Internal>,
  pl: Instance,
  ...fields: Field[]
)

Source from the content-addressed store, hash-verified

42}
43
44export function getMultiInternalSlots<
45 Instance extends object,
46 Internal extends object,
47 Field extends keyof Internal,
48>(
49 map: WeakMap<Instance, Internal>,
50 pl: Instance,
51 ...fields: Field[]
52): Pick<Internal, Field> {
53 const slots = map.get(pl)
54 if (!slots) {
55 throw new TypeError(`${pl} InternalSlot has not been initialized`)
56 }
57 return fields.reduce(
58 (all, f) => {
59 all[f] = slots[f]
60 return all
61 },
62 Object.create(null) as Pick<Internal, Field>
63 )
64}
65
66export interface LiteralPart {
67 type: 'literal'

Callers 4

getInternalSlotFunction · 0.85
ofMethod · 0.85
resolvedOptionsMethod · 0.85
resolvedOptionsMethod · 0.85

Calls 1

getMethod · 0.65

Tested by

no test coverage detected