Node.js module for reading and creating Aggregion binary bundles
Installation
npm install git+ssh://git@stash.aggregion.com:7999/bck/node-bundle-module.git --save
Usage
const AggregionBundle = require('agg-bundle');
let bundle = new AggregionBundle({path: '/path/to/bundle'});
bundle
.getFiles()
.then((fileNames) => {
console.log(fileNames);
});
bundle
.getBundleInfoData()
.then((data) => {
console.log('info', data);
});
bundle
.getBundlePropertiesData()
.then((data) => {
console.log('properties', data);
});
bundle
.setBundleInfoData('some info string')
.then(() => {
return bundle.setBundleInfoData(new Buffer('or you can use buffer'));
})
.then(() => {
console.log('done');
});
bundle
.setBundlePropertiesData('some info string')
.then(() => {
return bundle.setBundlePropertiesData(new Buffer('or you can use buffer'));
})
.then(() => {
console.log('done');
});
bundle
.createFile('path/to/file/to/create.dat')
.then((fd) => {
console.log(`created file with descriptor: ${fd}`);
});
bundle
.openFile('path/to/existing/file.dat')
.then((fd) => {
console.log(`opened file with descriptor: ${fd}`);
});
bundle
.readFileBlock(bundle.openFile('path/to/existing/file.dat'), 1024 * 1024)
.then((data) => {
console.log(`Read block with size: ${data.length}`);
});
bundle
.readFilePropertiesData(bundle.openFile('path/to/existing/file.dat'))
.then((propsData) => {
console.log(propsData);
});
let fd = bundle.openFile('path/to/existing/file.dat');
bundle.seekFile(
fd,
1000
);
bundle
.createFile('path/to/file/to/create.dat')
.then((fd) => {
return bundle.writeFileBlock(fd, new Buffer(1000))
})
.then(() => {
console.log('Block written');
});
bundle
.writeFilePropertiesData(bundle.openFile('path/to/existing/file.dat'), 'some props')
.then(() => {
console.log('Properties written');
});
console.log(`Size of file: ${bundle.getFileSize('path/to/existing/file.dat')}`);
bundle.deleteFile('path/to/existing/file.dat');
Run tests
npm test