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

chamandir

v0.0.17

Published

Cha Man Dir

Downloads

20

Readme

ChaManDir

ChaManDir is a js library to help with OO development and abstract from prototype. It also have some predefined base classes to extend from. e.g eventing, getter/setter

µ is the prefered namespace for chamandir, though ChaManDir is currently the global namespace

µ = ChaManDir;

If prefer to use require.js with chamandir, configure:

require.config({
  path: {
    'chamandir',  'path to chamandir distrib version, or minified'
  }
})

require(['chamandir'], function(µ) {
  var Klass = µ.define();
});

If to use in node.js, configure package.json -> npm install, and:

var µ = require('chamandir');

To define a class use

var PokemonBreeder = µ.define({
  initialize: function(options){
    this.name = options.name;
    this.color = options.color;
    this.element = options.element;
  },
  get_color: function(){
    return this.color;
  }
});

ChaManDir classes are design to not have methods attached the class constructor, but the initialize method is always called on creation.

var pokemon = PokemonBreeder.create({
  name:    "charmander",
  color:   "red",
  element: "fire"
);
pokemon.get_color(); // return "red"
pokemon.element; // return "fire"

ChaManDir classes are designed to evolve with ability of super

var ElitePokemonBreeder = PokemonBreeder.evolve({
  initialize: function(options){
    this._super();
    this.temper = options.temper;
  }
});
var pokemon = ElitePokemonBreeder.create({
  name:     "charmander",
  color:    "red",
  element:  "fire",
  temper:   "shy"
});
pokemon.get_color(); // return "red"
pokemon.temper; // return "shy"

ChaManDir classes are able to adopt ability from other ChaManDir classes

var FireBreath = µ.define({
  fire_breath: function() {
    return "so much heat!";
  }
});
var ElitePokemonWithFireBreathBreeder = ElitePokemonBreeder.adopt(FireBreath);

or when you go fire breath you can't go back

ElitePokemonBreeder.adapt(FireBreath);

ChaManDir also has a comprehesive event system

var EventingElitePokemonBreeder = ElitePokemonBreeder.adapt(µ.Events.Delegator);
var pokemon = EventingElitePokemonBreeder.create({
  name:     "charmander",
  color:    "red",
  element:  "fire",
  temper:   "shy"
});
pokemon.bind('eat', function(){
  console.log(this.name + " is getting happier");
});
pokemon.bind('eat.start', function(){
  console.log(this.name + " just found food");
});
pokemon.trigger('eat'); // log 'charmander just found food'
                        // log 'charmander is getting happier'
pokemon.trigger('eat.start'); // log 'charmander just found food'