1.0.12 • Published 3 years ago

compound-binary-file-js v1.0.12

Weekly downloads
307
License
ISC
Repository
github
Last release
3 years ago

This is an implementation of Compound Binary File v.3 \ Allows reading existing files, creation of the/write operation

Usage

To parse existing Compound Binary File:

const {CompoundFile} = require('compound-binary-file-js');

const reader = new FileReader(); 
reader.onload = () => { 
    const arrayBuffer = reader.result; 
    const cfb = CompoundFile.fromUint8Array(new Uint8Array(arrayBuffer));
    const rootStorage = cfb.getRootStorage();
    const subStorages = rootStorage.storages();
    const subStreams = rootStorage.streams();
    // etc.
};

reader.readAsArrayBuffer(input.files[0]);

Or alternatively you may use the following syntax if you read file as number[]:

var cfb = CompoundFile.fromUint8Array(...arrayOfBytes);

To create new Compound File:

const {CompoundFile} = require('compound-binary-file-js');

const cfb = CompoundFile.empty();
const storage1 = cfb.getRootStorage().addStorage('storage1');
const stream1 = storage1.addStream('stream1', [1,2,3,4]);
const fileBytes = cfb.asBytes();
1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago