backbone.enumerable
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -25,2 +25,5 @@ (function(root, factory) { | ||
var Enumerable = function(items) { | ||
if (items) { | ||
items = _.isArray(items) ? items : [items]; | ||
} | ||
this._items = []; | ||
@@ -162,3 +165,3 @@ this._index = 0; | ||
Backbone.Enumerable.VERSION = '0.0.0'; | ||
Backbone.Enumerable.VERSION = '0.0.1'; | ||
@@ -165,0 +168,0 @@ Backbone.Enumerable.noConflict = function() { |
@@ -1,1 +0,1 @@ | ||
!function(t,e){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(t,n){return e(t,n)});else if("undefined"!=typeof exports){var n=require("backbone"),i=require("underscore");module.exports=e(n,i)}else e(t.Backbone,t._)}(this,function(t,e){"use strict";var n=t.Enumerable;return t.Enumerable=function(t,e){var n=function(t){this._items=[],this._index=0,this._type=null,this.length=0,e.each(t,this.add,this)};e.extend(n.prototype,{add:function(t,e){if(this._items.length||this._setType(t),!(t instanceof this._type))throw new Error("Wrong type supplied.");return void 0===e?this._items.push(t):this._items.splice(e,0,t),this._updateLength(),this},remove:function(t){return void 0===t?(this._items.pop(),this._updateLength(),this):(t>-1&&this._items.splice(t,1),this._updateLength(),this)},get:function(t){return void 0===t?void 0:this._items[t]||void 0},next:function(){return this._traverse(1),this},prev:function(){return this._traverse(-1),this},getNext:function(){return this.next(),this.get(this._index)},getPrev:function(){return this.prev(),this.get(this._index)},getIndex:function(){return this._index},setIndex:function(t){return 0>t||t>this._items.length-1?!1:(this._index=t,this._index)},_setType:function(t){return this._type=t.constructor,this},_traverse:function(t){if(0===this.length)return!1;var e=this._index+t;return-1===e&&(e=this.length-1),e===this.length&&(e=0),this.setIndex(e)},_updateLength:function(){this.length=this._items.length}});var i=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","includes","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];return e.each(i,function(t){n.prototype[t]=function(){var n=e.values(this._items),i=[n].concat(e.toArray(arguments));return e[t].apply(e,i)}}),n}(t,e),t.Enumerable.VERSION="0.0.0",t.Enumerable.noConflict=function(){return t.Enumerable=n,this},t.Enumerable}); | ||
!function(t,e){if("function"==typeof define&&define.amd)define(["backbone","underscore"],function(t,i){return e(t,i)});else if("undefined"!=typeof exports){var i=require("backbone"),n=require("underscore");module.exports=e(i,n)}else e(t.Backbone,t._)}(this,function(t,e){"use strict";var i=t.Enumerable;return t.Enumerable=function(t,e){var i=function(t){t&&(t=e.isArray(t)?t:[t]),this._items=[],this._index=0,this._type=null,this.length=0,e.each(t,this.add,this)};e.extend(i.prototype,{add:function(t,e){if(this._items.length||this._setType(t),!(t instanceof this._type))throw new Error("Wrong type supplied.");return void 0===e?this._items.push(t):this._items.splice(e,0,t),this._updateLength(),this},remove:function(t){return void 0===t?(this._items.pop(),this._updateLength(),this):(t>-1&&this._items.splice(t,1),this._updateLength(),this)},get:function(t){return void 0===t?void 0:this._items[t]||void 0},next:function(){return this._traverse(1),this},prev:function(){return this._traverse(-1),this},getNext:function(){return this.next(),this.get(this._index)},getPrev:function(){return this.prev(),this.get(this._index)},getIndex:function(){return this._index},setIndex:function(t){return 0>t||t>this._items.length-1?!1:(this._index=t,this._index)},_setType:function(t){return this._type=t.constructor,this},_traverse:function(t){if(0===this.length)return!1;var e=this._index+t;return-1===e&&(e=this.length-1),e===this.length&&(e=0),this.setIndex(e)},_updateLength:function(){this.length=this._items.length}});var n=["forEach","each","map","find","detect","filter","select","reject","every","all","some","any","includes","contains","invoke","toArray","first","initial","rest","last","without","isEmpty","pluck"];return e.each(n,function(t){i.prototype[t]=function(){var i=e.values(this._items),n=[i].concat(e.toArray(arguments));return e[t].apply(e,n)}}),i}(t,e),t.Enumerable.VERSION="0.0.1",t.Enumerable.noConflict=function(){return t.Enumerable=i,this},t.Enumerable}); |
{ | ||
"name": "backbone.enumerable", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Backbone.Enumerable Class for creating enumerable objects within Backbone.js apps", | ||
@@ -15,3 +15,3 @@ "main": "backbone.enumerable.js", | ||
"author": "Joe Fitter", | ||
"license": "ISC", | ||
"license": "MIT", | ||
"bugs": { | ||
@@ -18,0 +18,0 @@ "url": "https://github.com/joefitter/backbone.enumerable/issues" |
@@ -6,2 +6,5 @@ // Backbone.Enumerable | ||
var Enumerable = function(items) { | ||
if (items) { | ||
items = _.isArray(items) ? items : [items]; | ||
} | ||
this._items = []; | ||
@@ -8,0 +11,0 @@ this._index = 0; |
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
28512
0
733