A mixin helper
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build
.gitignore
LICENSE
README.md
bower.json
gulpfile.js
mixin.js
package.json

README.md

mixinjs

A Mixin Helper Module

Usage

  
  function MyRevealingModule() { 
    return { 
      publicMethod: function() {
        console.log('hello public method');
      };
    };
  }
  
  function Mixin1() { this.prop = 'hello world'; }
  function Mixin2() { this.val = 10; }
  
  var MixedConstructor = mixin(MyRevealingModule, Mixin1, Mixin2);
  
  var mixedInstance = MixedConstructor();
  mixedInstance.publicMethod();    // hello public method
  console.log(mixedInstance.prop); // hello world
  console.log(mixedInstance.val);  // 10
  

Notes

  • mixins are applied in the order they are defined
  • mixins that set property names used by the revealing module will replace the original definition