UNPKG

king

Version:

A powerful server infrastructure management platform - "The King of your Nodes"

48 lines (37 loc) 1.16 kB
// Generated by CoffeeScript 1.6.3 var EventEmitter, List, __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; EventEmitter = require("events").EventEmitter; module.exports = List = (function(_super) { __extends(List, _super); function List() { this._array = []; } List.prototype.get = function(i) { return this._array[i]; }; List.prototype.add = function(item) { this._array.push(item); this.emit('add', item); return this; }; List.prototype.remove = function(item) { var i; i = this._array.indexOf(item); if (i === -1) { return false; } this._array.splice(i, 1); this.emit('remove', item); return this; }; List.prototype.each = function(fn) { this._array.forEach(fn); return this; }; List.prototype.map = function(fn) { return this._array.map(fn); }; return List; })(EventEmitter);