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

extended

v0.0.6

Published

Library for combining multiple libraries into one

Downloads

342,321

Readme

Build Status

browser support

extended

extended is a wrapper than sits on top of extender than allows you to combine multiple libraries into a single API.

This allows you create a feature rich API that only includes the functionality that you wish to have.

Extended is also browser friendly so you can create a utility library that is reusable on both in node and the browser.

Why?

Often times I end up using quite a few libraries in a single node project, extended allows you to seamlessly integrate libraries into a single interface.

You also get the added benefit of replacing libraries without having to change you code every place that they were required.

Installation

npm install extended

Or download the source (minified)

Usage

register

The register method allows you to register a library with extended.

The following example makes use of

Notice how all the APIs are completely integrated together, so you can use the chaining API from each registered library in a single unified interface.


var _ = extended()
            .register(require("array-extended"))
            .register(require("string-extended"))
            .register(require("date-extended"))
            .register(require("function-extended"))
            .register(require("is-extended"))
            .register(require("object-extended"))
            .register(require("promise-extended"));

//now use your API!

//from is-extended
_.isArray([]); //true

//from string-extended
_.format("{first} {last}", {first : "Bob", last : "yukon"});

//combination of object-extended, array-extended, and string-extended
_({hello : "hello", world: "world"}).keys().map(function(key, index){
    return _.format("%d key is %s", index + 1, key);
}).value().join(";"); //"1 key is hello; 2 key is world"

If you want to namespace you API you can provide an alias.


var _ = extended()
            .register("array", require("array-extended"))
            .register("string", require("string-extended"))
            .register("date", require("date-extended"))
            .register("fn", require("function-extended"))
            .register("is", require("is-extended"))
            .register("obj", require("object-extended"))
            .register("promise", require("promise-extended"));

//now use your API!

//from is-extended
_.is.isArray([]); //true

//from string-extended
_.string.format("{first} {last}", {first : "Bob", last : "yukon"});

Integration with other libraries.

You can also integrate other libraries by just mixing in their functions.

Suppose you dont want to use promise-extended but instead Q.

var _ = extended()
            .register(require("array-extended"))
            .register(require("string-extended"))
            .register(require("date-extended"))
            .register(require("function-extended"))
            .register(require("is-extended"))
            .register(require("object-extended"))
            .register(require("q"));

_.resolve("hello").then(function(hello){
    console.log("hello");
})

Or maybe you want to continue to use underscore with added functionality.


//lets create a library with _, promises and an inheritance library.
var _ = extended()
            .register(require("_"))
            .register(require("is-extended"))
            .register(require("promise-extended"))
            .register(require("declare.js"));

var Person = _.declare({
    constructor: function(firstName, lastName){
        this.firstName = firstName;
        this.lastName = lastName;
    }
});

var