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

atomy

v2.1.3

Published

JavaScript OOP library

Downloads

1

Readme

#Atomy JavaScript OOP

##installaton npm install atomy

Browser

<script src="/path/to/undercloud.atomy.min.js"></script>

NodeJS

var Atomy = require('atomy');

##class creation

var Animal = Atomy.extend({
  weight: 0,
  abilities: ['eat','breath','see'],
  constructor: function(name) {
    this.name = name;
  },
  say: function() {
    console.log("I'am " + this.name);
  }
})

var dogg = new Animal('Snoop');
var cat  = new Animal('Tom');

dogg.say(); //I'am Snoop
cat.say(); //I'am Tom

##inheritance

var Monkey = Animal.extend({
  constructor: function(name) {
    Monkey.superclass.constructor.call(this, name);
  },
  jump: function() {
    console.log('I can jump');
  }
})

var monkey = new Monkey('Joe');

monkey.say(); //I'am Joe
monkey.jump(); //I can jump

##extends an existing class

var ReversedArray = Atomy.extend(Array, {
  constructor: function() {
    for (var i in arguments){
      this.push(arguments[i]);
    }
  },
  reverseSort: function() {
    return this.sort().reverse();
  }
})

var ra = new ReversedArray(1,5,3,4,2);
ra.reverseSort(); //[5,4,3,2,1]

##instanceof

var Animal = Atomy.extend({/*...*/});

var Monkey = Animal.extend({/*...*/});
var Human  = Monkey.extend({/*...*/});

var Wolf = Animal.extend({/*...*/});
var Dog  = Wolf.extend({/*...*/});

console.log(new Dog() instanceof Wolf); //true
console.log(new Dog() instanceof Animal); //true
console.log(new Dog() instanceof Monkey); //false

##constant

var XMath = Atomy.extend({});

XMath.constant('PI', 3.14);

try {
  XMath.PI = 0;
} catch (e) {

}

XMath.PI; //3.14

Add constant into existing objects

Atomy.constant(window, 'MYCONST', true);
window.MYCONST = false;
window.MYCONST; //true

##private

var Something = Atomy.extend({
  constructor: function() {
    var hiddenProperty = 'Hidden Value';

    Something.prototype.getHiddenProperty = function() {
      return hiddenProperty;
    };
  }
});

var s = new Something();
s.getHiddenProperty(); //Hidden Value

##inject Extend object prototype

var Something = Atomy.extend({/*...*/});

Something.inject({
  foo: 'Bar',
  getFoo: function() {
    return this.foo;
  }
});

var some = new Something();
some.getFoo(); //Bar

Inject single property

Something.inject('square', function(x) {
  return x * x;
});

some.square(3); //9

Inject into existing objects

Atomy.inject(Array, 'reverseSort', function() {
  return this.sort().reverse()
});

var a = [6,7,3,4,2];
a.reverseSort(); //[7, 6, 4, 3, 2]

##share Same as Atomy.inject but extends only static context

var Something = Atomy.extend({/*...*/});

Something.share({
  foo: 'Bar',
  getFoo: function() {
    return this.foo;
  }
});

Something.getFoo(); //Bar

Share single property

Something.inject('square', function(x) {
  return x * x;
});

Something.square(3); //9

Share existing objects

Atomy.share(window.location, 'setHash', function(hash) {
  this.hash = hash;
});

window.location.setHash('goto');

##singletone

var Animal = Atomy.extend({});

Animal.__instance__ = null;
Animal.getInstance = function() {
  if(this.__instance__ === null) {
    this.__instance__ = new Animal();
  }

  return this.__instance__;
}

var a = Animal.getInstance();
var b = Animal.getInstance();

a === b //true

##namespace

Atomy.namespace('milkyway.solar.earth');
//window.milkyway.solar.earth

var scope = {};
Atomy.namespace('milkyway.solar.earth',scope);
//scope.milkyway.solar.earth

Atomy.namespace('milkyway.solar.earth.life').Animal = Atomy.extend({
  /*...*/
});

var animal = new milkyway.solar.earth.life.Animal();

##isset

Atomy.isset('window.Array.prototype.sort'); //true
Atomy.isset('sort', Array.prototype); //true

var Animal = Atomy.extend({
  say: function() {
    /*...*/
  }
});

var monkey = new Animal();
monkey.isset('say') //true

Animal.abilities = []; 
Animal.isset('abilities'); //true

##toString

var Animal = Atomy.extend({
  toString: function() {
    return '[object Atomy]';
  }
});