Skip to content

eldargab/reuse.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reuse.js

Funky way to extend your objects

usage

obj.use = require('reuse')

// mix some properties
obj.use({
  root: 'public'
})

// or
function root (that, dir) {
  that.root = dir
}
obj.use(root, 'public')

// in both cases
obj.should.have.property('root').equal('public')

There is also a weird thing. Passing in a function with enumerable properties on prototype is the same as .use(fn.protototype)

function Klass () {
  this.a = 'a'
}

Klass.prototype.foo = 'foo'

obj.use(Klass)

obj.should.have.property('foo').equal('foo')
obj.should.not.have.property('a')

Installation

Via npm

npm install reuse

To run tests install dev dependecies and run npm test command

npm install -d
npm test

License

MIT

About

Funky way to extend your objects

Resources

Stars

Watchers

Forks

Packages

No packages published