Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including node-compound-counter with all npm packages installed. Try it out:

var nodeCompoundCounter = require("node-compound-counter")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

node-compound-counter v0.1.0

A Node.js module to use a single 32-bit positive integer as a record of integers. Loosely inspired by C structures.

Compound Counter

A Node.js module to use a single 32-bit positive integer as a record of integers. Loosely inspired by C structures.

Installation

npm install node-compound-counter --save

Basic Usage


// module deps
var
    CompoundCounter = require('node-compound-counter');

var
    counter = CompoundCounter.forge();

// field definition
counter
    .field('lo', 255)
    .field('hi', 31);

counter.lo.set(128);
counter.hi.set(16);

console.log(counter.get()); // 4224

Advanced Usage


// module deps
var
    CompoundCounter = require('node-compound-counter');

var
    counter = CompoundCounter.forge();

// field definition
counter
    .field('single', 255);

counter.single
    .on('error', function (error) {
        // your code here
    })
    .on('change', function (value) {
        // your code here
    });

counter
    .on('error', function (error) {
        // your code here
    })
    .on('change', function (value) {
        // your code here
    });
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free