~cadence/PE-DIA

8fc97b95bbd3752433f81c2c8b76318be73d47c1 — Cadence Ember 1 year, 8 months ago 1e7b6a8
Support integers larger than 255
1 files changed, 8 insertions(+), 1 deletions(-)

M processor.js
M processor.js => processor.js +8 -1
@@ 54,7 54,14 @@ class MSStream {
	}

	writeInt(int) {
		const array = new Uint8Array([int, 0, 0, 0])
		const uint8length = 8
		const uint8capacity = (1 << uint8length) - 1
		const array = new Uint8Array(4).map((_, i) => {
			// output byte based on position. it's little-endian, so produce the least significant byte first.
			const scale = uint8length * i
			const mask = uint8capacity << scale // mask higher bits further in the array
			return (mask & int) >> scale
		})
		this.stream.write(array)
	}