Skip to content

Commit

Permalink
Motion/Motion.Collection: implement Collection.Emitter
Browse files Browse the repository at this point in the history
Signed-off-by: Rick Waldron <[email protected]>
  • Loading branch information
rwaldron committed May 10, 2016
1 parent 07a6bb8 commit 4434b28
Showing 1 changed file with 37 additions and 4 deletions.
41 changes: 37 additions & 4 deletions lib/motion.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var Board = require("./board"),
events = require("events"),
util = require("util"),
priv = new Map();
var Collection = require("./mixins/collection");
var Board = require("./board");
var events = require("events");
var util = require("util");
var priv = new Map();


function analogInitializer(opts, dataHandler) {
Expand Down Expand Up @@ -217,4 +218,36 @@ function Motion(opts) {

util.inherits(Motion, events.EventEmitter);



/**
* Motion.Collection()
* new Motion.Collection()
*
* Constructs an Array-like instance
*/

Motion.Collection = function(numsOrObjects) {
if (!(this instanceof Motion.Collection)) {
return new Motion.Collection(numsOrObjects);
}

Object.defineProperty(this, "type", {
value: Motion
});

Collection.Emitter.call(this, numsOrObjects);
};

Motion.Collection.prototype = Object.create(Collection.Emitter.prototype, {
constructor: {
value: Motion.Collection
}
});

Collection.installMethodForwarding(
Motion.Collection.prototype, Motion.prototype
);


module.exports = Motion;

0 comments on commit 4434b28

Please sign in to comment.