Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/deebloo/mie

and experiment in creating objects
https://github.com/deebloo/mie

Last synced: 15 days ago
JSON representation

and experiment in creating objects

Awesome Lists containing this project

README

        

# mie

An experiment with creating objects

```JS
var person = mie.factory('person').extend({
walk: function() {
console.log('walk');
},
talk: function() {
console.log('talk');
}
});

var stealthy = mie.factory('stealthy').extend({
sneak: function() {
console.log('sneak');
}
});

var solider = mie.factory('solider').is('person').extend({
march: function() {
console.log('march');
},
shoot: function() {
console.log('shoot');
}
});

var sniper = mie.factory('sniper').is('solider', 'stealthy').extend({
shoot: function() {
console.log('snipe!');
}
});

var danny = person.create('danny', {
fname: 'Danny',
lname: 'Blue'
});

var aaron = solider.create('aaron', {
fname: 'Aaron',
lname: 'Druck'
});

var cody = sniper.create('cody', {
fname: 'Cody',
lname: 'Henthorne'
});

person.list(); // {danny: {...}, aaron: {...}, cody: {...}}
soldier.list(); // {aaron: {...}, cody: {...}}
sniper.list(); // {cody: {...}}

mie.factory('person').get('cody') // returns cody
mie.factory('soldier').get('danny') // returns undefined

```