MCPcopy Index your code
hub / github.com/TruthHun/BookStack / fromObject

Function fromObject

static/word2md/mammoth.browser.js:9974–10002  ·  view source on GitHub ↗
(that, obj)

Source from the content-addressed store, hash-verified

9972}
9973
9974function fromObject (that, obj) {
9975 if (Buffer.isBuffer(obj)) {
9976 var len = checked(obj.length) | 0
9977 that = createBuffer(that, len)
9978
9979 if (that.length === 0) {
9980 return that
9981 }
9982
9983 obj.copy(that, 0, 0, len)
9984 return that
9985 }
9986
9987 if (obj) {
9988 if ((typeof ArrayBuffer !== 'undefined' &&
9989 obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
9990 if (typeof obj.length !== 'number' || isnan(obj.length)) {
9991 return createBuffer(that, 0)
9992 }
9993 return fromArrayLike(that, obj)
9994 }
9995
9996 if (obj.type === 'Buffer' && isArray(obj.data)) {
9997 return fromArrayLike(that, obj.data)
9998 }
9999 }
10000
10001 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
10002}
10003
10004function checked (length) {
10005 // Note: cannot use `length < kMaxLength()` here because that fails when

Callers 1

fromFunction · 0.70

Calls 5

checkedFunction · 0.70
createBufferFunction · 0.70
isnanFunction · 0.70
fromArrayLikeFunction · 0.70
isArrayFunction · 0.70

Tested by

no test coverage detected