array-keys
Advanced tools
Comparing version 1.2.5 to 1.2.6
/*! | ||
* array-keys | ||
* version 1.2.4 | ||
* version 1.2.6 | ||
* http://github.com/silverbucket/array-keys | ||
@@ -82,3 +82,3 @@ * | ||
// start looking for the record at the same point as the idx entry | ||
for (var i = idx; i !== 0; i = i - 1) { | ||
for (var i = idx; i >= 0; i = i - 1) { | ||
if (this.store[i][this.identifier] === id) { | ||
@@ -85,0 +85,0 @@ this.store.splice(i, 1); |
!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.4 | ||
* version 1.2.6 | ||
* http://github.com/silverbucket/array-keys | ||
@@ -83,3 +83,3 @@ * | ||
// start looking for the record at the same point as the idx entry | ||
for (var i = idx; i !== 0; i = i - 1) { | ||
for (var i = idx; i >= 0; i = i - 1) { | ||
if (this.store[i][this.identifier] === id) { | ||
@@ -86,0 +86,0 @@ this.store.splice(i, 1); |
@@ -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,r,i){function n(f,s){if(!r[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=r[f]={exports:{}};e[f][0].call(u.exports,function(t){var r=e[f][1][t];return n(r?r:t)},u,u.exports,t,e,r,i)}return r[f].exports}for(var o="function"==typeof require&&require,f=0;f<i.length;f++)n(i[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(var e=this.idx.length-1;e>=0;e-=1)if(this.idx[e]===t)return e;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;for(var r=e;0!==r;r-=1)if(this.store[r][this.identifier]===t)return this.store.splice(r,1),this.idx.splice(e,1),!0;for(var 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,r=this,i=function(){};return setTimeout(function(){for(var n=r.store.length-1;n>=0;n-=1)e+=1,t(r.store[n]);i(e)},0),{"finally":function(t){i=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,r,i){function n(f,s){if(!r[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=r[f]={exports:{}};e[f][0].call(u.exports,function(t){var r=e[f][1][t];return n(r?r:t)},u,u.exports,t,e,r,i)}return r[f].exports}for(var o="function"==typeof require&&require,f=0;f<i.length;f++)n(i[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(var e=this.idx.length-1;e>=0;e-=1)if(this.idx[e]===t)return e;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;for(var r=e;r>=0;r-=1)if(this.store[r][this.identifier]===t)return this.store.splice(r,1),this.idx.splice(e,1),!0;for(var 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,r=this,i=function(){};return setTimeout(function(){for(var n=r.store.length-1;n>=0;n-=1)e+=1,t(r.store[n]);i(e)},0),{"finally":function(t){i=t}}},r.prototype.getCount=function(){return this.store.length},e.exports=r},{}]},{},[1])(1)}); |
{ | ||
"name": "array-keys", | ||
"version": "1.2.5", | ||
"version": "1.2.6", | ||
"description": "a simple interface to manage large arrays of objects easily", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -45,2 +45,16 @@ function getTests() { | ||
{ | ||
desc: "# removeRecord 1", | ||
run: function (env, test) { | ||
test.assert(env.mod.removeRecord('thingy1'), true); | ||
} | ||
}, | ||
{ | ||
desc: '# addRecord 1', | ||
run: function (env, test) { | ||
test.assert(env.mod.addRecord({id:'thingy1'}), true); | ||
} | ||
}, | ||
{ | ||
desc: '# addRecord 2', | ||
@@ -47,0 +61,0 @@ run: function (env, test) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21015
486