MCPcopy Create free account
hub / github.com/microsoft/SandDance / alloc

Function alloc

docs/app/js/sanddance-app.js:112971–112979  ·  view source on GitHub ↗
(size, fill, encoding)

Source from the content-addressed store, hash-verified

112969 else if (size < 0) throw new RangeError('The value "' + size + '" is invalid for option "size"');
112970}
112971function alloc(size, fill, encoding) {
112972 assertSize(size);
112973 if (size <= 0) return createBuffer(size);
112974 if (fill !== undefined) // Only pay attention to encoding if it's a string. This
112975 // prevents accidentally sending in a number that would
112976 // be interpreted as a start offset.
112977 return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
112978 return createBuffer(size);
112979}
112980/**
112981 * Creates a new filled Buffer instance.
112982 * alloc(size[, fill[, encoding]])

Callers 1

sanddance-app.jsFile · 0.70

Calls 2

assertSizeFunction · 0.70
createBufferFunction · 0.70

Tested by

no test coverage detected