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

lobar

v0.9.5

Published

A thin shell wrapper for lodash.chain()

Downloads

20

Readme

lobar

A thin shell wrapper for lodash.chain().

install

> npm install -g lobar

usage

> lbr -h

Usage: lbr <JSON> <method> <arg> [method arg, ...] [options]

Options:
  -d, --data         <required> input json  [string]
  -f, --filename     <required> input json file  [string]
  -v, --verbose      verbosity level  [count]
  -p, --prettyPrint  pretty print output  [boolean]
  -i, --interactive  interactive mode  [boolean]
  -h, --help         Show help  [boolean]
  -V, --version      Show version number  [boolean]

Examples:
  lbr -d '["foo"]' map upperCase       ["FOO"]
  echo '{"foo": "bar"}' | lbr get foo  "bar"
  echo '{"foo": "bar"}' | lbr .foo     "bar"

pipe

$ echo '[{"foo":"bar"}, {"foo":"baz"}]' | lbr map foo
> ["bar","baz"]

You also have access to lodash methods inside of the method calls:

$ echo '[{"foo":"bar"}, {"foo": 3}]' | lbr filter 'x => isString(x.foo)'
> [{"foo":"bar"}]

shorthands

A leading . on an argument is shorthand for get:

$ echo '{"foo": {"bar": "baz"}}' | lbr .foo.bar
> "baz"

is equivalent to:

$ echo '{"foo": {"bar": "baz"}}' | lbr get foo.bar
> "baz"

interactive mode

$ curl https://registry.npmjs.com/lobar | lbr -i

interactive mode gif

vi keybindings

Interactive mode has basic vi keybindings. It starts in insert mode.

autocompletion

In insert mode, lobar will try to infer methods or argument from method/arg position and evaluated JSON at the current cursor position. <Tab>/<S-Tab> or <C-n>/<C-p> to navigate the completion list.

normal mode

Hitting esc will drop you into normal mode, where you can move horizontally with h, l, b, w, e, t, f, T, F, 0, and $. You can also use c and d with those movements in addition to i and a with a character or one of {}[]{}'". Vertical movement ('j', 'k', <C-d>, <C-u>), will scroll the json output.

u to undo and <C-r> to redo.

y will copy your current prompt input to your clipboard.

<C-c> to exit or enter to exit and print the currently evaluated json to stdout.

caveats

If you want to use a string argument for a method that collides with a lodash method name, you'll have to quote it twice:

echo '[{"isString": true}]' | lbr filter "'isString'"
[{"isString":true}]

This is because lbr tries to eval the argument with lodash as the context.

echo '[{"isString": true}]' | lbr filter isString
[]

environment variables

You can set options using environment variables:

$ LOBAR_PRETTY_PRINT=true lbr -d '{"foo": "bar"}' .foo
> "bar"

why?

I really like jq, but I have to look up the syntax all the time. As a javascript developer, I already know lodash, and it's generally enough for what I want to do at the command line.

TODO

  • interactive mode
    • history
    • commands:
      • R
    • tests