node package manager



NPM version npm Travis

An NPM for compressing arrays of objects containing many repeated values... the sort of thing you might import from a CSV.


First include the module:

var Index = require('./index-compressor');

Then to compress an array of objects:

var compressed = Index.compress(objectArray);

given an array like this:

[{"title":"Black Sun", "genre":"fiction", "author":"Edward Abbey"},
{"title":"Desert Solitaire", "genre":"nonfiction", "author":"Edward Abbey"},
{"title":"The Monkey Wrench Gang", "genre":"fiction", "author":"Edward Abbey"},
{"title":"Cosmic Banditos", "genre":"fiction", "author":"Allan Weisbecker"},
{"title":"In Search of Captain Zero", "genre":"nonfiction", "author":"Allan Weisbecker"},
{"title":"Why Can't You Get Along With Anyone?", "genre":"nonfiction", "author":"Allan Weisbecker"},
{"title":"The Cosmic Connection", "genre":"nonfiction", "author":"Carl Sagan"},
{"title":"Contact", "genre":"fiction", "author":"Carl Sagan"},
{"title":"The Unbearable Lightness of Being", "genre":"nonfiction", "author":"Milan Kundera"},
{"title":"Valis", "genre":"fiction", "author":"Philip K Dick"},
{"title":"Do Androids Dream of Electric Sheep?", "genre":"fiction", "author":"Philip K Dick"},
{"title":"Neuromancer", "genre":"fiction", "author":"William Gibson"},
{"title":"Idoru", "genre":"fiction", "author":"William Gibson"},
{"title":"Elric", "genre":"fiction", "author":"Michael Moorcock"},
{"title":"Cerebus", "genre":"fiction", "author":"Dave Sim"},
{"title":"Go Rin No Sho", "genre":"nonfiction", "author":"Miyamato Musashi"},
{"title":"Brave New World", "genre":"fiction", "author":"Aldous Huxley"}]

You get out an object like this:

        "Black Sun","fiction","Edward Abbey","Desert Solitaire","nonfiction",
        "The Monkey Wrench Gang","Cosmic Banditos","Allan Weisbecker",
        "In Search of Captain Zero","Why Can't You Get Along With Anyone?",
        "The Cosmic Connection","Carl Sagan","Contact","The Unbearable Lightness of Being",
        "Milan Kundera","Valis","Philip K Dick","Do Androids Dream of Electric Sheep?",
        "Neuromancer","William Gibson","Idoru","Elric","Michael Moorcock","Cerebus",
        "Dave Sim","Go Rin No Sho","Miyamato Musashi","Brave New World","Aldous Huxley"

Then to go back in the other direction:

var inflatedArray = Index.inflate(compressed);


Run the tests at the project root with:



-Abbey Hawk Sparrow