MCPcopy Index your code
hub / github.com/OneNoteDev/WebClipper / fromObject

Function fromObject

lib/sanitize-html.js:878–906  ·  view source on GitHub ↗
(that, obj)

Source from the content-addressed store, hash-verified

876}
877
878function fromObject (that, obj) {
879 if (Buffer.isBuffer(obj)) {
880 var len = checked(obj.length) | 0
881 that = createBuffer(that, len)
882
883 if (that.length === 0) {
884 return that
885 }
886
887 obj.copy(that, 0, 0, len)
888 return that
889 }
890
891 if (obj) {
892 if ((typeof ArrayBuffer !== 'undefined' &&
893 obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
894 if (typeof obj.length !== 'number' || isnan(obj.length)) {
895 return createBuffer(that, 0)
896 }
897 return fromArrayLike(that, obj)
898 }
899
900 if (obj.type === 'Buffer' && isArray(obj.data)) {
901 return fromArrayLike(that, obj.data)
902 }
903 }
904
905 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
906}
907
908function checked (length) {
909 // Note: cannot use `length < kMaxLength()` here because that fails when

Callers 1

fromFunction · 0.85

Calls 5

checkedFunction · 0.85
createBufferFunction · 0.85
isnanFunction · 0.85
fromArrayLikeFunction · 0.85
isArrayFunction · 0.85

Tested by

no test coverage detected