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

js-stdlib

v1.0.4

Published

A module containing extremely commonly used functionality

Downloads

3

Readme

js stdlib

This module is intended to provide commonly used functionality which is desired in most projects.

Getting started

Node js

npm install js-stdlib. require('js-stdlib').

Bower

bower install js-stdlib. window.stdlib.

Functionality

The following functionality is contained within the library:

  • clone - Deep clones any value.
  • copy - Shallow copies any value.
  • epromise - Extends the native promise with defer, and callback conversion functions.
  • extend - Extends objects with values from other objects.
  • format - Provides .NET like string formatting.
  • regex - Provides regex string encoding and decoding.
  • typeof - Provides an extended typeof function.

clone(val)

Deep copies all properties in the supplied value. This function can be used to create deep copies of objects, arrays or functions.

clone.register()

Adds the clone function to Object.prototype.

clone.deregister()

Removes the clone function from Object.prototype.

copy(val)

Shallow copies all properties in the supplied value. This function can be used to create shallow copies of objects, arrays or functions.

copy.register()

Adds the copy function to Object.prototype.

copy.deregister()

Removes the copy function from Object.prototype.

Promise(executor)

The extended promise type. This offers the following extensions onto the standard promise object.

Promise.defer()

Returns an object containing the promise, as well as resolve, reject and notify functions.

Promise.callback([context], func, arg1, arg2, arg3)

Calls a function with the supplied context and arguments, and supplied an additional function callback which will resolve or reject the promise returned from the function.

promise.then(onResolved, onRejected, onNotified)

The onNotified function is added as a possible argument to the then function. This function will be called when the executor notify function us called.

promise.notify(onNotified)

The function adds a handler to be called when a notification has been received.

promise.callback(cb)

Calls the supplied callback when the promise is resolved or rejected.

extend(dest, src, argN)

Extends the destination object with the properties from source. Continues extending through all supplied arguments.

extend.register()

Adds the extend function to Object.prototype.

extend.deregister()

Removes the extend function from Object.prototype.

regex

regex.encode(str)

Replaces special regex characters with their escaped equivalents.

regex.decode(str)

Replaces escaped regex characters with their unescaped equivalents.

regex.register()

Adds the encode and decode functions to RegExp.prototype.

regex.deregister()

Removes the encode and decode functions from RegExp.prototype.

typeOf(val)

An improved typeOf function. This returns the usual values from typeof along with the following differences:

  • A RegExp retruns regexp.
  • A Date returns date.
  • An Array returns array.
  • null returns null.
  • NaN returns nan.

typeOf.register()

Adds the typeOf function to Object.prototype.

typeOf.deregister()

Removes the typeOf function from Object.prototype.

format

This follows the .NET string, number and date formatting with some exceptions. Links to the relevant .NET documentation:

Differences

[TODO]

EvemtEmitter

[TODO]