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

ocat

v0.3.0

Published

Inspect an object various ways in order to easily generate test cases.

Downloads

15

Readme

ocat

Inspect an object various ways in order to easily generate test cases.

assets/demo.gif

Installation

npm install ocat

API

ocat.inspect

Inspects object and returns result.

Parameters

  • obj Object to inspect
  • opts Object options (same as @see ocat.log)

ocat.bag

Inspects object and adds results to a bag. This entire bag is logged at process.on('exit').

Parameters

  • obj Object to inspect
  • opts Object options (same as @see ocat.log)

ocat.file

Same as @see ocat.log, but writes to ocat.tmpFile * at /tmp/ocat.txt on Unixes and who knows on Windows (os.tmpdir()/ocat.txt).

This is useful if you want to read isolated ocat output into your editor without other output, i.e. by your test runner.

Vim Example:

:r !OCAT_COLOR=0 OCAT_DEPTH=0 OCAT_RM=1 node % 2>&1 > /dev/null && cat /tmp/ocat.txt

will read the ocat printed output right into your editor. You should probably bind that to a shortcut. ;)

Tail Example:

In another terminal pane do:

tail -f /tmp/ocat.txt

to see logged objects every time you run your tests/code.

Parameters

  • obj Object to inspect
  • opts Object options (same as @see ocat.log) with color: false

ocat.log

Inspects object and logs it to stderr immediately.

The given opts override all other options for each supplied property, which are derived as follows:

  1. ocat.opts, the default opts: prefix: '', suffix: '', indent: '', color: true, depth: 1, commaFirst: true
  2. OCAT_COLOR and OCAT_COMMAFIRST to override the related defaults, i.e. OCAT_COLOR=0 node my.js includes no colors
  3. opts passed to ocat.create for that ocat instance only
  4. opts passed to ocat.log and ocat.bag

Parameters

  • obj Object object to inspect
  • opts Object options inherit from opts passed to create and then ocat.opts.
    • opts.prefix String? the prefix to insert before the logged object
    • opts.suffix String? the suffix to insert after the logged object
    • opts.indent String? the indentation to apply to each line
    • opts.color Boolean? if true logging in colors
    • opts.depth Number? depth to which the object is inspected
    • opts.commaFirst Boolean? if true commaFirst style is used when logging without color** (default: true)

ocat.applyRes5Opts

Applies preconfigured opts with prefix + indentation and depth that work well in lots of scenarios.

Example

const ocat = require('ocat').applyRes5Opts()

Returns Object ocat

ocat.opts

Start out as default options @see ocat.log. Allow overriding ocat options for all instances.

ocat.resetOpts

Resets ocat.opts to default opts.

ocat.create

Creates an ocat instance with the supplied options.

Parameters

  • opts Object options (same as @see ocat.log)

Returns Object ocat instance

ocat.tmpFile

The file into which ocat.file writes. Set it to any other path you like to use instead.

ocat.rm

Removes the ocat.tmpFile If the an env var OCAT_RM=1 is present, the file is removed on startup.

License

MIT