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

Function fromString

stackgl_modules/index.js:224–241  ·  view source on GitHub ↗
(string, encoding)

Source from the content-addressed store, hash-verified

222 return allocUnsafe(size);
223};
224function fromString(string, encoding) {
225 if (typeof encoding !== 'string' || encoding === '') {
226 encoding = 'utf8';
227 }
228 if (!Buffer.isEncoding(encoding)) {
229 throw new TypeError('Unknown encoding: ' + encoding);
230 }
231 var length = byteLength(string, encoding) | 0;
232 var buf = createBuffer(length);
233 var actual = buf.write(string, encoding);
234 if (actual !== length) {
235 // Writing a hex string, for example, that contains invalid characters will
236 // cause everything after the first invalid character to be ignored. (e.g.
237 // 'abxxcd' will be treated as 'ab')
238 buf = buf.slice(0, actual);
239 }
240 return buf;
241}
242function fromArrayLike(array) {
243 var length = array.length < 0 ? 0 : checked(array.length) | 0;
244 var buf = createBuffer(length);

Callers 1

fromFunction · 0.85

Calls 2

byteLengthFunction · 0.85
createBufferFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…