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

constructor-kit

v0.1.0

Published

A simple, convenient and backward compatible constructor construction API for JavaScript.

Downloads

27

Readme

Constructor-Kit

Constructor Kit is a simple, convenient and backward compatible constructor creation API for JavaScript.

Supports Nodejs, Bower, AMD and loading as a global browser <script>.

Install

bower install constructor-kit

Or

npm install constructor-kit

Bower

To use the component you will have to bundle the component using a tool like Browserify. For example:

./public/modules/app.js:

var ck = require('constructor-kit')
console.log(typeof ck)

command line:

browserify -t debowerify ./public/modules/app.js > ./public/app.max.js

Advantages

  • Built on core JavaScript features, introduces no new concepts
  • Works with all legacy and new JavaScript frameworks
  • Extremely lightweight and easy to use

Example usage

var o = {
  toString: function () {
    return ':>' + Object.prototype.toString.call(this);
  }
};

var C = constructorKit(function (message) {
  this.message = message;
}, {
  toString: function () {
    return this.message + o.toString.call(this);
  }
}, o);

var D = constructorKit(function () {
  C.call(this, 'Message from D!');
}, {
  toString: function () {
    return C.prototype.toString.call(this).toUpperCase();
  }
}, C);

var c = new C('Hello World!');
var d = new D();

// Logs: ':>[object Object]'
console.log('o.toString:', o.toString()); 
// Logs: 'Hello World!:>[object Object]
console.log('c.toString:', c.toString()); 
// Logs: 'MESSAGE FROM D!:>[OBJECT OBJECT]'
console.log('d.toString:', d.toString());

Reference

constructorKit(constructor)
constructorKit(constructor, prototypeProperties)
constructorKit(constructor, prototypeProperties, prototypeChain)

The parameter constructor is the actual constructor and the prototypeProperties parameter is a plain JavaScript object containing all the properties to have mixed into the constructor's prototype. The prototypeChain is an object or function (i.e. another constructor). A prototype chain will be created with the object or with the function's prototype property and assigned to the prototype property of the constructor parameter before returning the constructor.

NOTE: prototypeProperties can be null.