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

Function fromString

app/public/socketcluster-client.js:2848–2870  ·  view source on GitHub ↗
(string, encoding)

Source from the content-addressed store, hash-verified

2846}
2847
2848function fromString (string, encoding) {
2849 if (typeof encoding !== 'string' || encoding === '') {
2850 encoding = 'utf8'
2851 }
2852
2853 if (!Buffer.isEncoding(encoding)) {
2854 throw new TypeError('Unknown encoding: ' + encoding)
2855 }
2856
2857 var length = byteLength(string, encoding) | 0
2858 var buf = createBuffer(length)
2859
2860 var actual = buf.write(string, encoding)
2861
2862 if (actual !== length) {
2863 // Writing a hex string, for example, that contains invalid characters will
2864 // cause everything after the first invalid character to be ignored. (e.g.
2865 // 'abxxcd' will be treated as 'ab')
2866 buf = buf.slice(0, actual)
2867 }
2868
2869 return buf
2870}
2871
2872function fromArrayLike (array) {
2873 var length = array.length < 0 ? 0 : checked(array.length) | 0

Callers 1

fromFunction · 0.85

Calls 3

byteLengthFunction · 0.85
createBufferFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…