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

package-utils

v0.2.1

Published

Simple utilities for handling object properties to support creating packages

Readme

PackageUtilities

Table of Contents

Install

This is available as package-utils on npm. (Install with npm install package-utils.)

Usage

As usual:

var PackageUtilities = require("package-utils");

addImmutablePropertyValue(o, name, value, isEnumerable = true, isConfigurable = false)

Adds a "value" property to an object via Object.defineProperty.

addPropertyGetter(o, name, fn, isEnumerable = true, isConfigurable = false)

Adds a getter.

addPropertyGetterAndSetter(o, name, {get, set}, isEnumerable = true, isConfigurable = false)

Adds a getter and setter. For example:

var o = {_x: 100};
PackageUtilities.addPropertyGetterAndSetter(o, 'noisy_x', {
    get: function() {
        return this._x * (1 + 0.01 * Math.random());
    },
    set: function(v) {
        this._x = v * (1 + 0.01 * Math.random());
    }
});

addNonEnumerablePropertyValue(o, name, value, isWritable = false, isConfigurable = false)

Adds a non-enumerable property.

addImmutablePropertyFunction(o, name, fn, isEnumerable = false, isConfigurable = false)

Adds a "function" property to an object via Object.defineProperty. By default, functions are added as non-enumerable properties.

addImmutablePropertyObject(o, name, childObj, isEnumerable = true, isConfigurable = false)

Adds an "object" property to an object via Object.defineProperty. Does not, however, protect members that are objects.

addMutablePropertyObject(o, name, childObj, isEnumerable = true, isConfigurable = false)

Adds an "object" property to an object via Object.defineProperty. The underlying object can be mutated, but not through the property. Does not, however, protect members that are objects.

addImmutablePropertyArray(o, name, arr, isEnumerable = true, isConfigurable = false)

Adds an "array" property to an object via Object.defineProperty. Does not, however, protect array elements.

addMutablePropertyArray(o, name, arr, isEnumerable = true, isConfigurable = false)

Adds an "array" property to an object via Object.defineProperty. The underlying array can be directed mutated, but changes made to the property does not affect the underlying array. Does not, however, protect array elements.

updateDefaultOptionsWithInput(defaultOptions, inputOptions, failOnTypeMismatch = true)

Uses the (top-level) properties of defaultOptions and fills in the gaps from inputOptions with basic type checking.

hasDuckTypeEquality(examinedDuck, sourceDuck, checkPrototypeChainEquality = false)

Checks for "duck-type" equality. If checkPrototypeChainEquality is set to true, there will be an additional check that prototype chain elements point to the same functions.

getPrototypeElements(o)

Gets prototype elements of o.

filterObject(o, oFilter, inPlace = false)

Filters object o based on existing keys of oFilter. If inPlace is set to true, key-value pairs in o absent from oFilter will be deleted from o. Returns the resulting object.

isKindaUncloneable

Reports whether an independent clone of an object cannot be made. Basically checks for the following: ['Null', 'Undefined', 'Function', 'GeneratorFunction', 'Boolean', 'String', 'Number', 'RegExp', 'Symbol']

shallowCopy(o)

Does a "type-respecting" shallow copy, including non-enumerable properties, respecting property descriptors.

Note: Because functions are returned as is, functions with explicit bindings may not work as expected.

deepCopy(o)

Does a "type-respecting" deep copy, including non-enumerable properties, respecting property descriptors.

Note: Because functions are returned as is, functions with explicit bindings may not work as expected.