npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gronk

v1.0.0

Published

Updated version of Gron which makes JSON greppable, now also works as a Node module

Downloads

33

Readme

Gronk

Updated version of Gron which makes JSON greppable, now also works as a Node module.

Unlike the Gron package, this version exports a function for use within code rather than just a binary tool.

As a module within Node:

gronk({
	foo: {
		bar: {
			baz: [
				1,
				2,
				{
					quz: 'Quz!',
				},
			],
		},
	},
}) //=

foo = {}
foo.bar = {}
foo.bar.baz = []
foo.bar.baz.0 = 1
foo.bar.baz.1 = 2
foo.bar.baz.2 = {}
foo.bar.baz.2.quz = "Quz!"

As a command line tool:

> cat test/data/complex.json | gronk
foo = "Foo!"
bar = []
bar.0 = 1
bar.1 = 2
bar.2 = {}
bar.2.baz = []
bar.2.baz.0 = 1
bar.2.baz.1 = 2
bar.2.baz.2 = 3
quz = []
quz.0 = []
quz.0.0 = 10
quz.0.1 = 20
quz.0.2 = 30
quz.1 = 40
flarp = {}
flarp.boink = "Boink!"

Differences from Gron

This module has a few differences from the standard Gron binary:

  1. Path formatting uses dotted notation instead of JS notation. For example foo.1.bar.2.baz instead of foo[1].bar[2].baz. If you would like this format set {dotted: true} in the options.
  2. Recursion detection (disable with {detectRecursion: false} if you really need to)
  3. Type detection + serialization system - the base module provides a set of base types which can be expanded for custom output

API

This module exports two items, the main function and a defaults object which allows global alteration of the default settings.

gronk(data, [options])

Accept a complex data object and return a dotted notation path + values.

Valid options are:

| Key | Type | Default | Description | |-------------------|------------|------------|----------------------------------------------------------------------------------------------------------------------------------------------| | want | string | 'string' | How to return the output, values are 'array', 'object' and 'string' | | dotted | boolean | true | Use dotted notation rather than JS notation | | stubArray | string | '[]' | How to show the marker for an array entry, set this to falsy to disable | | stubObject | string | '{}' | How to show the marker for an object entry, set this to falsy to disable | | detectRecursion | boolean | true | If recursion is detected, stop processing. Disable this only if you are absolutely sure the input is not circular | | baseTypes | boolean | true | Use the inbuilt type system which supports only Object, Array, String and Number if disabled the type system lookup gets used instead | | typeDetail | boolean | false | Use full type values, rather than abbreivating them as a digest (If enabled buffers are output as full Base64 rather than just their length) | | format | function | See code | Formatting function to use when processing each 'line', only used when want is 'array' or 'string' | | formatPath | function | See code | Formatting function to use to encode the path portion of each item | | formatData | function | See code | Formatting function to use to encode the data portion of each item | | formatString | function | See code | Used when want is 'string' to format a processed string, by default this just adds '\n' to the end | | types | array | See code | Defines the type detection + serialization system when {baseTypes: false} |

gronk.defaults

Object containing the global Gronk defaults.