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

aoop

v1.0.3

Published

Augmented Object Oriented Programming

Downloads

3

Readme

AOOP

License Email Donate Donate

Augmented Object Oriented Programming This node module allow programmers to use some of Object Oriented tecniques on JavaScript (Prototype Oriented)

Getting Started

Installing

For install library is easy to install by cloning the repo. You can install trhought npm too: Local installation

npm install aoop

Global installation

npm install -g aoop

Usage

  • Require
const aoop = require('aoop');

//aoop module contains this elements:
//{
//  Mixin:[Function],
//  Interface:[Function],
//  Utils:{
//    copyProto:[Function],
//    copyAsProto: [Function],
//    extend: [Function],
//    getProto: [Function],
//    isClass: [Function]
//  }
//}
  • Mixin Mixin(class A,class B,[... classes])

This function takes all methods from two or more classes (or constructor functions) and create another one that inherits all of them from the mixins classes. Remember that the hierarchy of inheritance goes from left to right

const { Mixin } = require('aoop');

//creating two classes A and B
//class A created as constructor function
function A(){}
A.prototype.foo = function(){console.log('foo');};
A.prototype.baz = function(){console.log('Baz from A!');};

//class B created as ES6 class
class B{
  bar(){console.log('bar');}
  baz(){console.log('Baz from B!');}
}

//USING MIXIN
//class C created as class
const C = new Mixin(A,B);
//class D created as ES6 class
class D extends Mixin(B,A){}

//TESTING INSTANCES
var c = new C();
var d = new D();

c.foo();  //foo
c.bar();  //bar
c.baz();  //Baz from A! (the Mixin(A,B) takes A > B hierachy)

d.foo();  //foo
d.bar();  //bar
d.baz();  //Baz from B! (the Mixin(B,A) takes B > A hierachy)
  • Interface Interface(proto, constrain)

This function constrain a constructor of a class (or a particular object) to have some methods defined in the proto argument. constrain argument tell the Interface to instanciate methods from his proto to the extended class. You can create an object from an Interface too using default methods described in the Interface proto. The Interface's instance constructor take a force argument to tell the instance to use Interface's proto defaults methods.

const { Interface, Utils } = require('aoop');

//Creating Interface that must have "bye" method
var proto = {
bye(){console.log('good bye from Hello')}
};
const Hello = new Interface(proto);

//as Function without "bye" method
function A(){Hello.call(this);}
Utils.extend(A,Hello);

//as Function with "bye" method
function B(){Hello.call(this);}
Utils.extend(B,Hello);
B.prototype.bye = function(){console.log('good bye from B');};

//as Function with defaults methods (passing "force" argument to Hello Interface)
function C(){Hello.call(this,true);}
Utils.extend(C,Hello);

//as class without "bye" method
class D extends Hello{}

//as class with "bye" method
class E extends Hello{bye(){console.log('good bye from E');}}

//as class with Hello defaults methods (passing "force" argument to Hello Interface)
class F extends Hello{constructor(){super(true);}}

var a = new A();  //throw an InterfaceError becaues is missing "bye" method
var b = new B();
var c = new C();
var d = new D();  //throw an InterfaceError becaues is missing "bye" method
var e = new E();
var f = new F();
var h = new Hello(true); //generate an Interface instance by passing true as "force" argument

b.bye();  //good bye from B
c.bye();  //good bye from Hello
e.bye();  //good bye from E
f.bye();  //good bye from Hello
h.bye();  //good bye from Hello
  • Utils This object is a library of some tools for deal with functions.

    • copyProto(A,B): get and copy the prototype of B to A

    • copyAsProto(A,B): copy directly object B to A as prototype object

    • extend(A,B): extend the A function with prototype of B

    • getProto(A): return the correct proto of the function A

    • isClass(A): return true if the A function is an ES6 class object or false if it is a normal JavaScript function

Contacts

If you like the project feel free to contact me on my Email.

Something gone wrong? Feel free to rise an issue!

Did you like this project and it was usefull? Help me improve my work:

Donate Donate