Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
concentrate
Advanced tools
Readme
Produce binary data with a neat DSL.
Concentrate allows you to efficiently create buffers by chaining together calls to write numbers, strings and even other buffers! Concentrate is also easily extendable so you can implement your own custom types.
If you want to parse binary data, might I suggest dissolve?
Available via npm:
$ npm install concentrate
Or via git:
$ git clone git://github.com/deoxxa/concentrate.git node_modules/concentrate
Also see example.js and example-complex.js.
#!/usr/bin/env node
var Concentrate = require("./index");
var data = Concentrate().uint8(1).uint8(2).uint32be(555).string("hi there", "utf8").result();
console.log(data);
<Buffer 01 02 00 00 02 2b 68 69 20 74 68 65 72 65 40 06 66 66 40 00 cc cc cc cc cc cd>
Oh look! Streams! Also see example-stream.js.
#!/usr/bin/env node
var Concentrate = require("./index");
var c = Concentrate();
c.on("end", function() {
console.log("ended");
});
c.on("readable", function() {
var e;
while (e = c.read()) {
console.log(e);
}
});
c.uint8(1).uint8(2).uint32be(555).string("hi there", "utf8").floatbe(2.1).doublebe(2.1).flush();
c.uint8(5).uint8(6);
c.uint8(7);
c.uint8(30);
c.flush().end();
<Buffer 01 02 00 00 02 2b 68 69 20 74 68 65 72 65 40 06 66 66 40 00 cc cc cc cc cc cd>
<Buffer 05 06 07 1e>
ended
All methods aside from result
are chainable and all except copy
return the
same Concentrate instance they were called on.
copy()
- returns a new copy of the current Concentrate instance, copying the
state of the current job listreset()
- resets the job listresult()
- compiles the job list into a buffer and returns that bufferflush()
- compiles the current job list, emits it via the stream API, then
clears the current job listend()
- ends the stream part of Concentrate (basically makes it emit "end")buffer(data)
string(data, encoding)
- write a string with the given encodingint8(data)
- signed 8 bit integersint8(data)
- signed 8 bit integeruint8(data)
- unsigned 8 bit integerint16(data)
- signed, little endian 16 bit integerint16le(data)
- signed, little endian 16 bit integerint16be(data)
- signed, big endian 16 bit integersint16(data)
- signed, little endian 16 bit integersint16le(data)
- signed, little endian 16 bit integersint16be(data)
- signed, big endian 16 bit integeruint16(data)
- unsigned, little endian 16 bit integeruint16le(data)
- unsigned, little endian 16 bit integeruint16be(data)
- unsigned, big endian 16 bit integerint32(data)
- signed, little endian 32 bit integerint32le(data)
- signed, little endian 32 bit integerint32be(data)
- signed, big endian 32 bit integersint32(data)
- signed, little endian 32 bit integersint32le(data)
- signed, little endian 32 bit integersint32be(data)
- signed, big endian 32 bit integeruint32(data)
- unsigned, little endian 32 bit integeruint32le(data)
- unsigned, little endian 32 bit integeruint32be(data)
- unsigned, big endian 32 bit integerfloatbe(data)
- big endian 32 bit floatfloatle(data)
- little endian 32 bit floatdoublebe(data)
- big endian 64 bit doubledoublele(data)
- little endian 64 bit double3-clause BSD. A copy is included with the source.
FAQs
Produce binary data with a neat DSL
The npm package concentrate receives a total of 159 weekly downloads. As such, concentrate popularity was classified as not popular.
We found that concentrate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.