Comparing version 1.0.0 to 1.1.0
export { IFF } from './IFF'; | ||
export { Chunk } from './Chunk'; | ||
export * from './constants'; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class l extends Blob{constructor(n,i){const{identifier:o,...r}=i;super(n,r),this.identifier=o}}const c=4,d=BigUint64Array.BYTES_PER_ELEMENT,B=c+d;class b extends Array{constructor(...n){super(...n)}blob(){const n=e=>{const s=new Uint8Array(c),a=new TextEncoder().encode(e);return s.set(a.length<=c?a:a.subarray(0,c)),s},i=e=>{const s=new ArrayBuffer(d);return new DataView(s).setBigUint64(0,BigInt(e)),new Uint8Array(s)},o=e=>[n(e.identifier),i(e.size),e],r=this.map(o).flat();return new Blob(r)}arrayBuffer(){return this.blob().arrayBuffer()}stream(){return this.blob().stream()}static async parse(n){const i=new Blob([n]),o=[];let r=0;const e=(t,u="")=>{const f=new l([i.slice(r,r+t)],{identifier:u});return r+=t,f},s=t=>new TextDecoder().decode(new Uint8Array(t,0,c)),a=t=>Number(new DataView(t,c).getBigUint64(0));for(;r<i.size;){const t=await e(B).arrayBuffer(),u=a(t),f=s(t),w=e(u,f);o.push(w)}return new b(...o)}}exports.Chunk=l;exports.IFF=b; | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=4,E=BigUint64Array.BYTES_PER_ELEMENT,l=o+E,g=127;function y(c){if(typeof c!="string")throw new Error("identifier must be string.");if(c.length!==o)throw new Error(`identifier must be ${o} bytes.`);for(let e=0;e<c.length;e++)if(c.charCodeAt(e)>g)throw new Error("identifier must be ASCII characters.")}class d extends Blob{constructor(e,i){const{identifier:s,...n}=i;super(e,n),y(s),this.identifier=s}}class b extends Array{constructor(...e){super(...e)}blob(){const e=t=>new TextEncoder().encode(t),i=t=>{const a=new ArrayBuffer(E);return new DataView(a).setBigUint64(0,BigInt(t)),new Uint8Array(a)},s=t=>[e(t.identifier),i(t.size),t],n=this.map(s).flat();return new Blob(n)}arrayBuffer(){return this.blob().arrayBuffer()}stream(){return this.blob().stream()}static async parse(e){const i=new Blob([e]),s=[];let n=0;const t=(r,u)=>{const f=new d([i.slice(n,n+r)],{identifier:u});return n+=r,f},a=r=>new TextDecoder().decode(new Uint8Array(r,0,o)),w=r=>Number(new DataView(r,o).getBigUint64(0));for(;n<i.size;){const r=await t(l,"HEAD").arrayBuffer(),u=w(r),f=a(r),h=t(u,f);s.push(h)}return new b(...s)}}exports.Chunk=d;exports.HEADER_LENGTH=l;exports.IFF=b;exports.SIZE_LENGTH=E;exports.TYPE_LENGTH=o; |
{ | ||
"name": "iff.js", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"main": "./index.js", | ||
@@ -5,0 +5,0 @@ "module": "./index.mjs", |
Sorry, the diff of this file is not supported yet
3681
7
87