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

Method from

helpers/compile/plugins/fill-plugin/fillers/buffer-small.ts:122–154  ·  view source on GitHub ↗
(value: unknown, encoding: any = 'utf8')

Source from the content-addressed store, hash-verified

120 }
121
122 static from(value: unknown, encoding: any = 'utf8'): BufferClass {
123 if (value && typeof value === 'object' && value['type'] === 'Buffer') {
124 return new BufferClass(value['data'])
125 }
126
127 if (typeof value === 'number') {
128 return new BufferClass(new Uint8Array(value))
129 }
130
131 if (typeof value === 'string') {
132 return stringToBuffer(value, encoding)
133 }
134
135 if (ArrayBuffer.isView(value)) {
136 const { byteOffset, byteLength, buffer } = value
137
138 if ('map' in value && typeof value.map === '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 === 'object' && ('length' in value || 'byteLength' in value || 'buffer' in value)) {
150 return new BufferClass(value as ArrayLike<number>)
151 }
152
153 throw new TypeError('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