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

Function fromString

lib/sanitize-html.js:815–837  ·  view source on GitHub ↗
(that, string, encoding)

Source from the content-addressed store, hash-verified

813}
814
815function fromString (that, string, encoding) {
816 if (typeof encoding !== 'string' || encoding === '') {
817 encoding = 'utf8'
818 }
819
820 if (!Buffer.isEncoding(encoding)) {
821 throw new TypeError('"encoding" must be a valid string encoding')
822 }
823
824 var length = byteLength(string, encoding) | 0
825 that = createBuffer(that, length)
826
827 var actual = that.write(string, encoding)
828
829 if (actual !== length) {
830 // Writing a hex string, for example, that contains invalid characters will
831 // cause everything after the first invalid character to be ignored. (e.g.
832 // 'abxxcd' will be treated as 'ab')
833 that = that.slice(0, actual)
834 }
835
836 return that
837}
838
839function fromArrayLike (that, array) {
840 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