Socket
Socket
Sign inDemoInstall

uhooks-fx

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uhooks-fx - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

33

cjs/index.js

@@ -14,18 +14,25 @@ 'use strict';

const fx = new WeakMap;
const states = new WeakMap;
const wrap = (h, c, a, reduced) => (
const set = (h, c, a, update) => {
const wrap = value => {
if (!fx.has(h)) {
fx.set(h, 0);
wait.then(() => {
fx.delete(h);
h.apply(c, a);
});
}
update(value);
};
states.set(update, wrap);
return wrap;
};
const wrap = (h, c, a, state) => (
h ? [
reduced[0],
value => {
if (!fx.has(h)) {
fx.set(h, 0);
wait.then(() => {
fx.delete(h);
h.apply(c, a);
});
}
reduced[1](value);
}
state[0],
states.get(state[1]) || set(h, c, a, state[1])
] :
reduced
state
);

@@ -32,0 +39,0 @@

@@ -1,3 +0,3 @@

self.uhooksFX=function(e){"use strict";var t=Promise;let n=null,s=new Set;const l=new WeakMap,a=e=>{const{$:t,r:n,h:s}=e;f(n)&&(o.get(s).delete(e),n()),f(e.r=t())&&o.get(s).add(e)},c=()=>{const e=s;s=new Set,e.forEach((({h:e,c:t,a:n,e:s})=>{s&&e.apply(t,n)}))},o=new WeakMap,u=[],r=[];function h(e,t){return e!==this[t]}const i=()=>l.get(n),f=e=>"function"==typeof e,p=e=>{const t={h:s,c:null,a:null,e:0,i:0,s:[]};return l.set(s,t),s;function s(){const l=n;n=s,t.e=t.i=0;try{return e.apply(t.c=this,t.a=arguments)}finally{n=l,u.length&&d.then(u.forEach.bind(u.splice(0),a)),r.length&&r.splice(0).forEach(a)}}},d=new t((e=>e()));function y(e){const{_:t,value:n}=this;n!==e&&(this._=new Set,this.value=e,t.forEach((({h:e,c:t,a:n})=>{e.apply(t,n)})))}const _=(e,t)=>{const n=i(),{i:s,s:l}=n;return s!==l.length&&t&&!t.some(h,l[s]._)||(l[s]={$:e(),_:t}),l[n.i++].$},g=e=>(t,n)=>{const s=i(),{i:l,s:a,h:c}=s,u=l===a.length;s.i++,u&&(o.has(c)||o.set(c,new Set),a[l]={$:t,_:n,r:null,h:c}),(u||!n||n.some(h,a[l]._))&&e.push(a[l]),a[l].$=t,a[l]._=n},w=g(u),v=g(r),E=(e,t)=>f(t)?t(e):t,$=(e,t,n)=>{const l=i(),{i:a,s:o}=l;a===o.length&&o.push({$:f(n)?n(t):E(void 0,t),set:t=>{o[a].$=e(o[a].$,t),(e=>{s.has(e)||(e.e=1,s.add(e),d.then(c))})(l)}});const{$:u,set:r}=o[l.i++];return[u,r]};
self.uhooksFX=function(e){"use strict";var t=Promise;let n=null,s=new Set;const a=new WeakMap,l=e=>{const{$:t,r:n,h:s}=e;f(n)&&(o.get(s).delete(e),n()),f(e.r=t())&&o.get(s).add(e)},c=()=>{const e=s;s=new Set,e.forEach((({h:e,c:t,a:n,e:s})=>{s&&e.apply(t,n)}))},o=new WeakMap,u=[],r=[];function h(e,t){return e!==this[t]}const i=()=>a.get(n),f=e=>"function"==typeof e,p=e=>{const t={h:s,c:null,a:null,e:0,i:0,s:[]};return a.set(s,t),s;function s(){const a=n;n=s,t.e=t.i=0;try{return e.apply(t.c=this,t.a=arguments)}finally{n=a,u.length&&d.then(u.forEach.bind(u.splice(0),l)),r.length&&r.splice(0).forEach(l)}}},d=new t((e=>e()));function y(e){const{_:t,value:n}=this;n!==e&&(this._=new Set,this.value=e,t.forEach((({h:e,c:t,a:n})=>{e.apply(t,n)})))}const g=(e,t)=>{const n=i(),{i:s,s:a}=n;return s!==a.length&&t&&!t.some(h,a[s]._)||(a[s]={$:e(),_:t}),a[n.i++].$},w=e=>(t,n)=>{const s=i(),{i:a,s:l,h:c}=s,u=a===l.length;s.i++,u&&(o.has(c)||o.set(c,new Set),l[a]={$:t,_:n,r:null,h:c}),(u||!n||n.some(h,l[a]._))&&e.push(l[a]),l[a].$=t,l[a]._=n},_=w(u),v=w(r),E=(e,t)=>f(t)?t(e):t,$=(e,t,n)=>{const a=i(),{i:l,s:o}=a;l===o.length&&o.push({$:f(n)?n(t):E(void 0,t),set:t=>{o[l].$=e(o[l].$,t),(e=>{s.has(e)||(e.e=1,s.add(e),d.then(c))})(a)}});const{$:u,set:r}=o[a.i++];return[u,r]};
/*! (c) Andrea Giammarchi - ISC */
let k=null,S=null,M=null;const m=new WeakMap,b=(e,t,n,s)=>e?[s[0],l=>{m.has(e)||(m.set(e,0),d.then((()=>{m.delete(e),e.apply(t,n)}))),s[1](l)}]:s;return e.createContext=e=>({_:new Set,provide:y,value:e}),e.dropEffect=e=>{const t=o.get(e);t&&d.then((()=>{t.forEach((e=>{e.r(),e.r=null})),t.clear()}))},e.hasEffect=e=>o.has(e),e.hooked=(e,t)=>p(t?function t(){const[n,s,l]=[k,S,M];[k,S,M]=[t,this,arguments];try{return e.apply(S,M)}finally{[k,S,M]=[n,s,l]}}:e),e.useCallback=(e,t)=>_((()=>e),t),e.useContext=({_:e,value:t})=>(e.add(i()),t),e.useEffect=w,e.useLayoutEffect=v,e.useMemo=_,e.useReducer=(e,t,n)=>b(k,S,M,$(e,t,n)),e.useRef=e=>{const t=i(),{i:n,s:s}=t;return n===s.length&&s.push({current:e}),s[t.i++]},e.useState=e=>b(k,S,M,(e=>$(E,e))(e)),e.wait=d,e}({});
let k=null,M=null,S=null;const m=new WeakMap,W=new WeakMap,b=(e,t,n,s)=>{const a=a=>{m.has(e)||(m.set(e,0),d.then((()=>{m.delete(e),e.apply(t,n)}))),s(a)};return W.set(s,a),a},C=(e,t,n,s)=>e?[s[0],W.get(s[1])||b(e,t,n,s[1])]:s;return e.createContext=e=>({_:new Set,provide:y,value:e}),e.dropEffect=e=>{const t=o.get(e);t&&d.then((()=>{t.forEach((e=>{e.r(),e.r=null})),t.clear()}))},e.hasEffect=e=>o.has(e),e.hooked=(e,t)=>p(t?function t(){const[n,s,a]=[k,M,S];[k,M,S]=[t,this,arguments];try{return e.apply(M,S)}finally{[k,M,S]=[n,s,a]}}:e),e.useCallback=(e,t)=>g((()=>e),t),e.useContext=({_:e,value:t})=>(e.add(i()),t),e.useEffect=_,e.useLayoutEffect=v,e.useMemo=g,e.useReducer=(e,t,n)=>C(k,M,S,$(e,t,n)),e.useRef=e=>{const t=i(),{i:n,s:s}=t;return n===s.length&&s.push({current:e}),s[t.i++]},e.useState=e=>C(k,M,S,(e=>$(E,e))(e)),e.wait=d,e}({});

@@ -13,18 +13,25 @@ /*! (c) Andrea Giammarchi - ISC */

const fx = new WeakMap;
const states = new WeakMap;
const wrap = (h, c, a, reduced) => (
const set = (h, c, a, update) => {
const wrap = value => {
if (!fx.has(h)) {
fx.set(h, 0);
wait.then(() => {
fx.delete(h);
h.apply(c, a);
});
}
update(value);
};
states.set(update, wrap);
return wrap;
};
const wrap = (h, c, a, state) => (
h ? [
reduced[0],
value => {
if (!fx.has(h)) {
fx.set(h, 0);
wait.then(() => {
fx.delete(h);
h.apply(c, a);
});
}
reduced[1](value);
}
state[0],
states.get(state[1]) || set(h, c, a, state[1])
] :
reduced
state
);

@@ -31,0 +38,0 @@

@@ -231,5 +231,6 @@ self.uhooksFX = (function (exports) {

var fx$1 = new WeakMap();
var states = new WeakMap();
var wrap = function wrap(h, c, a, reduced) {
return h ? [reduced[0], function (value) {
var set = function set(h, c, a, update) {
var wrap = function wrap(value) {
if (!fx$1.has(h)) {

@@ -243,6 +244,13 @@ fx$1.set(h, 0);

reduced[1](value);
}] : reduced;
update(value);
};
states.set(update, wrap);
return wrap;
};
var wrap = function wrap(h, c, a, state) {
return h ? [state[0], states.get(state[1]) || set(h, c, a, state[1])] : state;
};
var hooked$1 = function hooked$1(callback, outer) {

@@ -249,0 +257,0 @@ return hooked(outer ? function hook() {

@@ -1,1 +0,1 @@

self.uhooksFX=function(n){"use strict";var t="function"==typeof Promise?Promise:function(n){var t,e=[],u=0;return n((function(n){t=n,u=1,e.splice(0).forEach(r)})),{then:r};function r(n){return u?setTimeout(n,0,t):e.push(n),this}},e=null,u=new Set,r=new WeakMap,i=function(n){var t=n.$,e=n.r,u=n.h;h(e)&&(c.get(u).delete(n),e()),h(n.r=t())&&c.get(u).add(n)},o=function(){var n=u;u=new Set,n.forEach((function(n){var t=n.h,e=n.c,u=n.a;n.e&&t.apply(e,u)}))},c=new WeakMap,a=[],f=[];function s(n,t){return n!==this[t]}var l=function(){return r.get(e)},h=function(n){return"function"==typeof n},v=new t((function(n){return n()}));function p(n){var t=this._;this.value!==n&&(this._=new Set,this.value=n,t.forEach((function(n){var t=n.h,e=n.c,u=n.a;t.apply(e,u)})))}var d=function(n,t){var e=l(),u=e.i,r=e.s;return u!==r.length&&t&&!t.some(s,r[u]._)||(r[u]={$:n(),_:t}),r[e.i++].$},y=function(n){return function(t,e){var u=l(),r=u.i,i=u.s,o=u.h,a=r===i.length;u.i++,a&&(c.has(o)||c.set(o,new Set),i[r]={$:t,_:e,r:null,h:o}),(a||!e||e.some(s,i[r]._))&&n.push(i[r]),i[r].$=t,i[r]._=e}},g=y(a),w=y(f),E=function(n,t){return h(t)?t(n):t},$=function(n,t,e){var r=l(),i=r.i,c=r.s;i===c.length&&c.push({$:h(e)?e(t):E(void 0,t),set:function(t){c[i].$=n(c[i].$,t),function(n){u.has(n)||(n.e=1,u.add(n),v.then(o))}(r)}});var a=c[r.i++];return[a.$,a.set]},_=null,k=null,m=null,S=new WeakMap,M=function(n,t,e,u){return n?[u[0],function(r){S.has(n)||(S.set(n,0),v.then((function(){S.delete(n),n.apply(t,e)}))),u[1](r)}]:u};return n.createContext=function(n){return{_:new Set,provide:p,value:n}},n.dropEffect=function(n){var t=c.get(n);t&&v.then((function(){t.forEach((function(n){n.r(),n.r=null})),t.clear()}))},n.hasEffect=function(n){return c.has(n)},n.hooked=function(n,t){return function(n){var t={h:u,c:null,a:null,e:0,i:0,s:[]};return r.set(u,t),u;function u(){var r=e;e=u,t.e=t.i=0;try{return n.apply(t.c=this,t.a=arguments)}finally{e=r,a.length&&v.then(a.forEach.bind(a.splice(0),i)),f.length&&f.splice(0).forEach(i)}}}(t?function t(){var e=_,u=k,r=m;_=t,k=this,m=arguments;try{return n.apply(k,m)}finally{_=e,k=u,m=r}}:n)},n.useCallback=function(n,t){return d((function(){return n}),t)},n.useContext=function(n){var t=n._,e=n.value;return t.add(l()),e},n.useEffect=g,n.useLayoutEffect=w,n.useMemo=d,n.useReducer=function(n,t,e){return M(_,k,m,$(n,t,e))},n.useRef=function(n){var t=l(),e=t.i,u=t.s;return e===u.length&&u.push({current:n}),u[t.i++]},n.useState=function(n){return M(_,k,m,function(n){return $(E,n)}(n))},n.wait=v,n}({});
self.uhooksFX=function(n){"use strict";var t="function"==typeof Promise?Promise:function(n){var t,e=[],u=0;return n((function(n){t=n,u=1,e.splice(0).forEach(r)})),{then:r};function r(n){return u?setTimeout(n,0,t):e.push(n),this}},e=null,u=new Set,r=new WeakMap,i=function(n){var t=n.$,e=n.r,u=n.h;h(e)&&(c.get(u).delete(n),e()),h(n.r=t())&&c.get(u).add(n)},o=function(){var n=u;u=new Set,n.forEach((function(n){var t=n.h,e=n.c,u=n.a;n.e&&t.apply(e,u)}))},c=new WeakMap,a=[],f=[];function s(n,t){return n!==this[t]}var l=function(){return r.get(e)},h=function(n){return"function"==typeof n},v=new t((function(n){return n()}));function p(n){var t=this._;this.value!==n&&(this._=new Set,this.value=n,t.forEach((function(n){var t=n.h,e=n.c,u=n.a;t.apply(e,u)})))}var d=function(n,t){var e=l(),u=e.i,r=e.s;return u!==r.length&&t&&!t.some(s,r[u]._)||(r[u]={$:n(),_:t}),r[e.i++].$},y=function(n){return function(t,e){var u=l(),r=u.i,i=u.s,o=u.h,a=r===i.length;u.i++,a&&(c.has(o)||c.set(o,new Set),i[r]={$:t,_:e,r:null,h:o}),(a||!e||e.some(s,i[r]._))&&n.push(i[r]),i[r].$=t,i[r]._=e}},g=y(a),w=y(f),E=function(n,t){return h(t)?t(n):t},$=function(n,t,e){var r=l(),i=r.i,c=r.s;i===c.length&&c.push({$:h(e)?e(t):E(void 0,t),set:function(t){c[i].$=n(c[i].$,t),function(n){u.has(n)||(n.e=1,u.add(n),v.then(o))}(r)}});var a=c[r.i++];return[a.$,a.set]},_=null,k=null,m=null,S=new WeakMap,M=new WeakMap,W=function(n,t,e,u){var r=function(r){S.has(n)||(S.set(n,0),v.then((function(){S.delete(n),n.apply(t,e)}))),u(r)};return M.set(u,r),r},C=function(n,t,e,u){return n?[u[0],M.get(u[1])||W(n,t,e,u[1])]:u};return n.createContext=function(n){return{_:new Set,provide:p,value:n}},n.dropEffect=function(n){var t=c.get(n);t&&v.then((function(){t.forEach((function(n){n.r(),n.r=null})),t.clear()}))},n.hasEffect=function(n){return c.has(n)},n.hooked=function(n,t){return function(n){var t={h:u,c:null,a:null,e:0,i:0,s:[]};return r.set(u,t),u;function u(){var r=e;e=u,t.e=t.i=0;try{return n.apply(t.c=this,t.a=arguments)}finally{e=r,a.length&&v.then(a.forEach.bind(a.splice(0),i)),f.length&&f.splice(0).forEach(i)}}}(t?function t(){var e=_,u=k,r=m;_=t,k=this,m=arguments;try{return n.apply(k,m)}finally{_=e,k=u,m=r}}:n)},n.useCallback=function(n,t){return d((function(){return n}),t)},n.useContext=function(n){var t=n._,e=n.value;return t.add(l()),e},n.useEffect=g,n.useLayoutEffect=w,n.useMemo=d,n.useReducer=function(n,t,e){return C(_,k,m,$(n,t,e))},n.useRef=function(n){var t=l(),e=t.i,u=t.s;return e===u.length&&u.push({current:n}),u[t.i++]},n.useState=function(n){return C(_,k,m,function(n){return $(E,n)}(n))},n.wait=v,n}({});
{
"name": "uhooks-fx",
"version": "0.1.6",
"version": "0.1.7",
"description": "uhooks with propagated states",

@@ -5,0 +5,0 @@ "main": "./cjs/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc