MCPcopy Create free account
hub / github.com/Effect-TS/effect / getOrCreateContainer

Function getOrCreateContainer

packages/effect/src/SchemaGetter.ts:1873–1882  ·  view source on GitHub ↗
(self: any, key: PropertyKey, shouldBeArray: boolean)

Source from the content-addressed store, hash-verified

1871 const containers = new WeakSet<object>()
1872
1873 function getOrCreateContainer(self: any, key: PropertyKey, shouldBeArray: boolean): any {
1874 const current = Object.hasOwn(self, key) ? self[key] : undefined
1875 if (containers.has(current) && Array.isArray(current) === shouldBeArray) {
1876 return current
1877 }
1878 const container = shouldBeArray ? [] : {}
1879 containers.add(container)
1880 InternalRecord.assignProperty(self, key, container)
1881 return container
1882 }
1883
1884 bracketPathEntries.forEach(([key, value]) => {
1885 const tokens = bracketPathToTokens(key)

Callers 1

makeTreeRecordFunction · 0.85

Calls 2

addMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected