Comparing version 0.2.0 to 0.2.1
@@ -13,9 +13,9 @@ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)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.lill=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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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(require,module,exports){ | ||
'use strict'; | ||
var LiLL, Symbol, add, attach, checkAttached, checkItem, clear, detach, each, getHead, getNext, getPrevious, getSize, getTail, has, remove, sData, sOwner; | ||
var LiLL, Symbol, add, attach, bData, bOwner, checkAttached, checkItem, clear, detach, each, getHead, getNext, getPrevious, getSize, getTail, has, remove; | ||
Symbol = require('es6-symbol'); | ||
sData = Symbol('linked list related data'); | ||
bData = Symbol('lill related data'); | ||
sOwner = Symbol('owner of the item'); | ||
bOwner = Symbol('lill owner of item'); | ||
@@ -27,3 +27,3 @@ attach = function(owner) { | ||
} | ||
if (owner[sData]) { | ||
if (owner[bData]) { | ||
throw new TypeError('LiLL.attach cannot use already attached object'); | ||
@@ -34,6 +34,6 @@ } | ||
} | ||
owner[sData] = data = { | ||
id: Symbol('identity of the list'), | ||
next: Symbol('next item in linked list'), | ||
prev: Symbol('previous item in linked list'), | ||
owner[bData] = data = { | ||
owner: Symbol('lill parent owner'), | ||
next: Symbol('lill next item'), | ||
prev: Symbol('lill previous item'), | ||
head: null, | ||
@@ -48,6 +48,7 @@ tail: null, | ||
detach = function(owner) { | ||
var data; | ||
data = checkAttached(owner); | ||
if (!owner[bData]) { | ||
return owner; | ||
} | ||
clear(owner); | ||
delete owner[sData]; | ||
delete owner[bData]; | ||
return owner; | ||
@@ -60,7 +61,7 @@ }; | ||
checkItem(owner, item, 'add'); | ||
if (item[data.id] === owner) { | ||
if (item[data.owner] === owner) { | ||
return owner; | ||
} | ||
item[data.next] = item[data.prev] = null; | ||
item[data.id] = owner; | ||
item[data.owner] = owner; | ||
if (!data.head) { | ||
@@ -81,3 +82,3 @@ data.head = data.tail = item; | ||
checkItem(owner, item, 'has'); | ||
return item[data.id] === owner; | ||
return item[data.owner] === owner; | ||
}; | ||
@@ -89,3 +90,3 @@ | ||
checkItem(owner, item, 'remove'); | ||
if (item[data.id] !== owner) { | ||
if (item[data.owner] !== owner) { | ||
return owner; | ||
@@ -107,3 +108,3 @@ } | ||
delete item[data.prev]; | ||
delete item[data.id]; | ||
delete item[data.owner]; | ||
data.size -= 1; | ||
@@ -120,3 +121,3 @@ return owner; | ||
delete item[data.prev]; | ||
delete item[data.id]; | ||
delete item[data.owner]; | ||
} | ||
@@ -184,3 +185,3 @@ data.head = data.tail = null; | ||
var data; | ||
if (data = owner != null ? owner[sData] : void 0) { | ||
if (data = owner != null ? owner[bData] : void 0) { | ||
return data; | ||
@@ -199,3 +200,3 @@ } | ||
} | ||
if (item[sOwner] && item[sOwner] !== owner) { | ||
if (item[bOwner] && item[bOwner] !== owner) { | ||
throw new TypeError("LiLL cannot " + method + " item that is managed by another list"); | ||
@@ -202,0 +203,0 @@ } |
@@ -11,2 +11,2 @@ /* | ||
*/ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.lill=e()}}(function(){return function e(t,n,r){function o(a,s){if(!n[a]){if(!t[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[a]={exports:{}};t[a][0].call(l.exports,function(e){var n=t[a][1][e];return o(n?n:e)},l,l.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t){"use strict";var n,r,o,i,a,s,c,u,l,f,p,d,b,y,m,v,h,x;r=e("es6-symbol"),h=r("linked list related data"),x=r("owner of the item"),i=function(e){var t,n;if(!e||"object"!=(n=typeof e)&&"function"!==n)throw new TypeError("LiLL.attach needs an object or function");if(e[h])throw new TypeError("LiLL.attach cannot use already attached object");if(!Object.isExtensible(e))throw new TypeError("LiLL.attach needs extensible object");return e[h]=t={id:r("identity of the list"),next:r("next item in linked list"),prev:r("previous item in linked list"),head:null,tail:null,size:0},Object.seal(t),e},u=function(e){var t;return t=a(e),c(e),delete e[h],e},o=function(e,t){var n;return n=a(e),s(e,t,"add"),t[n.id]===e?e:(t[n.next]=t[n.prev]=null,t[n.id]=e,n.head?(n.tail[n.next]=t,t[n.prev]=n.tail,n.tail=t):n.head=n.tail=t,n.size+=1,e)},m=function(e,t){var n;return n=a(e),s(e,t,"has"),t[n.id]===e},v=function(e,t){var n,r,o;return n=a(e),s(e,t,"remove"),t[n.id]!==e?e:(n.head===t&&(n.head=n.head[n.next]),n.tail===t&&(n.tail=n.tail[n.prev]),(o=t[n.prev])&&(o[n.next]=t[n.next]),(r=t[n.next])&&(r[n.prev]=t[n.prev]),delete t[n.next],delete t[n.prev],delete t[n.id],n.size-=1,e)},c=function(e){var t,n;for(t=a(e);n=t.head;)t.head=n[t.next],delete n[t.next],delete n[t.prev],delete n[t.id];return t.head=t.tail=null,t.size=0,e},f=function(e){var t;return t=a(e),t.head},y=function(e){var t;return t=a(e),t.tail},p=function(e,t){var n;return n=a(e),null!=t?t[n.next]:void 0},d=function(e,t){var n;return n=a(e),null!=t?t[n.prev]:void 0},b=function(e){var t;return t=a(e),t.size},l=function(e,t,n){var r,o,i,s;if(r=a(e),"function"!=typeof t)throw new TypeError("LiLL.each method expects callback function");if(i=r.head){for(o=0,n||(n=t),s=[];;){if(t.call(n,i,o++),i=i[r.next],!i)break;s.push(void 0)}return s}},a=function(e){var t;if(t=null!=e?e[h]:void 0)return t;throw new TypeError("use LiLL.attach() method on owner object")},s=function(e,t,n){var r;if(!t||"object"!=(r=typeof t)&&"function"!==r)throw new TypeError("LiLL."+n+" needs an object or function to be added");if(!Object.isExtensible(t))throw new TypeError("LiLL."+n+" method needs an extensible item");if(t[x]&&t[x]!==e)throw new TypeError("LiLL cannot "+n+" item that is managed by another list")},n={attach:i,detach:u,add:o,has:m,remove:v,clear:c,getHead:f,getTail:y,getNext:p,getPrevious:d,getSize:b,each:l},t.exports=Object.freeze(n)},{"es6-symbol":2}],2:[function(e,t){"use strict";t.exports=e("./is-implemented")()?Symbol:e("./polyfill")},{"./is-implemented":3,"./polyfill":17}],3:[function(e,t){"use strict";t.exports=function(){var e;if("function"!=typeof Symbol)return!1;e=Symbol("test symbol");try{if("Symbol (test symbol)"!==String(e))return!1}catch(t){return!1}return"symbol"==typeof Symbol.iterator?!0:"object"!=typeof Symbol.isConcatSpreadable?!1:"object"!=typeof Symbol.isRegExp?!1:"object"!=typeof Symbol.iterator?!1:"object"!=typeof Symbol.toPrimitive?!1:"object"!=typeof Symbol.toStringTag?!1:"object"!=typeof Symbol.unscopables?!1:!0}},{}],4:[function(e,t){"use strict";var n,r=e("es5-ext/object/assign"),o=e("es5-ext/object/normalize-options"),i=e("es5-ext/object/is-callable"),a=e("es5-ext/string/#/contains");n=t.exports=function(e,t){var n,i,s,c,u;return arguments.length<2||"string"!=typeof e?(c=t,t=e,e=null):c=arguments[2],null==e?(n=s=!0,i=!1):(n=a.call(e,"c"),i=a.call(e,"e"),s=a.call(e,"w")),u={value:t,configurable:n,enumerable:i,writable:s},c?r(o(c),u):u},n.gs=function(e,t,n){var s,c,u,l;return"string"!=typeof e?(u=n,n=t,t=e,e=null):u=arguments[3],null==t?t=void 0:i(t)?null==n?n=void 0:i(n)||(u=n,n=void 0):(u=t,t=n=void 0),null==e?(s=!0,c=!1):(s=a.call(e,"c"),c=a.call(e,"e")),l={get:t,set:n,configurable:s,enumerable:c},u?r(o(u),l):l}},{"es5-ext/object/assign":5,"es5-ext/object/is-callable":8,"es5-ext/object/normalize-options":12,"es5-ext/string/#/contains":14}],5:[function(e,t){"use strict";t.exports=e("./is-implemented")()?Object.assign:e("./shim")},{"./is-implemented":6,"./shim":7}],6:[function(e,t){"use strict";t.exports=function(){var e,t=Object.assign;return"function"!=typeof t?!1:(e={foo:"raz"},t(e,{bar:"dwa"},{trzy:"trzy"}),e.foo+e.bar+e.trzy==="razdwatrzy")}},{}],7:[function(e,t){"use strict";var n=e("../keys"),r=e("../valid-value"),o=Math.max;t.exports=function(e,t){var i,a,s,c=o(arguments.length,2);for(e=Object(r(e)),s=function(n){try{e[n]=t[n]}catch(r){i||(i=r)}},a=1;c>a;++a)t=arguments[a],n(t).forEach(s);if(void 0!==i)throw i;return e}},{"../keys":9,"../valid-value":13}],8:[function(e,t){"use strict";t.exports=function(e){return"function"==typeof e}},{}],9:[function(e,t){"use strict";t.exports=e("./is-implemented")()?Object.keys:e("./shim")},{"./is-implemented":10,"./shim":11}],10:[function(e,t){"use strict";t.exports=function(){try{return Object.keys("primitive"),!0}catch(e){return!1}}},{}],11:[function(e,t){"use strict";var n=Object.keys;t.exports=function(e){return n(null==e?e:Object(e))}},{}],12:[function(e,t){"use strict";var n,r=e("./assign"),o=Array.prototype.forEach,i=Object.create,a=Object.getPrototypeOf;n=function(e,t){var o=a(e);return r(o?n(o,t):t,e)},t.exports=function(){var e=i(null);return o.call(arguments,function(t){null!=t&&n(Object(t),e)}),e}},{"./assign":5}],13:[function(e,t){"use strict";t.exports=function(e){if(null==e)throw new TypeError("Cannot use null or undefined");return e}},{}],14:[function(e,t){"use strict";t.exports=e("./is-implemented")()?String.prototype.contains:e("./shim")},{"./is-implemented":15,"./shim":16}],15:[function(e,t){"use strict";var n="razdwatrzy";t.exports=function(){return"function"!=typeof n.contains?!1:n.contains("dwa")===!0&&n.contains("foo")===!1}},{}],16:[function(e,t){"use strict";var n=String.prototype.indexOf;t.exports=function(e){return n.call(this,e,arguments[1])>-1}},{}],17:[function(e,t){"use strict";var n,r,o=e("d"),i=Object.create,a=Object.defineProperties;n=function(){var e=i(null);return function(t){for(var n=0;e[t+(n||"")];)++n;return t+=n||"",e[t]=!0,"@@"+t}}(),t.exports=r=function(e){var t;if(this instanceof r)throw new TypeError("TypeError: Symbol is not a constructor");return t=i(r.prototype),e=void 0===e?"":String(e),a(t,{__description__:o("",e),__name__:o("",n(e))})},Object.defineProperties(r,{create:o("",r("create")),hasInstance:o("",r("hasInstance")),isConcatSpreadable:o("",r("isConcatSpreadable")),isRegExp:o("",r("isRegExp")),iterator:o("",r("iterator")),toPrimitive:o("",r("toPrimitive")),toStringTag:o("",r("toStringTag")),unscopables:o("",r("unscopables"))}),a(r.prototype,{properToString:o(function(){return"Symbol ("+this.__description__+")"}),toString:o("",function(){return this.__name__})}),Object.defineProperty(r.prototype,r.toPrimitive,o("",function(){throw new TypeError("Conversion of symbol objects is not allowed")})),Object.defineProperty(r.prototype,r.toStringTag,o("c","Symbol"))},{d:4}]},{},[1])(1)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.lill=e()}}(function(){return function e(t,n,r){function o(a,c){if(!n[a]){if(!t[a]){var s="function"==typeof require&&require;if(!c&&s)return s(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[a]={exports:{}};t[a][0].call(l.exports,function(e){var n=t[a][1][e];return o(n?n:e)},l,l.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t){"use strict";var n,r,o,i,a,c,s,u,l,f,p,d,b,y,m,v,h,x;r=e("es6-symbol"),a=r("lill related data"),c=r("lill owner of item"),i=function(e){var t,n;if(!e||"object"!=(n=typeof e)&&"function"!==n)throw new TypeError("LiLL.attach needs an object or function");if(e[a])throw new TypeError("LiLL.attach cannot use already attached object");if(!Object.isExtensible(e))throw new TypeError("LiLL.attach needs extensible object");return e[a]=t={owner:r("lill parent owner"),next:r("lill next item"),prev:r("lill previous item"),head:null,tail:null,size:0},Object.seal(t),e},f=function(e){return e[a]?(l(e),delete e[a],e):e},o=function(e,t){var n;return n=s(e),u(e,t,"add"),t[n.owner]===e?e:(t[n.next]=t[n.prev]=null,t[n.owner]=e,n.head?(n.tail[n.next]=t,t[n.prev]=n.tail,n.tail=t):n.head=n.tail=t,n.size+=1,e)},h=function(e,t){var n;return n=s(e),u(e,t,"has"),t[n.owner]===e},x=function(e,t){var n,r,o;return n=s(e),u(e,t,"remove"),t[n.owner]!==e?e:(n.head===t&&(n.head=n.head[n.next]),n.tail===t&&(n.tail=n.tail[n.prev]),(o=t[n.prev])&&(o[n.next]=t[n.next]),(r=t[n.next])&&(r[n.prev]=t[n.prev]),delete t[n.next],delete t[n.prev],delete t[n.owner],n.size-=1,e)},l=function(e){var t,n;for(t=s(e);n=t.head;)t.head=n[t.next],delete n[t.next],delete n[t.prev],delete n[t.owner];return t.head=t.tail=null,t.size=0,e},d=function(e){var t;return t=s(e),t.head},v=function(e){var t;return t=s(e),t.tail},b=function(e,t){var n;return n=s(e),null!=t?t[n.next]:void 0},y=function(e,t){var n;return n=s(e),null!=t?t[n.prev]:void 0},m=function(e){var t;return t=s(e),t.size},p=function(e,t,n){var r,o,i,a;if(r=s(e),"function"!=typeof t)throw new TypeError("LiLL.each method expects callback function");if(i=r.head){for(o=0,n||(n=t),a=[];;){if(t.call(n,i,o++),i=i[r.next],!i)break;a.push(void 0)}return a}},s=function(e){var t;if(t=null!=e?e[a]:void 0)return t;throw new TypeError("use LiLL.attach() method on owner object")},u=function(e,t,n){var r;if(!t||"object"!=(r=typeof t)&&"function"!==r)throw new TypeError("LiLL."+n+" needs an object or function to be added");if(!Object.isExtensible(t))throw new TypeError("LiLL."+n+" method needs an extensible item");if(t[c]&&t[c]!==e)throw new TypeError("LiLL cannot "+n+" item that is managed by another list")},n={attach:i,detach:f,add:o,has:h,remove:x,clear:l,getHead:d,getTail:v,getNext:b,getPrevious:y,getSize:m,each:p},t.exports=Object.freeze(n)},{"es6-symbol":2}],2:[function(e,t){"use strict";t.exports=e("./is-implemented")()?Symbol:e("./polyfill")},{"./is-implemented":3,"./polyfill":17}],3:[function(e,t){"use strict";t.exports=function(){var e;if("function"!=typeof Symbol)return!1;e=Symbol("test symbol");try{if("Symbol (test symbol)"!==String(e))return!1}catch(t){return!1}return"symbol"==typeof Symbol.iterator?!0:"object"!=typeof Symbol.isConcatSpreadable?!1:"object"!=typeof Symbol.isRegExp?!1:"object"!=typeof Symbol.iterator?!1:"object"!=typeof Symbol.toPrimitive?!1:"object"!=typeof Symbol.toStringTag?!1:"object"!=typeof Symbol.unscopables?!1:!0}},{}],4:[function(e,t){"use strict";var n,r=e("es5-ext/object/assign"),o=e("es5-ext/object/normalize-options"),i=e("es5-ext/object/is-callable"),a=e("es5-ext/string/#/contains");n=t.exports=function(e,t){var n,i,c,s,u;return arguments.length<2||"string"!=typeof e?(s=t,t=e,e=null):s=arguments[2],null==e?(n=c=!0,i=!1):(n=a.call(e,"c"),i=a.call(e,"e"),c=a.call(e,"w")),u={value:t,configurable:n,enumerable:i,writable:c},s?r(o(s),u):u},n.gs=function(e,t,n){var c,s,u,l;return"string"!=typeof e?(u=n,n=t,t=e,e=null):u=arguments[3],null==t?t=void 0:i(t)?null==n?n=void 0:i(n)||(u=n,n=void 0):(u=t,t=n=void 0),null==e?(c=!0,s=!1):(c=a.call(e,"c"),s=a.call(e,"e")),l={get:t,set:n,configurable:c,enumerable:s},u?r(o(u),l):l}},{"es5-ext/object/assign":5,"es5-ext/object/is-callable":8,"es5-ext/object/normalize-options":12,"es5-ext/string/#/contains":14}],5:[function(e,t){"use strict";t.exports=e("./is-implemented")()?Object.assign:e("./shim")},{"./is-implemented":6,"./shim":7}],6:[function(e,t){"use strict";t.exports=function(){var e,t=Object.assign;return"function"!=typeof t?!1:(e={foo:"raz"},t(e,{bar:"dwa"},{trzy:"trzy"}),e.foo+e.bar+e.trzy==="razdwatrzy")}},{}],7:[function(e,t){"use strict";var n=e("../keys"),r=e("../valid-value"),o=Math.max;t.exports=function(e,t){var i,a,c,s=o(arguments.length,2);for(e=Object(r(e)),c=function(n){try{e[n]=t[n]}catch(r){i||(i=r)}},a=1;s>a;++a)t=arguments[a],n(t).forEach(c);if(void 0!==i)throw i;return e}},{"../keys":9,"../valid-value":13}],8:[function(e,t){"use strict";t.exports=function(e){return"function"==typeof e}},{}],9:[function(e,t){"use strict";t.exports=e("./is-implemented")()?Object.keys:e("./shim")},{"./is-implemented":10,"./shim":11}],10:[function(e,t){"use strict";t.exports=function(){try{return Object.keys("primitive"),!0}catch(e){return!1}}},{}],11:[function(e,t){"use strict";var n=Object.keys;t.exports=function(e){return n(null==e?e:Object(e))}},{}],12:[function(e,t){"use strict";var n,r=e("./assign"),o=Array.prototype.forEach,i=Object.create,a=Object.getPrototypeOf;n=function(e,t){var o=a(e);return r(o?n(o,t):t,e)},t.exports=function(){var e=i(null);return o.call(arguments,function(t){null!=t&&n(Object(t),e)}),e}},{"./assign":5}],13:[function(e,t){"use strict";t.exports=function(e){if(null==e)throw new TypeError("Cannot use null or undefined");return e}},{}],14:[function(e,t){"use strict";t.exports=e("./is-implemented")()?String.prototype.contains:e("./shim")},{"./is-implemented":15,"./shim":16}],15:[function(e,t){"use strict";var n="razdwatrzy";t.exports=function(){return"function"!=typeof n.contains?!1:n.contains("dwa")===!0&&n.contains("foo")===!1}},{}],16:[function(e,t){"use strict";var n=String.prototype.indexOf;t.exports=function(e){return n.call(this,e,arguments[1])>-1}},{}],17:[function(e,t){"use strict";var n,r,o=e("d"),i=Object.create,a=Object.defineProperties;n=function(){var e=i(null);return function(t){for(var n=0;e[t+(n||"")];)++n;return t+=n||"",e[t]=!0,"@@"+t}}(),t.exports=r=function(e){var t;if(this instanceof r)throw new TypeError("TypeError: Symbol is not a constructor");return t=i(r.prototype),e=void 0===e?"":String(e),a(t,{__description__:o("",e),__name__:o("",n(e))})},Object.defineProperties(r,{create:o("",r("create")),hasInstance:o("",r("hasInstance")),isConcatSpreadable:o("",r("isConcatSpreadable")),isRegExp:o("",r("isRegExp")),iterator:o("",r("iterator")),toPrimitive:o("",r("toPrimitive")),toStringTag:o("",r("toStringTag")),unscopables:o("",r("unscopables"))}),a(r.prototype,{properToString:o(function(){return"Symbol ("+this.__description__+")"}),toString:o("",function(){return this.__name__})}),Object.defineProperty(r.prototype,r.toPrimitive,o("",function(){throw new TypeError("Conversion of symbol objects is not allowed")})),Object.defineProperty(r.prototype,r.toStringTag,o("c","Symbol"))},{d:4}]},{},[1])(1)}); |
@@ -12,9 +12,9 @@ /* | ||
'use strict'; | ||
var LiLL, Symbol, add, attach, checkAttached, checkItem, clear, detach, each, getHead, getNext, getPrevious, getSize, getTail, has, remove, sData, sOwner; | ||
var LiLL, Symbol, add, attach, bData, bOwner, checkAttached, checkItem, clear, detach, each, getHead, getNext, getPrevious, getSize, getTail, has, remove; | ||
Symbol = require('es6-symbol'); | ||
sData = Symbol('linked list related data'); | ||
bData = Symbol('lill related data'); | ||
sOwner = Symbol('owner of the item'); | ||
bOwner = Symbol('lill owner of item'); | ||
@@ -26,3 +26,3 @@ attach = function(owner) { | ||
} | ||
if (owner[sData]) { | ||
if (owner[bData]) { | ||
throw new TypeError('LiLL.attach cannot use already attached object'); | ||
@@ -33,6 +33,6 @@ } | ||
} | ||
owner[sData] = data = { | ||
id: Symbol('identity of the list'), | ||
next: Symbol('next item in linked list'), | ||
prev: Symbol('previous item in linked list'), | ||
owner[bData] = data = { | ||
owner: Symbol('lill parent owner'), | ||
next: Symbol('lill next item'), | ||
prev: Symbol('lill previous item'), | ||
head: null, | ||
@@ -47,6 +47,7 @@ tail: null, | ||
detach = function(owner) { | ||
var data; | ||
data = checkAttached(owner); | ||
if (!owner[bData]) { | ||
return owner; | ||
} | ||
clear(owner); | ||
delete owner[sData]; | ||
delete owner[bData]; | ||
return owner; | ||
@@ -59,7 +60,7 @@ }; | ||
checkItem(owner, item, 'add'); | ||
if (item[data.id] === owner) { | ||
if (item[data.owner] === owner) { | ||
return owner; | ||
} | ||
item[data.next] = item[data.prev] = null; | ||
item[data.id] = owner; | ||
item[data.owner] = owner; | ||
if (!data.head) { | ||
@@ -80,3 +81,3 @@ data.head = data.tail = item; | ||
checkItem(owner, item, 'has'); | ||
return item[data.id] === owner; | ||
return item[data.owner] === owner; | ||
}; | ||
@@ -88,3 +89,3 @@ | ||
checkItem(owner, item, 'remove'); | ||
if (item[data.id] !== owner) { | ||
if (item[data.owner] !== owner) { | ||
return owner; | ||
@@ -106,3 +107,3 @@ } | ||
delete item[data.prev]; | ||
delete item[data.id]; | ||
delete item[data.owner]; | ||
data.size -= 1; | ||
@@ -119,3 +120,3 @@ return owner; | ||
delete item[data.prev]; | ||
delete item[data.id]; | ||
delete item[data.owner]; | ||
} | ||
@@ -183,3 +184,3 @@ data.head = data.tail = null; | ||
var data; | ||
if (data = owner != null ? owner[sData] : void 0) { | ||
if (data = owner != null ? owner[bData] : void 0) { | ||
return data; | ||
@@ -198,3 +199,3 @@ } | ||
} | ||
if (item[sOwner] && item[sOwner] !== owner) { | ||
if (item[bOwner] && item[bOwner] !== owner) { | ||
throw new TypeError("LiLL cannot " + method + " item that is managed by another list"); | ||
@@ -201,0 +202,0 @@ } |
@@ -11,2 +11,2 @@ /* | ||
*/ | ||
"use strict";var e,t,a,r,n,c,i,o,h,d,l,s,u,v,f,L,m,b;t=require("es6-symbol"),m=t("linked list related data"),b=t("owner of the item"),r=function(e){var a,r;if(!e||"object"!=(r=typeof e)&&"function"!==r)throw new TypeError("LiLL.attach needs an object or function");if(e[m])throw new TypeError("LiLL.attach cannot use already attached object");if(!Object.isExtensible(e))throw new TypeError("LiLL.attach needs extensible object");return e[m]=a={id:t("identity of the list"),next:t("next item in linked list"),prev:t("previous item in linked list"),head:null,tail:null,size:0},Object.seal(a),e},o=function(e){var t;return t=n(e),i(e),delete e[m],e},a=function(e,t){var a;return a=n(e),c(e,t,"add"),t[a.id]===e?e:(t[a.next]=t[a.prev]=null,t[a.id]=e,a.head?(a.tail[a.next]=t,t[a.prev]=a.tail,a.tail=t):a.head=a.tail=t,a.size+=1,e)},f=function(e,t){var a;return a=n(e),c(e,t,"has"),t[a.id]===e},L=function(e,t){var a,r,i;return a=n(e),c(e,t,"remove"),t[a.id]!==e?e:(a.head===t&&(a.head=a.head[a.next]),a.tail===t&&(a.tail=a.tail[a.prev]),(i=t[a.prev])&&(i[a.next]=t[a.next]),(r=t[a.next])&&(r[a.prev]=t[a.prev]),delete t[a.next],delete t[a.prev],delete t[a.id],a.size-=1,e)},i=function(e){var t,a;for(t=n(e);a=t.head;)t.head=a[t.next],delete a[t.next],delete a[t.prev],delete a[t.id];return t.head=t.tail=null,t.size=0,e},d=function(e){var t;return t=n(e),t.head},v=function(e){var t;return t=n(e),t.tail},l=function(e,t){var a;return a=n(e),null!=t?t[a.next]:void 0},s=function(e,t){var a;return a=n(e),null!=t?t[a.prev]:void 0},u=function(e){var t;return t=n(e),t.size},h=function(e,t,a){var r,c,i,o;if(r=n(e),"function"!=typeof t)throw new TypeError("LiLL.each method expects callback function");if(i=r.head){for(c=0,a||(a=t),o=[];;){if(t.call(a,i,c++),i=i[r.next],!i)break;o.push(void 0)}return o}},n=function(e){var t;if(t=null!=e?e[m]:void 0)return t;throw new TypeError("use LiLL.attach() method on owner object")},c=function(e,t,a){var r;if(!t||"object"!=(r=typeof t)&&"function"!==r)throw new TypeError("LiLL."+a+" needs an object or function to be added");if(!Object.isExtensible(t))throw new TypeError("LiLL."+a+" method needs an extensible item");if(t[b]&&t[b]!==e)throw new TypeError("LiLL cannot "+a+" item that is managed by another list")},e={attach:r,detach:o,add:a,has:f,remove:L,clear:i,getHead:d,getTail:v,getNext:l,getPrevious:s,getSize:u,each:h},module.exports=Object.freeze(e); | ||
"use strict";var e,t,a,r,n,c,i,o,h,l,d,u,b,v,f,s,L,w;t=require("es6-symbol"),n=t("lill related data"),c=t("lill owner of item"),r=function(e){var a,r;if(!e||"object"!=(r=typeof e)&&"function"!==r)throw new TypeError("LiLL.attach needs an object or function");if(e[n])throw new TypeError("LiLL.attach cannot use already attached object");if(!Object.isExtensible(e))throw new TypeError("LiLL.attach needs extensible object");return e[n]=a={owner:t("lill parent owner"),next:t("lill next item"),prev:t("lill previous item"),head:null,tail:null,size:0},Object.seal(a),e},l=function(e){return e[n]?(h(e),delete e[n],e):e},a=function(e,t){var a;return a=i(e),o(e,t,"add"),t[a.owner]===e?e:(t[a.next]=t[a.prev]=null,t[a.owner]=e,a.head?(a.tail[a.next]=t,t[a.prev]=a.tail,a.tail=t):a.head=a.tail=t,a.size+=1,e)},L=function(e,t){var a;return a=i(e),o(e,t,"has"),t[a.owner]===e},w=function(e,t){var a,r,n;return a=i(e),o(e,t,"remove"),t[a.owner]!==e?e:(a.head===t&&(a.head=a.head[a.next]),a.tail===t&&(a.tail=a.tail[a.prev]),(n=t[a.prev])&&(n[a.next]=t[a.next]),(r=t[a.next])&&(r[a.prev]=t[a.prev]),delete t[a.next],delete t[a.prev],delete t[a.owner],a.size-=1,e)},h=function(e){var t,a;for(t=i(e);a=t.head;)t.head=a[t.next],delete a[t.next],delete a[t.prev],delete a[t.owner];return t.head=t.tail=null,t.size=0,e},u=function(e){var t;return t=i(e),t.head},s=function(e){var t;return t=i(e),t.tail},b=function(e,t){var a;return a=i(e),null!=t?t[a.next]:void 0},v=function(e,t){var a;return a=i(e),null!=t?t[a.prev]:void 0},f=function(e){var t;return t=i(e),t.size},d=function(e,t,a){var r,n,c,o;if(r=i(e),"function"!=typeof t)throw new TypeError("LiLL.each method expects callback function");if(c=r.head){for(n=0,a||(a=t),o=[];;){if(t.call(a,c,n++),c=c[r.next],!c)break;o.push(void 0)}return o}},i=function(e){var t;if(t=null!=e?e[n]:void 0)return t;throw new TypeError("use LiLL.attach() method on owner object")},o=function(e,t,a){var r;if(!t||"object"!=(r=typeof t)&&"function"!==r)throw new TypeError("LiLL."+a+" needs an object or function to be added");if(!Object.isExtensible(t))throw new TypeError("LiLL."+a+" method needs an extensible item");if(t[c]&&t[c]!==e)throw new TypeError("LiLL cannot "+a+" item that is managed by another list")},e={attach:r,detach:l,add:a,has:L,remove:w,clear:h,getHead:u,getTail:s,getNext:b,getPrevious:v,getSize:f,each:d},module.exports=Object.freeze(e); |
{ | ||
"name": "lill", | ||
"description": "Lightweight linked list implementation with small memory footprint.", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
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
640
38804