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

osm.js

v1.3.0

Published

A modern JavaScript library which offers utility functions for objects in JavaScript

Readme

Osm.js

Commitizen friendly Build Status

A modern JavaScript library which offers utility functions for objects in JavaScript. Osm.js follows functional programming paradigms such as immutability & currying. Osm.js methods always return a new object rather than mutating the objects passed in. This leads to consistent & predictable behavior.

Usage

Osm.js is exported as a UMD module, which means it can work on both the client & the server.

npm

Installing Osm via npm

npm install osm.js

Then require/import it in any module

import osm from 'osm.js';

Browser

To use Osm.js from a browser, download lib/osm.min.js

Then, add it as a script tag to your page

<script src="osm.min.js"></script>
<script>
const scores = {
  Jason: 2,
  Sam: 3,
  Jane: 1
};
const double = (v) => v * 2;
const dbl = osm.map(double, scores);
</script>

Or use an AMD loader such as RequireJS

require(['./osm.min.js'], (osm) => {
  // your code here
});

Documentation

map

osm.map(interatee, obj);

Returns a new object by running obj through iteratee.

const scores = {
  Jason: 2,
  Sam: 3,
  Jane: 1
};
const double = (v) => v * 2;
const dbl = osm.map(double, scores);

filter

osm.filter(predicate, obj);

Iterates over an object & returns a new object with all values predicate returns truthy for. The predicate is invoked with two arguments: (value, key)

const scores = {
  Jason: 2,
  Sam: 3,
  Jane: 1
};
const predicate = score => score > 1;
const highScores = osm.filter(predicate, scores);

isObject

osm.isObject(value)

Checks if the value is a plain object

osm.isObject({}); //true
osm.isObject(''); //false
osm.isObject(0); //false
osm.isObject(null); //false
osm.isObject(undefined); //false
osm.isObject(NaN); //false

clone

osm.clone(obj);

Returns a new object which uses obj as it's prototype and clones the properties.

extend

osm.extend(objA, objB);

Returns a new object which uses own enumerable properties of source objects objA & objB. Sources are applied left to right and objA is not mutated in the process.

const numbers = {One: 1, Two: 2, Three: 3};
const strings = {One: 'One', Two: 'Two'};
osm.extend(numbers, strings); //{One: 'One', Two: 'Two', Three: 3};

omit

osm.omit(obj, [keys]);

Returns a new object which doesn't contain the omitted keys. Keys must be array.

const scores = {
  Jason: 2,
  Sam: 3,
  Jane: 1
};
osm.omit(scores, ['Jason', 'Sam']); //returns {Jane: 1}

findKeyByValue

osm.findKeyByValue(val, obj);

Returns the first key which matches the pass value. If no match found, then undefined is returned. Note: If the val is NaN or an object then undefined is returned.

const obj = {
  'arrayVal': [1, 2, 3],
  'boolean': false,
  'string': 'test',
  'nullVal': null,
  'notDefined': undefined,
  'notANumber': NaN,
  'dateVal': new Date('2016-01-01'),
  'secondBool': false
}

osm.findKeyByValue([1,2,3], obj); //returns 'arrayVal'
osm.findKeyByValue(false, obj); //returns 'boolean'
osm.findKeyByValue('test', obj); //returns 'string'
osm.findKeyByValue([null, obj); //returns 'nullVal'
osm.findKeyByValue(undefined, obj); //returns 'notDefined'
osm.findKeyByValue(NaN, obj); //returns undefined
osm.findKeyByValue(new Date('2016-01-01'), obj); //returns dateVal