Comparing version 0.1.6 to 0.1.7
@@ -1,1 +0,1 @@ | ||
{"processes":{"5533be88-6af4-4919-a434-8b62ae34ee29":{"parent":null,"children":[]}},"files":{},"externalIds":{}} | ||
{"processes":{"14af51f7-4a6c-4882-bced-b3e6c3d1c450":{"parent":null,"children":[]}},"files":{},"externalIds":{}} |
@@ -279,8 +279,18 @@ 'use strict'; | ||
const writeUint8Array = (encoder, uint8Array) => { | ||
const prevBufferLen = encoder.cbuf.length; | ||
// TODO: Append to cbuf if possible | ||
encoder.bufs.push(buffer.createUint8ArrayViewFromArrayBuffer(encoder.cbuf.buffer, 0, encoder.cpos)); | ||
encoder.bufs.push(uint8Array); | ||
encoder.cbuf = buffer.createUint8ArrayFromLen(prevBufferLen); | ||
encoder.cpos = 0; | ||
const bufferLen = encoder.cbuf.length; | ||
const cpos = encoder.cpos; | ||
const leftCopyLen = math.min(bufferLen - cpos, uint8Array.length); | ||
const rightCopyLen = uint8Array.length - leftCopyLen; | ||
encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos); | ||
encoder.cpos += leftCopyLen; | ||
if (rightCopyLen > 0) { | ||
// Still something to write, write right half.. | ||
// Append new buffer | ||
encoder.bufs.push(encoder.cbuf); | ||
// must have at least size of remaining buffer | ||
encoder.cbuf = new Uint8Array(math.max(bufferLen * 2, rightCopyLen)); | ||
// copy array | ||
encoder.cbuf.set(uint8Array.subarray(leftCopyLen)); | ||
encoder.cpos = rightCopyLen; | ||
} | ||
}; | ||
@@ -287,0 +297,0 @@ |
@@ -71,2 +71,19 @@ 'use strict'; | ||
/** | ||
* @template K | ||
* @template V | ||
* @param {Map<K,V>} m | ||
* @param {function(V,K):boolean} f | ||
* @return {boolean} | ||
*/ | ||
const all = (m, f) => { | ||
for (const [key, value] of m) { | ||
if (!f(value, key)) { | ||
return false | ||
} | ||
} | ||
return true | ||
}; | ||
exports.all = all; | ||
exports.any = any; | ||
@@ -73,0 +90,0 @@ exports.copy = copy; |
@@ -271,8 +271,18 @@ /** | ||
export const writeUint8Array = (encoder, uint8Array) => { | ||
const prevBufferLen = encoder.cbuf.length | ||
// TODO: Append to cbuf if possible | ||
encoder.bufs.push(buffer.createUint8ArrayViewFromArrayBuffer(encoder.cbuf.buffer, 0, encoder.cpos)) | ||
encoder.bufs.push(uint8Array) | ||
encoder.cbuf = buffer.createUint8ArrayFromLen(prevBufferLen) | ||
encoder.cpos = 0 | ||
const bufferLen = encoder.cbuf.length | ||
const cpos = encoder.cpos | ||
const leftCopyLen = math.min(bufferLen - cpos, uint8Array.length) | ||
const rightCopyLen = uint8Array.length - leftCopyLen | ||
encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos) | ||
encoder.cpos += leftCopyLen | ||
if (rightCopyLen > 0) { | ||
// Still something to write, write right half.. | ||
// Append new buffer | ||
encoder.bufs.push(encoder.cbuf) | ||
// must have at least size of remaining buffer | ||
encoder.cbuf = new Uint8Array(math.max(bufferLen * 2, rightCopyLen)) | ||
// copy array | ||
encoder.cbuf.set(uint8Array.subarray(leftCopyLen)) | ||
encoder.cpos = rightCopyLen | ||
} | ||
} | ||
@@ -279,0 +289,0 @@ |
16
map.js
@@ -67,1 +67,17 @@ | ||
} | ||
/** | ||
* @template K | ||
* @template V | ||
* @param {Map<K,V>} m | ||
* @param {function(V,K):boolean} f | ||
* @return {boolean} | ||
*/ | ||
export const all = (m, f) => { | ||
for (const [key, value] of m) { | ||
if (!f(value, key)) { | ||
return false | ||
} | ||
} | ||
return true | ||
} |
{ | ||
"name": "lib0", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "dependencies": {}, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
888018
12837