MCPcopy Index your code
hub / github.com/plotly/plotly.js / from

Function from

stackgl_modules/index.js:132–161  ·  view source on GitHub ↗
(value, encodingOrOffset, length)

Source from the content-addressed store, hash-verified

130Buffer.poolSize = 8192; // not used by this implementation
131
132function from(value, encodingOrOffset, length) {
133 if (typeof value === 'string') {
134 return fromString(value, encodingOrOffset);
135 }
136 if (ArrayBuffer.isView(value)) {
137 return fromArrayView(value);
138 }
139 if (value == null) {
140 throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value));
141 }
142 if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
143 return fromArrayBuffer(value, encodingOrOffset, length);
144 }
145 if (typeof SharedArrayBuffer !== 'undefined' && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
146 return fromArrayBuffer(value, encodingOrOffset, length);
147 }
148 if (typeof value === 'number') {
149 throw new TypeError('The "value" argument must not be of type number. Received type number');
150 }
151 var valueOf = value.valueOf && value.valueOf();
152 if (valueOf != null && valueOf !== value) {
153 return Buffer.from(valueOf, encodingOrOffset, length);
154 }
155 var b = fromObject(value);
156 if (b) return b;
157 if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === 'function') {
158 return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length);
159 }
160 throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' + 'or Array-like Object. Received type ' + _typeof(value));
161}
162
163/**
164 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError

Callers 2

BufferFunction · 0.85
index.jsFile · 0.85

Calls 6

fromStringFunction · 0.85
fromArrayViewFunction · 0.85
_typeofFunction · 0.85
isInstanceFunction · 0.85
fromArrayBufferFunction · 0.85
fromObjectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…