MCPcopy Index your code
hub / github.com/SocketCluster/socketcluster / fromObject

Function fromObject

app/public/socketcluster-client.js:2904–2927  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

2902}
2903
2904function fromObject (obj) {
2905 if (Buffer.isBuffer(obj)) {
2906 var len = checked(obj.length) | 0
2907 var buf = createBuffer(len)
2908
2909 if (buf.length === 0) {
2910 return buf
2911 }
2912
2913 obj.copy(buf, 0, 0, len)
2914 return buf
2915 }
2916
2917 if (obj.length !== undefined) {
2918 if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {
2919 return createBuffer(0)
2920 }
2921 return fromArrayLike(obj)
2922 }
2923
2924 if (obj.type === 'Buffer' && Array.isArray(obj.data)) {
2925 return fromArrayLike(obj.data)
2926 }
2927}
2928
2929function checked (length) {
2930 // 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…