Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bin-file

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bin-file

Binary file manipulation helper module

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

bin-file

Binary file manipulation helper. Read and write content from and to binary files.

Install

npm install bin-file

Usage

var BinFile = require('bin-file');

// write to file
var file = File.open('file.bin', 'w+', function(err, file) {
	if (err) return console.log(err);

	var struct = file.createWriteStruct(0)
		.uintLE(123, 1)
		.uint(321, 2)
		.string('Hello')
		.stringLen('Hello World!', 2)
		.write((err, written) => {
			if (err) return console.log(err);
			console.log('wrote ' + written + ' bytes');
		});
});

// read from file
var file = File.open('file.bin', 'r+', function(err, file) {
	if (err) return console.log(err);

	var struct = file.createReadStruct(0)
		.uintLE('code', 1)
		.uint('op', 2)
		.string('title', 5)
		.stringLen('content', 2)
		.read((err, res) => {
			if (err) return console.log(err);
			console.log('result:', res);
		});
});

Methods (TBA)

FAQs

Package last updated on 22 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc