MCPcopy Create free account
hub / github.com/GoogleChrome/samples / writeChunks

Function writeChunks

mkbitmap/mkbitmap.js:3263–3279  ·  view source on GitHub ↗
(stream, buffer, offset, length, position)

Source from the content-addressed store, hash-verified

3261 };
3262 });
3263 function writeChunks(stream, buffer, offset, length, position) {
3264 var contents = stream.node.contents;
3265 if (position >= contents.length)
3266 return 0;
3267 var size = Math.min(contents.length - position, length);
3268 assert(size >= 0);
3269 if (contents.slice) { // normal array
3270 for (var i = 0; i < size; i++) {
3271 buffer[offset + i] = contents[position + i];
3272 }
3273 } else {
3274 for (var i = 0; i < size; i++) { // LazyUint8Array from sync binary XHR
3275 buffer[offset + i] = contents.get(position + i);
3276 }
3277 }
3278 return size;
3279 }
3280 // use a custom read function
3281 stream_ops.read = (stream, buffer, offset, length, position) => {
3282 FS.forceLoadFile(node);

Callers 1

mkbitmap.jsFile · 0.70

Calls 2

assertFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected