printen
v1.0.0-2
Published
These printens look so tasty, and quite similar to a package called stringify-object, which I love.
Downloads
8
Readme
These printens look so tasty, and quite similar to a package called stringify-object, which I love.
Why
- Printed plain objects should be easy readable by humans
- Printed plain objects should be easy readable by robots
Install
$ npm install printen
Usage
Running
const printen = require('printen')
const exampleData = {
title: "Printen Examples",
stars: Number.POSITIVE_INFINITY,
cons: undefined,
pros: [
'They are gross',
'They are tasty'
],
cons: [],
attributes: {
color: 'brown',
jellyBeans: 4
}
}
console.log(printen(exampleData))
prints
Unnecessary clutter is hidden from the output, as the prefixes for subsequent attributes. But since it is hidden you can still access it via grep:
$ node printen-example.js | grep pros
pros.0: They are gross
pros.1: They are tasty
The key-value separator is in fact a colon and a tab-character therefore you can use cut to access the value:
$ node printen-example.js | grep pros | cut -f 2
They are gross
They are tasty
API
printen(object, prefix)
|Parameter|Type|Necessity|Description|
|---|---|---|---|
|object
|PlainObject
|mandatory|Plain object to be stringified by printen|
|prefix
|String
|optional|Prefix to be used before each line, use this f.e. to indent the output|
License
MIT © Florian Breisch