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 🙏

© 2025 – Pkg Stats / Ryan Hefner

inline-object

v1.0.2

Published

Converts an object to inline string and can revert if needed.

Readme

Inline Object

Formats an object into an inline string using dot notation to indicate level and position in array.

Converts this:

  name: 'Milton Waddams',
  quotes: [
    'I believe you have my stapler'
  ]

To this:

name='Milton Waddams' quote[0]='I believe you have my stapler'

Install

npm install inline-object

Usage

Using ES6

import { InlineObject } from 'inline-object';
const inlineObj = new InlineObject();

const formatted = inlineObj.format({
  name: 'Milton Waddams',
  movie: 'Office Space',
  year: 1999
});

Using ES5

var InlineObject = require('inline-object').InlineObject;
var inlineObj = new InlineObject();

var formatted = inlineObj.format({
  name: 'Milton Waddams',
  movie: 'Office Space',
  year: 1999
});

The Result

name='Milton Waddams' movie='Office Space' year=1999

Options

Options can be set in the constructor or through the instantiated instance.

depth

The max depth to parse when converting an object to inline string. When null allows any depth with 0 being the top level.

colorize

When true Node's util.inspect is used to colorize by type.

castTypes

When true and reverting an inline string, values are cast back to their original type if possible. (not full proof).

transform

API

Inline object api methods. If you are familiar with Typescript the below annotations will look familiar. For those who are not you can ignore said annotaitons. They merely indicate the "types" for method arguments and return values. If you are NOT using Typescript you can completely ignore them. The module will work as expected without using typings.

For example the revert arguments indicate the following:

// indicates expects a string.
str: string

// Indicates the method expects a key which is a string,
// a value of any type and it expects a returned value of
// any type. The "?" simply indicates that the argument is optional
transform?: (key: string, value: any) => any

format

Formats an object resulting in an inline string.

revert

Rerverts a formatted inline string back to an object. Accepts additonal

Examples

Assumes using one of the above import methods of your choice (ES6, Typescript or ES5).

Limiting Depth

const formatted = inlineObj.format({
  name: 'Milton Waddams',
  movie: 'Office Space',
  year: 1999,
  quotes: [
    // will NOT output
  ]
}, 0, true);

Using Transform with Revert

const str = "name='Milton Waddams' movie='Office Space' year=1999";
const reverted = inlineObj.revert(str, function (k, v) {
  const float = parseFloat(v); // parse out float/numbers
  if (isNaN(float)) // if not a number return orig. string.
    return v;
  return float; // otherwise return the parsed float/number.
});

Nested Output

The output follows the same naming convention as lodash's get/set methods. If you are familiar with those this will make sense.

const formatted = inlineObj.format({
  name: 'Milton Waddams',
  movie: 'Office Space',
  year: 1999,
  quotes: [
    'I believe you have my stapler'
  ]
});

Results in

name='Milton Waddams' movie='Office Space' year=1999 quote[0]='I believe you have my stapler'

Test

npm test

Change

See CHANGE.md

License

See LICENSE.md