dom-augmentor
Advanced tools
Comparing version 1.4.0 to 2.0.0
@@ -243,3 +243,3 @@ var augmentor = (function (exports) { | ||
var defaults = { | ||
sync: false, | ||
async: false, | ||
always: false | ||
@@ -255,3 +255,3 @@ }; | ||
var _ref = options || defaults, | ||
sync = _ref.sync, | ||
asy = _ref.async, | ||
always = _ref.always; | ||
@@ -261,3 +261,3 @@ | ||
stack[i] = isFunction(value) ? value() : value; | ||
if (!updates.has(hook)) updates.set(hook, sync ? update : reraf()); | ||
if (!updates.has(hook)) updates.set(hook, asy ? reraf() : update); | ||
} | ||
@@ -264,0 +264,0 @@ |
/*! (c) Andrea Giammarchi - ISC */ | ||
var augmentor=function(n){"use strict";var e={};e.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(n){return e.prototype=new e("").constructor.prototype,e;function e(n,e){e||(e={});var t=document.createEvent("CustomEvent");return t.initCustomEvent(n,!!e.bubbles,!!e.cancelable,e.detail),t}}();var t=e.CustomEvent,r={};try{r.WeakSet=WeakSet}catch(n){!function(n){var e=new n,t=u.prototype;function u(t){e.set(this,new n),t&&t.forEach(this.add,this)}t.add=function(n){return e.get(this).set(n,1),this},t.delete=function(n){return e.get(this).delete(n)},t.has=function(n){return e.get(this).has(n)},r.WeakSet=u}(WeakMap)}var u=r.WeakSet;var a=null,o=function(n){var e=[];return function t(){var r=a,u=[];a={hook:t,args:arguments,stack:e,i:0,after:u};try{return n.apply(null,arguments)}finally{a=r;for(var o=0,c=u.length;o<c;o++)u[o]()}}},c=function(){return a};function i(n,e){return n!==this[e]}var s=function(n){return"function"==typeof n},f="function"==typeof cancelAnimationFrame,l=f?cancelAnimationFrame:clearTimeout,v=f?requestAnimationFrame:setTimeout;function d(n){var e,t,r,u,a;return c(),function(n,c,s){return r=n,u=c,a=s,t||(t=v(o)),--e<0&&i(!0),i};function o(){c(),r.apply(u,a||[])}function c(){e=n||1/0,t=f?0:null}function i(n){var e=!!t;return e&&(l(t),n&&o()),e}}var h=new WeakMap,p=function(n,e,t){n.apply(e,t)},m={sync:!1,always:!1},g=function(n,e){var t=c(),r=t.i++,u=t.hook,a=t.args,o=t.stack,i=e||m,f=i.sync,l=i.always;return o.length<=r&&(o[r]=s(n)?n():n,h.has(u)||h.set(u,f?p:d())),[o[r],function(n){var e=s(n)?n(o[r]):n;(l||o[r]!==e)&&(o[r]=e,h.get(u)(u,null,a))}]},k=new WeakMap,y=function(n){var e=n.hook,t=n.args;e.apply(null,t)};function E(n){this.value!==n&&(this.value=n,k.get(this).forEach(y))}function w(n){return n.hook===this.hook}var b=new WeakMap,W=function(){},C=function(n){return function(e,t){var r=c(),u=r.i++,a=r.hook,o=r.stack,s=r.after;if(u<o.length){var f=o[u],l=f.clean,v=f.update,h=f.values;if(!t||t.some(i,h)){f.values=t,l&&(f.clean=null,l());var p=function(){f.clean=e()};n?s.push(p):v(p)}}else{b.has(a)||b.set(a,{stack:[],update:d()});var m=b.get(a),g={clean:null,stop:W,update:m.update,values:t};o[u]=g,m.stack.push(g);var k=function(){g.clean=e()};n?s.push(k):g.stop=m.update(k)}}},N=C(!1),M=C(!0),S=function(n,e){var t=c(),r=t.i++,u=t.stack;return(!e||u.length<=r||e.some(i,u[r].values))&&(u[r]={current:n(),values:e}),u[r].current},T=function(n){var e=n.Event,t=n.WeakSet,r=!0,u=null;return function(n){return r&&(r=!r,u=new t,function(n){var r=new t,a=new t;try{new MutationObserver(s).observe(n,{subtree:!0,childList:!0})}catch(e){var o=0,c=[],i=function(n){c.push(n),clearTimeout(o),o=setTimeout(function(){s(c.splice(o=0,c.length))},0)};n.addEventListener("DOMNodeRemoved",function(n){i({addedNodes:[],removedNodes:[n.target]})},!0),n.addEventListener("DOMNodeInserted",function(n){i({addedNodes:[n.target],removedNodes:[]})},!0)}function s(n){for(var e,t=n.length,u=0;u<t;u++)f((e=n[u]).removedNodes,"disconnected",a,r),f(e.addedNodes,"connected",r,a)}function f(n,t,r,u){for(var a,o=new e(t),c=n.length,i=0;i<c;1===(a=n[i++]).nodeType&&l(a,o,t,r,u));}function l(n,e,t,r,a){u.has(n)&&!r.has(n)&&(a.delete(n),r.add(n),n.dispatchEvent(e));for(var o=n.children||[],c=o.length,i=0;i<c;l(o[i++],e,t,r,a));}}(n.ownerDocument)),u.add(n),n}}({Event:t,WeakSet:u}),L=!1;return n.augmentor=function(n){var e=o(n),t=null;return function(){L=!1;var n=e.apply(this,arguments);return L&&(L=!1,function n(e,t){var r=e.nodeType;if(r){var u=1===r?e:function(n){for(var e=n.childNodes,t=e.length,r=0;r<t;){var u=e[r++];if(1===u.nodeType)return u}throw"unobservable"}(e);T(u),u.addEventListener("disconnected",t,!1)}else{var a=e.valueOf();a!==e&&n(a,t)}}(n,t||(t=function(n){b.has(n)&&b.get(n).stack.forEach(function(n){var e=n.clean;(0,n.stop)(),e&&(n.clean=null,e())})}.bind(null,e)))),n}},n.contextual=function(n){var e=null,t=o(function(){return n.apply(e,arguments)});return function(){return e=this,t.apply(this,arguments)}},n.createContext=function(n){var e={value:n,provide:E};return k.set(e,[]),e},n.useCallback=function(n,e){return S(function(){return n},e)},n.useContext=function(n){var e=c(),t=e.hook,r=e.args,u=k.get(n),a={hook:t,args:r};return u.some(w,a)||u.push(a),n.value},n.useEffect=function(){return L=!0,N.apply(null,arguments)},n.useLayoutEffect=M,n.useMemo=S,n.useReducer=function(n,e,t,r){var u="function"==typeof t,a=g(u?t(e):e,u?r:t);return[a[0],function(e){a[1](n(a[0],e))}]},n.useRef=function(n){var e=c(),t=e.i++,r=e.stack;return t<r.length?r[t]:r[t]={current:n}},n.useState=g,n}({}); | ||
var augmentor=function(n){"use strict";var e={};e.CustomEvent="function"==typeof CustomEvent?CustomEvent:function(n){return e.prototype=new e("").constructor.prototype,e;function e(n,e){e||(e={});var t=document.createEvent("CustomEvent");return t.initCustomEvent(n,!!e.bubbles,!!e.cancelable,e.detail),t}}();var t=e.CustomEvent,r={};try{r.WeakSet=WeakSet}catch(n){!function(n){var e=new n,t=u.prototype;function u(t){e.set(this,new n),t&&t.forEach(this.add,this)}t.add=function(n){return e.get(this).set(n,1),this},t.delete=function(n){return e.get(this).delete(n)},t.has=function(n){return e.get(this).has(n)},r.WeakSet=u}(WeakMap)}var u=r.WeakSet;var a=null,o=function(n){var e=[];return function t(){var r=a,u=[];a={hook:t,args:arguments,stack:e,i:0,after:u};try{return n.apply(null,arguments)}finally{a=r;for(var o=0,c=u.length;o<c;o++)u[o]()}}},c=function(){return a};function i(n,e){return n!==this[e]}var s=function(n){return"function"==typeof n},f="function"==typeof cancelAnimationFrame,l=f?cancelAnimationFrame:clearTimeout,v=f?requestAnimationFrame:setTimeout;function d(n){var e,t,r,u,a;return c(),function(n,c,s){return r=n,u=c,a=s,t||(t=v(o)),--e<0&&i(!0),i};function o(){c(),r.apply(u,a||[])}function c(){e=n||1/0,t=f?0:null}function i(n){var e=!!t;return e&&(l(t),n&&o()),e}}var h=new WeakMap,p=function(n,e,t){n.apply(e,t)},m={async:!1,always:!1},g=function(n,e){var t=c(),r=t.i++,u=t.hook,a=t.args,o=t.stack,i=e||m,f=i.async,l=i.always;return o.length<=r&&(o[r]=s(n)?n():n,h.has(u)||h.set(u,f?d():p)),[o[r],function(n){var e=s(n)?n(o[r]):n;(l||o[r]!==e)&&(o[r]=e,h.get(u)(u,null,a))}]},k=new WeakMap,y=function(n){var e=n.hook,t=n.args;e.apply(null,t)};function E(n){this.value!==n&&(this.value=n,k.get(this).forEach(y))}function w(n){return n.hook===this.hook}var b=new WeakMap,W=function(){},C=function(n){return function(e,t){var r=c(),u=r.i++,a=r.hook,o=r.stack,s=r.after;if(u<o.length){var f=o[u],l=f.clean,v=f.update,h=f.values;if(!t||t.some(i,h)){f.values=t,l&&(f.clean=null,l());var p=function(){f.clean=e()};n?s.push(p):v(p)}}else{b.has(a)||b.set(a,{stack:[],update:d()});var m=b.get(a),g={clean:null,stop:W,update:m.update,values:t};o[u]=g,m.stack.push(g);var k=function(){g.clean=e()};n?s.push(k):g.stop=m.update(k)}}},N=C(!1),M=C(!0),S=function(n,e){var t=c(),r=t.i++,u=t.stack;return(!e||u.length<=r||e.some(i,u[r].values))&&(u[r]={current:n(),values:e}),u[r].current},T=function(n){var e=n.Event,t=n.WeakSet,r=!0,u=null;return function(n){return r&&(r=!r,u=new t,function(n){var r=new t,a=new t;try{new MutationObserver(s).observe(n,{subtree:!0,childList:!0})}catch(e){var o=0,c=[],i=function(n){c.push(n),clearTimeout(o),o=setTimeout(function(){s(c.splice(o=0,c.length))},0)};n.addEventListener("DOMNodeRemoved",function(n){i({addedNodes:[],removedNodes:[n.target]})},!0),n.addEventListener("DOMNodeInserted",function(n){i({addedNodes:[n.target],removedNodes:[]})},!0)}function s(n){for(var e,t=n.length,u=0;u<t;u++)f((e=n[u]).removedNodes,"disconnected",a,r),f(e.addedNodes,"connected",r,a)}function f(n,t,r,u){for(var a,o=new e(t),c=n.length,i=0;i<c;1===(a=n[i++]).nodeType&&l(a,o,t,r,u));}function l(n,e,t,r,a){u.has(n)&&!r.has(n)&&(a.delete(n),r.add(n),n.dispatchEvent(e));for(var o=n.children||[],c=o.length,i=0;i<c;l(o[i++],e,t,r,a));}}(n.ownerDocument)),u.add(n),n}}({Event:t,WeakSet:u}),L=!1;return n.augmentor=function(n){var e=o(n),t=null;return function(){L=!1;var n=e.apply(this,arguments);return L&&(L=!1,function n(e,t){var r=e.nodeType;if(r){var u=1===r?e:function(n){for(var e=n.childNodes,t=e.length,r=0;r<t;){var u=e[r++];if(1===u.nodeType)return u}throw"unobservable"}(e);T(u),u.addEventListener("disconnected",t,!1)}else{var a=e.valueOf();a!==e&&n(a,t)}}(n,t||(t=function(n){b.has(n)&&b.get(n).stack.forEach(function(n){var e=n.clean;(0,n.stop)(),e&&(n.clean=null,e())})}.bind(null,e)))),n}},n.contextual=function(n){var e=null,t=o(function(){return n.apply(e,arguments)});return function(){return e=this,t.apply(this,arguments)}},n.createContext=function(n){var e={value:n,provide:E};return k.set(e,[]),e},n.useCallback=function(n,e){return S(function(){return n},e)},n.useContext=function(n){var e=c(),t=e.hook,r=e.args,u=k.get(n),a={hook:t,args:r};return u.some(w,a)||u.push(a),n.value},n.useEffect=function(){return L=!0,N.apply(null,arguments)},n.useLayoutEffect=M,n.useMemo=S,n.useReducer=function(n,e,t,r){var u="function"==typeof t,a=g(u?t(e):e,u?r:t);return[a[0],function(e){a[1](n(a[0],e))}]},n.useRef=function(n){var e=c(),t=e.i++,r=e.stack;return t<r.length?r[t]:r[t]={current:n}},n.useState=g,n}({}); |
{ | ||
"name": "dom-augmentor", | ||
"version": "1.4.0", | ||
"version": "2.0.0", | ||
"description": "DOM oriented useEffect hooks for the augmentor", | ||
@@ -35,15 +35,15 @@ "main": "cjs/index.js", | ||
"@ungap/weakset": "^0.1.5", | ||
"augmentor": "^1.4.0", | ||
"augmentor": "^2.0.0", | ||
"disconnected": "^0.2.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.7.2", | ||
"@babel/preset-env": "^7.7.1", | ||
"ascjs": "^3.1.0", | ||
"@babel/core": "^7.7.4", | ||
"@babel/preset-env": "^7.7.4", | ||
"ascjs": "^3.1.2", | ||
"basichtml": "^1.1.2", | ||
"coveralls": "^3.0.8", | ||
"coveralls": "^3.0.9", | ||
"drop-babel-typeof": "^1.0.3", | ||
"http-server": "^0.11.1", | ||
"http-server": "^0.12.0", | ||
"istanbul": "^0.4.5", | ||
"rollup": "^1.27.3", | ||
"rollup": "^1.27.5", | ||
"rollup-plugin-babel": "^4.3.3", | ||
@@ -50,0 +50,0 @@ "rollup-plugin-node-resolve": "^5.2.0", |
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
27066
9
+ Addedaugmentor@2.2.0(transitive)
+ Addedumap@1.0.2(transitive)
- Removedaugmentor@1.4.0(transitive)
Updatedaugmentor@^2.0.0