1.0.1 • Published 9 years ago
pretty-immutable v1.0.1
pretty-immutable
Pretty printing for ImmutableJS
Heavily inspired by (and dependent on) json-stringify-pretty-compact.
Install
npm install pretty-immutableThis library will only work (or really make any sense) if you also have immutable installed.
Usage
var Immutable = require("immutable");
var prettyI = require("pretty-immutable");
var bigMap = Immutable.fromJS({
  a: [1, 2, 3, 4],
  b: {
    blah: {
      blah: [
        {a: 1},
        {b: 2},
        {c: 3}
      ]
    }
  }
});
// Use as a formatter
console.log(prettyI(bigMap)); /*
Map {
  "a": List [ 1, 2, 3, 4 ],
  "b": Map {
    "blah": Map {
      "blah": List [
        Map { "a": 1 },
        Map { "b": 2 },
        Map { "c": 3 }
      ]
    }
  }
}
*/
// Override the built-in inspect() method
prettyI.install(Immutable);
console.log(bigMap.inspect()); /*
Map {
  "a": List [ 1, 2, 3, 4 ],
  "b": Map {
    "blah": Map {
      "blah": List [
        Map { "a": 1 },
        Map { "b": 2 },
        Map { "c": 3 }
      ]
    }
  }
}
*/License
Copyright 2016 Glen Mailer.
MIT Licensed.