mop4js

0.0.11 • Public • Published

mop4js

A toy project motivated by implementing MOP (Meta Object Protocol) for Javascript ES6.

A "learn by doing" prototype of MOP for Javascript. This project follows my quest of an Interface class for Javascript (see mixin-interface-api).

I now think that using mixins is more a workaround than a "nice piece of cOOPcake". Recently, I remembered the Meta Object Protocol and sought if it was applied / applicable to Javascript. I found JOOSE and JOOP, there is also a reference MOP for PERL: MOOSE.

Regarding MOP (Meta Object Protocol), this paradigm is there for a while, since 1991 at least in the "The Art of the Metaobject Protocol" book which describes CLOS, a MOP for LISP (CLOS is the acronym of Common Lisp Object System).

My intent in this toy project is two-fold:

  • First: "Give it a try" and share a naive implementation.
  • Second: promote the usage and knowledge of MOP among Javascript developers.

Release 0.0.10 changelog

  • Documentation update.

Release 0.0.9 changelog

  • First Prototype ("Proof of concept") at a very early stage (the implementation is clumsy ATM).

Please find below a code sample:

const $$MetaClass = require('./src/mop4js.js').$$MetaClass;
 
var $$Interface = new $$MetaClass({ 'name': "$$Interface" }); // MetaClass Factory
console.log($$Interface + "\n");
 
var $ILogger = new $$Interface({ 'name': "$ILogger"}); // Class Factory
console.log($ILogger + "\n");
 
var logger = new $ILogger(); // Object instantiation and numbering
console.log(logger + "\n");

References

Package Sidebar

Install

npm i mop4js

Weekly Downloads

2

Version

0.0.11

License

MIT

Unpacked Size

15.2 kB

Total Files

5

Last publish

Collaborators

  • echopraxium