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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@jhel/om

v1.2.0

Published

Utility that adds composable utility methods to map a complecated nested object to a flat controlled destination object.

Readme

Object Mapper

Utility that adds composable utility methods to map a complecated nested object to a flat controlled destination object.

Applications

When integrating towards external api's it is common to get complicated nullable object structures that can result in error prone mapping of said objects.

This utility will help map and return properties in nested objects making it easier to then use in an application.

Install

Via yarn

yarn add @jhel/om

Via npm

npm install @jhel/om

Api

Keypath

An essential part of the API is the keypath. A keypath is a dot notated string path that resembles the path to get to the specific property.

For example the keypath foo.bar.value would retreive the value of the value prop in the object:

{
  foo: {
    bar: {
      value: any; // <--- The value
    }
  }
}

Operators

Every method is composable meaning they can be combined with each other to create more complex structures.

Take

Takes a specific property value from an object by given keypath.

If the object does not have the value specified in the keypath (or along the path), it will return null

@returns: Operator

Example:

const takeBarValue = take('foo.bar.value');

const theValue = takeBarValue({
  foo: { bar: { value: 'The returned value' } }
}); // returns "The returned value"

Either

Supply it with an arbitraty amount of Operator values, it will return the first defined value from the supplied Operator's.

@returns: Operator

Example:

const takeOopsValue = take('foo.bar.oops');
const takeBarValue = take('foo.bar.value');

const takeEitherOopsOrBarValue = either(takeOopsValue, takeBarValue);

const theValue = takeEitherOopsOrBarValue({
  foo: { bar: { value: 'The returned value' } }
}); // returns "The returned value"

When

If first operator is truthy it will return the value from the second Operator otherwise null.

@returns: Operator

const takeTypename = take('__typename');
const takeBarValue = take('foo.bar.value');

const whenBarTakeBarValue = when(takeTypename, takeBarValue);

const theValue = whenBarTakeBarValue({
  __typename: 'BAR',
  foo: { bar: { value: 'The returned value' } }
}); // return "The returned value"

ValueIs

First operator strictly checks with given value or runs a given predicate, return true or false depending on outcome.

@returns: Operator

const takeTypename = take('__typename');
const isTypenameBar = valueIs(takeTypename, 'BAR');
const isTypenameNotBar = valueIs(
  takeTypename,
  (typename) => typename !== 'BAR'
);

isTypenameBar({
  __typename: 'BAR',
  foo: { bar: { value: 'The returned value' } }
}); // return true

isTypenameNotBar({
  __typename: 'BAR',
  foo: { bar: { value: 'The returned value' } }
}); // return false

Om

Allows to create a new object using a supplied schema.

@return: Operator

const mapObject = om({
    value: take('foo.bar.value')
    foo: om({
        bar: when(take('__typename'), take('foo.bar'))
    })
})

const returnObject = mapObject({ __typename: 'BAR', foo: { bar: { value: 'The returned value' } } })
console.log(returnObject) // { value: 'The returned value', foo: { bar: { value: 'The returned value' } } }