MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / fromObject

Function fromObject

lib/models/dav.js:2147–2175  ·  view source on GitHub ↗
(that, obj)

Source from the content-addressed store, hash-verified

2145}
2146
2147function fromObject (that, obj) {
2148 if (internalIsBuffer(obj)) {
2149 var len = checked(obj.length) | 0;
2150 that = createBuffer(that, len);
2151
2152 if (that.length === 0) {
2153 return that
2154 }
2155
2156 obj.copy(that, 0, 0, len);
2157 return that
2158 }
2159
2160 if (obj) {
2161 if ((typeof ArrayBuffer !== 'undefined' &&
2162 obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
2163 if (typeof obj.length !== 'number' || isnan(obj.length)) {
2164 return createBuffer(that, 0)
2165 }
2166 return fromArrayLike(that, obj)
2167 }
2168
2169 if (obj.type === 'Buffer' && isArray$1(obj.data)) {
2170 return fromArrayLike(that, obj.data)
2171 }
2172 }
2173
2174 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
2175}
2176
2177function checked (length) {
2178 // Note: cannot use `length < kMaxLength()` here because that fails when

Callers 1

fromFunction · 0.85

Calls 5

internalIsBufferFunction · 0.85
checkedFunction · 0.85
createBufferFunction · 0.85
isnanFunction · 0.85
fromArrayLikeFunction · 0.85

Tested by

no test coverage detected