MCPcopy Create free account
hub / github.com/UI5/webcomponents / fromString

Function fromString

packages/main/test/pages/diffable-html.js:326–348  ·  view source on GitHub ↗
(string, encoding)

Source from the content-addressed store, hash-verified

324 }
325
326 function fromString (string, encoding) {
327 if (typeof encoding !== 'string' || encoding === '') {
328 encoding = 'utf8'
329 }
330
331 if (!Buffer.isEncoding(encoding)) {
332 throw new TypeError('Unknown encoding: ' + encoding)
333 }
334
335 var length = byteLength(string, encoding) | 0
336 var buf = createBuffer(length)
337
338 var actual = buf.write(string, encoding)
339
340 if (actual !== length) {
341 // Writing a hex string, for example, that contains invalid characters will
342 // cause everything after the first invalid character to be ignored. (e.g.
343 // 'abxxcd' will be treated as 'ab')
344 buf = buf.slice(0, actual)
345 }
346
347 return buf
348 }
349
350 function fromArrayLike (array) {
351 var length = array.length < 0 ? 0 : checked(array.length) | 0

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…