MCPcopy Create free account
hub / github.com/UI5/webcomponents / fromObject

Function fromObject

packages/main/test/pages/diffable-html.js:382–409  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

380 }
381
382 function fromObject (obj) {
383 if (Buffer.isBuffer(obj)) {
384 var len = checked(obj.length) | 0
385 var buf = createBuffer(len)
386
387 if (buf.length === 0) {
388 return buf
389 }
390
391 obj.copy(buf, 0, 0, len)
392 return buf
393 }
394
395 if (obj) {
396 if (ArrayBuffer.isView(obj) || 'length' in obj) {
397 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
398 return createBuffer(0)
399 }
400 return fromArrayLike(obj)
401 }
402
403 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
404 return fromArrayLike(obj.data)
405 }
406 }
407
408 throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object.')
409 }
410
411 function checked (length) {
412 // Note: cannot use `length < K_MAX_LENGTH` here because that fails when

Callers 1

fromFunction · 0.85

Calls 4

checkedFunction · 0.85
createBufferFunction · 0.85
numberIsNaNFunction · 0.85
fromArrayLikeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…