REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 3.74 KB
Close
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/restructure/test/EncodeStream.js
Text
Base64
import {EncodeStream} from 'restructure'; import assert from 'assert'; describe('EncodeStream', function() { it('should write a buffer', function() { const stream = new EncodeStream(new Uint8Array(3)); stream.writeBuffer(new Uint8Array([1,2,3])); assert.deepEqual(stream.buffer, new Uint8Array([1,2,3])); }); it('should writeUInt16BE', function() { const stream = new EncodeStream(new Uint8Array(2)); stream.writeUInt16BE(0xabcd); assert.deepEqual(stream.buffer, new Uint8Array([0xab, 0xcd])); }); it('should writeUInt16LE', function() { const stream = new EncodeStream(new Uint8Array(2)); stream.writeUInt16LE(0xcdab); assert.deepEqual(stream.buffer, new Uint8Array([0xab, 0xcd])); }); it('should writeUInt24BE', function() { const stream = new EncodeStream(new Uint8Array(3)); stream.writeUInt24BE(0xabcdef); assert.deepEqual(stream.buffer, new Uint8Array([0xab, 0xcd, 0xef])); }); it('should writeUInt24LE', function() { const stream = new EncodeStream(new Uint8Array(3)); stream.writeUInt24LE(0xabcdef); assert.deepEqual(stream.buffer, new Uint8Array([0xef, 0xcd, 0xab])); }); it('should writeInt24BE', function() { const stream = new EncodeStream(new Uint8Array(6)); stream.writeInt24BE(-21724); stream.writeInt24BE(0xabcdef); assert.deepEqual(stream.buffer, new Uint8Array([0xff, 0xab, 0x24, 0xab, 0xcd, 0xef])); }); it('should writeInt24LE', function() { const stream = new EncodeStream(new Uint8Array(6)); stream.writeInt24LE(-21724); stream.writeInt24LE(0xabcdef); assert.deepEqual(stream.buffer, new Uint8Array([0x24, 0xab, 0xff, 0xef, 0xcd, 0xab])); }); it('should fill', function() { const stream = new EncodeStream(new Uint8Array(5)); stream.fill(10, 5); assert.deepEqual(stream.buffer, new Uint8Array([10, 10, 10, 10, 10])); }); describe('writeString', function() { it('should encode ascii by default', function() { const expected = Buffer.from('some text', 'ascii'); const stream = new EncodeStream(new Uint8Array(expected.length)); stream.writeString('some text'); assert.deepEqual(stream.buffer, expected); }); it('should encode ascii', function() { const expected = Buffer.from('some text', 'ascii'); const stream = new EncodeStream(new Uint8Array(expected.length)); stream.writeString('some text', 'ascii'); assert.deepEqual(stream.buffer, expected); }); it('should encode utf8', function() { const expected = Buffer.from('unicode! 👍', 'utf8'); const stream = new EncodeStream(new Uint8Array(expected.length)); stream.writeString('unicode! 👍', 'utf8'); assert.deepEqual(stream.buffer, expected); }); it('should encode utf16le', function() { const expected = Buffer.from('unicode! 👍', 'utf16le'); const stream = new EncodeStream(new Uint8Array(expected.length)); stream.writeString('unicode! 👍', 'utf16le'); assert.deepEqual(stream.buffer, expected); }); it('should encode ucs2', function() { const expected = Buffer.from('unicode! 👍', 'ucs2'); const stream = new EncodeStream(new Uint8Array(expected.length)); stream.writeString('unicode! 👍', 'ucs2'); assert.deepEqual(stream.buffer, expected); }); it('should encode utf16be', function() { const expected = Buffer.from('unicode! 👍', 'utf16le'); for (let i = 0, end = expected.length - 1; i < end; i += 2) { const byte = expected[i]; expected[i] = expected[i + 1]; expected[i + 1] = byte; } const stream = new EncodeStream(new Uint8Array(expected.length)); stream.writeString('unicode! 👍', 'utf16be'); assert.deepEqual(stream.buffer, expected); }); }); });
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 15
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
Array.js
3.97 KB
lrw-r--r--
2026-02-14 19:19:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Bitfield.js
1.04 KB
lrw-r--r--
2026-02-14 19:19:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Boolean.js
1.15 KB
lrw-r--r--
2026-02-14 19:19:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Buffer.js
1.53 KB
lrw-r--r--
2026-02-14 19:19:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
DecodeStream.js
3.53 KB
lrw-r--r--
2026-02-14 19:19:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
EncodeStream.js
3.74 KB
lrw-r--r--
2026-02-14 19:19:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Enum.js
831 B
lrw-r--r--
2026-02-14 19:19:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
LazyArray.js
1.87 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Number.js
11.03 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Optional.js
3.83 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Pointer.js
9.48 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Reserved.js
820 B
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
String.js
5.61 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Struct.js
3.45 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
VersionedStruct.js
11.37 KB
lrw-r--r--
2026-02-14 19:19:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).