diff options
author | Matthieu Saulnier <fantom@fedoraproject.org> | 2023-09-10 11:02:37 +0200 |
---|---|---|
committer | Matthieu Saulnier <fantom@fedoraproject.org> | 2023-09-10 11:02:37 +0200 |
commit | c3d25357d4a61a26609480bf84a67a56d1a17fc3 (patch) | |
tree | 4209832fa639354a1c905ca6d3ca899e889df90e /roles/reverseproxy/files/conversejs/src/shared/gif/stream.js | |
parent | 78a34e844540a6f24a42e49bcc00ce00cd6ec955 (diff) | |
download | playbooks-ansible-c3d25357d4a61a26609480bf84a67a56d1a17fc3.tar.gz playbooks-ansible-c3d25357d4a61a26609480bf84a67a56d1a17fc3.tar.xz playbooks-ansible-c3d25357d4a61a26609480bf84a67a56d1a17fc3.zip |
Add conversejs deployment
Diffstat (limited to 'roles/reverseproxy/files/conversejs/src/shared/gif/stream.js')
-rw-r--r-- | roles/reverseproxy/files/conversejs/src/shared/gif/stream.js | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/roles/reverseproxy/files/conversejs/src/shared/gif/stream.js b/roles/reverseproxy/files/conversejs/src/shared/gif/stream.js new file mode 100644 index 0000000..e9306ff --- /dev/null +++ b/roles/reverseproxy/files/conversejs/src/shared/gif/stream.js @@ -0,0 +1,43 @@ + +export default class Stream { + + constructor (data) { + if (data.toString().indexOf('ArrayBuffer') > 0) { + data = new Uint8Array(data); + } + this.data = data; + this.len = this.data.length; + this.pos = 0; + } + + readByte () { + if (this.pos >= this.data.length) { + throw new Error('Attempted to read past end of stream.'); + } + if (this.data instanceof Uint8Array) + return this.data[this.pos++]; + else + return this.data.charCodeAt(this.pos++) & 0xFF; + } + + readBytes (n) { + const bytes = []; + for (let i = 0; i < n; i++) { + bytes.push(this.readByte()); + } + return bytes; + } + + read (n) { + let s = ''; + for (let i = 0; i < n; i++) { + s += String.fromCharCode(this.readByte()); + } + return s; + } + + readUnsigned () { // Little-endian. + const a = this.readBytes(2); + return (a[1] << 8) + a[0]; + } +} |