MCPcopy
hub / github.com/prisma/prisma / from

Method from

helpers/compile/plugins/fill-plugin/fillers/buffer-small.ts:122–154  ·  helpers/compile/plugins/fill-plugin/fillers/buffer-small.ts::BufferClass.from
(value: unknown, encoding: any = 'utf8')

Source from the content-addressed store, hash-verified

120 }
121
122 static from(value: unknown, encoding: any = class="st">'utf8'): BufferClass {
123 if (value && typeof value === class="st">'object' && value[class="st">'type'] === class="st">'Buffer') {
124 return new BufferClass(value[class="st">'data'])
125 }
126
127 if (typeof value === class="st">'number') {
128 return new BufferClass(new Uint8Array(value))
129 }
130
131 if (typeof value === class="st">'string') {
132 return stringToBuffer(value, encoding)
133 }
134
135 if (ArrayBuffer.isView(value)) {
136 const { byteOffset, byteLength, buffer } = value
137
138 if (class="st">'map' in value && typeof value.map === class="st">'function') {
139 return new BufferClass(
140 value.map((v) => v % 256),
141 byteOffset,
142 byteLength,
143 )
144 }
145
146 return new BufferClass(buffer, byteOffset, byteLength)
147 }
148
149 if (value && typeof value === class="st">'object' && (class="st">'length' in value || class="st">'byteLength' in value || class="st">'buffer' in value)) {
150 return new BufferClass(value as ArrayLike<number>)
151 }
152
153 throw new TypeError(class="st">'First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
154 }
155
156 static concat(list: readonly Uint8Array[], totalLength?: number) {
157 if (list.length === 0) return BufferClass.alloc(0)

Callers 15

mainFunction · 0.80
getTestClientFunction · 0.80
encodeParameterFunction · 0.80
deserializeValueFunction · 0.80
serializeArgumentsValueFunction · 0.80
ownKeysFunction · 0.80
receiverFunction · 0.80

Calls 1

stringToBufferFunction · 0.85

Tested by 7

receiverFunction · 0.64
binaryStringFunction · 0.64
binaryStringFunction · 0.64
mainFunction · 0.64
loadQueryCompilerFunction · 0.64
fromBase64UrlFunction · 0.64
fromBase64UrlFunction · 0.64