array-keys
Advanced tools
Comparing version 1.2.1 to 1.2.2
/*! | ||
* array-keys | ||
* version 1.2.1 | ||
* version 1.2.2 | ||
* http://github.com/silverbucket/array-keys | ||
@@ -44,3 +44,3 @@ * | ||
ArrayKeys.prototype.exists = function (id) { | ||
if (this.idx.getIndex(id) >= 0) { | ||
if (this.getIndex(id) >= 0) { | ||
return true; | ||
@@ -47,0 +47,0 @@ } else { |
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.ArrayKeys=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
/*! | ||
* array-keys | ||
* version 1.2.1 | ||
* version 1.2.2 | ||
* http://github.com/silverbucket/array-keys | ||
@@ -45,3 +45,3 @@ * | ||
ArrayKeys.prototype.exists = function (id) { | ||
if (this.idx.getIndex(id) >= 0) { | ||
if (this.getIndex(id) >= 0) { | ||
return true; | ||
@@ -48,0 +48,0 @@ } else { |
@@ -1,1 +0,1 @@ | ||
!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.ArrayKeys=t()}}(function(){return function t(e,i,r){function n(f,s){if(!i[f]){if(!e[f]){var d="function"==typeof require&&require;if(!s&&d)return d(f,!0);if(o)return o(f,!0);throw new Error("Cannot find module '"+f+"'")}var u=i[f]={exports:{}};e[f][0].call(u.exports,function(t){var i=e[f][1][t];return n(i?i:t)},u,u.exports,t,e,i,r)}return i[f].exports}for(var o="function"==typeof require&&require,f=0;f<r.length;f++)n(r[f]);return n}({1:[function(t,e){function r(t){"object"!=typeof t&&(t={}),this.identifier=t.identifier||"id",this.store=[],this.idx=[]}r.prototype.getIdentifiers=function(){for(var t=[],e=this.store.length-1;e>=0;e-=1)t[t.length]=this.store[e][this.identifier];return t},r.prototype.getRecord=function(t){for(var e=this.store.length-1;e>=0;e-=1)if(this.store[e][this.identifier]===t)return this.store[e];return void 0},r.prototype.exists=function(t){return this.idx.getIndex(t)>=0?!0:!1},r.prototype.getIndex=function(t){for(i=this.idx.length-1;i>=0;i-=1)if(this.idx[i]===t)return i;return-1},r.prototype.addRecord=function(t){if("object"!=typeof t)throw new Error("cannot add non-object records.");if(!t[this.identifier])throw new Error("cannot add a record with no `"+this.identifier+"` property specified.");return this.removeRecord(t[this.identifier]),this.idx[this.idx.length]=t[this.identifier],this.store[this.store.length]=t,!0},r.prototype.removeRecord=function(t){var e=this.getIndex(t);if(0>e)return!1;var i;for(i=e;0!==i;i-=1)if(this.store[i][this.identifier]===t)return this.store.splice(i,1),this.idx.splice(e,1),!0;for(i=this.store.length-1;i!==e;i-=1)if(this.store[i][this.identifier]===t)return this.store.splice(i,1),this.idx.splice(e,1),!0;return!1},r.prototype.forEachRecord=function(t){var e=0,i=this,r=function(){};return setTimeout(function(){for(var n=i.store.length-1;n>=0;n-=1)e+=1,t(i.store[n]);r(e)},0),{"finally":function(t){r=t}}},r.prototype.getCount=function(){return this.store.length},e.exports=r},{}]},{},[1])(1)}); | ||
!function(t){if("object"==typeof exports)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.ArrayKeys=t()}}(function(){return function t(e,i,r){function n(f,s){if(!i[f]){if(!e[f]){var d="function"==typeof require&&require;if(!s&&d)return d(f,!0);if(o)return o(f,!0);throw new Error("Cannot find module '"+f+"'")}var u=i[f]={exports:{}};e[f][0].call(u.exports,function(t){var i=e[f][1][t];return n(i?i:t)},u,u.exports,t,e,i,r)}return i[f].exports}for(var o="function"==typeof require&&require,f=0;f<r.length;f++)n(r[f]);return n}({1:[function(t,e){function r(t){"object"!=typeof t&&(t={}),this.identifier=t.identifier||"id",this.store=[],this.idx=[]}r.prototype.getIdentifiers=function(){for(var t=[],e=this.store.length-1;e>=0;e-=1)t[t.length]=this.store[e][this.identifier];return t},r.prototype.getRecord=function(t){for(var e=this.store.length-1;e>=0;e-=1)if(this.store[e][this.identifier]===t)return this.store[e];return void 0},r.prototype.exists=function(t){return this.getIndex(t)>=0?!0:!1},r.prototype.getIndex=function(t){for(i=this.idx.length-1;i>=0;i-=1)if(this.idx[i]===t)return i;return-1},r.prototype.addRecord=function(t){if("object"!=typeof t)throw new Error("cannot add non-object records.");if(!t[this.identifier])throw new Error("cannot add a record with no `"+this.identifier+"` property specified.");return this.removeRecord(t[this.identifier]),this.idx[this.idx.length]=t[this.identifier],this.store[this.store.length]=t,!0},r.prototype.removeRecord=function(t){var e=this.getIndex(t);if(0>e)return!1;var i;for(i=e;0!==i;i-=1)if(this.store[i][this.identifier]===t)return this.store.splice(i,1),this.idx.splice(e,1),!0;for(i=this.store.length-1;i!==e;i-=1)if(this.store[i][this.identifier]===t)return this.store.splice(i,1),this.idx.splice(e,1),!0;return!1},r.prototype.forEachRecord=function(t){var e=0,i=this,r=function(){};return setTimeout(function(){for(var n=i.store.length-1;n>=0;n-=1)e+=1,t(i.store[n]);r(e)},0),{"finally":function(t){r=t}}},r.prototype.getCount=function(){return this.store.length},e.exports=r},{}]},{},[1])(1)}); |
{ | ||
"name": "array-keys", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "a simple interface to manage large arrays of objects easily", | ||
@@ -5,0 +5,0 @@ "license": "LGPL", |
@@ -59,2 +59,9 @@ function getTests() { | ||
{ | ||
desc: '# exists 2', | ||
run: function (env, test) { | ||
test.assert(env.mod.exists('thingy2'), true); | ||
} | ||
}, | ||
{ | ||
desc: '# getCount (3)', | ||
@@ -61,0 +68,0 @@ run: function (env, test) { |
27380
476