REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 3.53 KB
Close
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/restructure/test/DecodeStream.js
Text
Base64
import {DecodeStream} from 'restructure'; import assert from 'assert'; describe('DecodeStream', function() { it('should read a buffer', function() { const buf = new Uint8Array([1,2,3]); const stream = new DecodeStream(buf); assert.deepEqual(stream.readBuffer(buf.length), new Uint8Array([1,2,3])); }); it('should readUInt16BE', function() { const buf = new Uint8Array([0xab, 0xcd]); const stream = new DecodeStream(buf); assert.deepEqual(stream.readUInt16BE(), 0xabcd); }); it('should readUInt16LE', function() { const buf = new Uint8Array([0xab, 0xcd]); const stream = new DecodeStream(buf); assert.deepEqual(stream.readUInt16LE(), 0xcdab); }); it('should readUInt24BE', function() { const buf = new Uint8Array([0xab, 0xcd, 0xef]); const stream = new DecodeStream(buf); assert.deepEqual(stream.readUInt24BE(), 0xabcdef); }); it('should readUInt24LE', function() { const buf = new Uint8Array([0xab, 0xcd, 0xef]); const stream = new DecodeStream(buf); assert.deepEqual(stream.readUInt24LE(), 0xefcdab); }); it('should readInt24BE', function() { const buf = new Uint8Array([0xff, 0xab, 0x24]); const stream = new DecodeStream(buf); assert.deepEqual(stream.readInt24BE(), -21724); }); it('should readInt24LE', function() { const buf = new Uint8Array([0x24, 0xab, 0xff]); const stream = new DecodeStream(buf); assert.deepEqual(stream.readInt24LE(), -21724); }); describe('readString', function() { it('should decode ascii by default', function() { const buf = Buffer.from('some text', 'ascii'); const stream = new DecodeStream(buf); assert.equal(stream.readString(buf.length), 'some text'); }); it('should decode ascii', function() { const buf = Buffer.from('some text', 'ascii'); const stream = new DecodeStream(buf); assert.equal(stream.readString(buf.length, 'ascii'), 'some text'); }); it('should decode utf8', function() { const buf = Buffer.from('unicode! 👍', 'utf8'); const stream = new DecodeStream(buf); assert.equal(stream.readString(buf.length, 'utf8'), 'unicode! 👍'); }); it('should decode utf16le', function() { const buf = Buffer.from('unicode! 👍', 'utf16le'); const stream = new DecodeStream(buf); assert.equal(stream.readString(buf.length, 'utf16le'), 'unicode! 👍'); }); it('should decode ucs2', function() { const buf = Buffer.from('unicode! 👍', 'ucs2'); const stream = new DecodeStream(buf); assert.equal(stream.readString(buf.length, 'ucs2'), 'unicode! 👍'); }); it('should decode utf16be', function() { const buf = Buffer.from('unicode! 👍', 'utf16le'); for (let i = 0, end = buf.length - 1; i < end; i += 2) { const byte = buf[i]; buf[i] = buf[i + 1]; buf[i + 1] = byte; } const stream = new DecodeStream(buf); assert.equal(stream.readString(buf.length, 'utf16be'), 'unicode! 👍'); }); it('should decode macroman', function() { const buf = new Uint8Array([0x8a, 0x63, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x64, 0x20, 0x63, 0x68, 0x87, 0x72, 0x61, 0x63, 0x74, 0x65, 0x72, 0x73]); const stream = new DecodeStream(buf); assert.equal(stream.readString(buf.length, 'mac'), 'äccented cháracters'); }); it('should return a buffer for unsupported encodings', function() { const stream = new DecodeStream(new Uint8Array([1, 2, 3])); assert.deepEqual(stream.readString(3, 'unsupported'), new Uint8Array([1, 2, 3])); }); }); });
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).