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

@aimingoo/metameta

v0.9.1

Published

Meta core and meta-class programming framework.

Downloads

7

Readme

Metameta

Metameta is meta core and meta-class programming framework.

Usage

# install from npm
> npm install @aimingoo/metameta

# OR, install from github
> npm install aimingoo/metameta

And use in javascript

// Meta core
var {Meta, MetaClass, MetaObject} = require('metameta');

// Helper methods, all home object safed.
var {isMeta, isAtom, asAtom} = Meta;

// learn case
var Objext = Meta.from(Object);
console.log(Objext.keys(new Objext)); // []
console.log(Meta.isAtom(new Objext)); // true

The Meta

atom

The atom is smallest unit of pure object in javascript, it's object but not inherited from Object(). An atom is a object. null, Object.prototype, arguments and namespace are atom objects in javascript language.

> Meta.isAtom(null);
true

> Meta.isAtom(Object.prototype)
true

meta/Atom

atom created by meta, so the meta is constructor of atoms, with Atom() on the concept is the same. meta is base unit of Meta system, and is function always.

# meta is same of Atom()
> meta = new Meta; 

# atom created
> atom = new meta;

# check is atom
> Meta.isAtom(atom);
true

# check is object
> typeof atom;
'object'

Meta

Meta is meta's class.

// extend
class MetaX extends Meta {};
var meta = new MetaX;

// meta is atom too.
console.log(Meta.isAtom(new Meta)); // true
console.log(Meta.isAtom(meta)); // true

// instance from meta, check inheritance
var x = new meta;
console.log(x instanceof meta); // true
console.log(x instanceof Meta); // true
console.log(x instanceof MetaX); // true
// another
class MetaX2 extends Meta {};
console.log(x instanceof MetaX2); // false

MetaClass

MetaClass is root of Meta-classes programming system.

// meta-classes
class MetaClassEx extends MetaClass {
    // ...
}

// extend meta system
//  NOTE: must extends from a meta/Atom
class AtomObjects extends new MetaClassEx() {
    // ...
}

// check
console.log(MetaClass.isClassOf(MetaClassEx)); // true
console.log(MetaClassEx.isClassOf(AtomObjects)); // true
console.log(MetaClassEx.isClassOf(new AtomObjects)); // true
// another
console.log(MetaClassEx.isClassOf(new MetaObject)); // false

MetaObject

MetaObject is a meta of MetaClass, and is a Class/Atom-constructor of atoms.

// MetaObject is defined in metameta
var obj = new MetaObject;
console.log(Meta.isAtom(obj)); // true

// extend object system
class MetaObjectEx extends MetaObject{}

// create atom
var x = new MetaObjectEx;

// check
console.log(MetaClass.isClassOf(MetaObject)); // true
console.log(MetaClass.isClassOf(MetaObjectEx)); // true
console.log(MetaClass.isClassOf(x)); // true

// check in pure javascript
console.log(x instanceof MetaObject); // true
console.log(x instanceof MetaObjectEx); // true
console.log(x instanceof MetaObject); // true
console.log(x instanceof MetaClass); // true
console.log(x instanceof Meta); // true

// more
var isPrototypeOf = (...args) => Object.prototype.isPrototypeOf.call(...args);
console.log(isPrototypeOf(MetaObject, MetaObjectEx)); // true
console.log(isPrototypeOf(MetaClass, MetaObject)); // false
console.log(isPrototypeOf(MetaClass, MetaObjectEx)); // false

Shadow meta

A shadow is meta from native constructor.

// shadow from native-constructor
var Objext = Meta.from(Object);

// shadow is meta
var x = new Objext;
console.log(Meta.isAtom(x)); // true

// shadow has static methods from source
console.log(Objext.keys(x)); // []

More testcases

# pull source
> git clone https://github.com/aimingoo/metameta
> cd metameta
> npm install

# test
> npm test

# coverage
> npm -g install istanbul
> npm run coverage

Interface

  • Meta's Class methods

    // Return a object is atom object
    // @param {object|function} - a object
    Meta.isAtom(x)
    
    // Return a new atom/Atom, it's proxy of x, and prototype by base.
    // @param {object}[object] - a atom base another atom object
    // @param {function}[function=Atom] - a meta base meta/Meta/Atom...
    Meta.asAtom(x, base)
    
    // Return a class is Meta
    // @param {function} - a class
    Meta.isMeta(cls)
    
    // Return a shadow meta for native-constructor
    // @param {function} - a native constructor
    Meta.from(constructor)
  • MetaClass's Class methods

    // Return the class is base of x
    // @param {object} - is instance of class
    // @param {function} - is sub-class of class
    MetaClass.isClassOf(x)
  • extends from Meta

    class MetaX extends Meta {}
  • meta's extends

    // Meta-classes programming framework based
    class X extends new MetaClass {}
    
    // OR
    class X extends new MetaX{}

History

2018.08.17 - v0.9.1 released, happy Chinese traditional valentine's day.