1.0.0-2 • Published 6 years ago

printen v1.0.0-2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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

npm.io

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

npm.io

API

printen(object, prefix)

ParameterTypeNecessityDescription
objectPlainObjectmandatoryPlain object to be stringified by printen
prefixStringoptionalPrefix to be used before each line, use this f.e. to indent the output

License

MIT © Florian Breisch

1.0.1-0

6 years ago

1.0.0-2

7 years ago

1.0.0-1

7 years ago

1.0.0-0

7 years ago