Comparing version 1.8.0 to 1.8.1
{ | ||
"name": "patronum", | ||
"version": "1.8.0", | ||
"version": "1.8.1", | ||
"description": "☄️ Effector utility library delivering modularity and convenience", | ||
@@ -34,2 +34,3 @@ "type": "module", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
@@ -46,2 +47,3 @@ "require": "./index.js", | ||
}, | ||
"./combine-events/package.json": "./combine-events/package.json", | ||
"./combine-events": { | ||
@@ -51,2 +53,3 @@ "require": "./combine-events/index.js", | ||
}, | ||
"./condition/package.json": "./condition/package.json", | ||
"./condition": { | ||
@@ -56,2 +59,3 @@ "require": "./condition/index.js", | ||
}, | ||
"./debounce/package.json": "./debounce/package.json", | ||
"./debounce": { | ||
@@ -61,2 +65,3 @@ "require": "./debounce/index.js", | ||
}, | ||
"./debug/package.json": "./debug/package.json", | ||
"./debug": { | ||
@@ -66,2 +71,3 @@ "require": "./debug/index.js", | ||
}, | ||
"./delay/package.json": "./delay/package.json", | ||
"./delay": { | ||
@@ -71,2 +77,3 @@ "require": "./delay/index.js", | ||
}, | ||
"./every/package.json": "./every/package.json", | ||
"./every": { | ||
@@ -76,2 +83,3 @@ "require": "./every/index.js", | ||
}, | ||
"./format/package.json": "./format/package.json", | ||
"./format": { | ||
@@ -81,2 +89,3 @@ "require": "./format/index.js", | ||
}, | ||
"./in-flight/package.json": "./in-flight/package.json", | ||
"./in-flight": { | ||
@@ -86,2 +95,3 @@ "require": "./in-flight/index.js", | ||
}, | ||
"./interval/package.json": "./interval/package.json", | ||
"./interval": { | ||
@@ -91,2 +101,3 @@ "require": "./interval/index.js", | ||
}, | ||
"./pending/package.json": "./pending/package.json", | ||
"./pending": { | ||
@@ -96,2 +107,3 @@ "require": "./pending/index.js", | ||
}, | ||
"./reset/package.json": "./reset/package.json", | ||
"./reset": { | ||
@@ -101,2 +113,3 @@ "require": "./reset/index.js", | ||
}, | ||
"./reshape/package.json": "./reshape/package.json", | ||
"./reshape": { | ||
@@ -106,2 +119,3 @@ "require": "./reshape/index.js", | ||
}, | ||
"./snapshot/package.json": "./snapshot/package.json", | ||
"./snapshot": { | ||
@@ -111,2 +125,3 @@ "require": "./snapshot/index.js", | ||
}, | ||
"./some/package.json": "./some/package.json", | ||
"./some": { | ||
@@ -116,2 +131,3 @@ "require": "./some/index.js", | ||
}, | ||
"./split-map/package.json": "./split-map/package.json", | ||
"./split-map": { | ||
@@ -121,2 +137,3 @@ "require": "./split-map/index.js", | ||
}, | ||
"./spread/package.json": "./spread/package.json", | ||
"./spread": { | ||
@@ -126,2 +143,3 @@ "require": "./spread/index.js", | ||
}, | ||
"./status/package.json": "./status/package.json", | ||
"./status": { | ||
@@ -131,2 +149,3 @@ "require": "./status/index.js", | ||
}, | ||
"./throttle/package.json": "./throttle/package.json", | ||
"./throttle": { | ||
@@ -136,2 +155,3 @@ "require": "./throttle/index.js", | ||
}, | ||
"./time/package.json": "./time/package.json", | ||
"./time": { | ||
@@ -138,0 +158,0 @@ "require": "./time/index.js", |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("effector"));function r(e,t,r){return e(r={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&r.path)}},r.exports),r.exports}var n=r((function(e,r){function n(e){throw new Error(e)}Object.defineProperty(r,"__esModule",{value:!0}),r.combineEvents=function({events:e,reset:r,target:o=(0,t.createEvent)({name:"target",sid:"3pez5"})}){t.is.unit(o)||n("target should be a unit");r&&!t.is.unit(r)&&n("reset should be a unit");return(0,t.withRegion)(o,(()=>{const n=Object.keys(e),i=Array.isArray(e)?[...n].fill(""):{},s=(0,t.createStore)(n.length,{name:"$counter",sid:"-dszn9a"}),a=(0,t.createStore)(i,{name:"$results",sid:"boz3x7"});s.reset((0,t.sample)({and:[o],or:{sid:"-8yzcn6"}})),a.reset(o),r&&(s.reset((0,t.sample)({and:[r],or:{sid:"-72suil"}})),a.reset(r));for(const i of n){const n=(0,t.createStore)(!1,{name:"$isDone",sid:"ucs7nc"}).on(e[i],(()=>!0)).reset(o);r&&n.reset(r),s.on(n,(e=>e-1)),a.on(e[i],((e,t)=>{const r=Array.isArray(e)?[...e]:{...e};return r[i]=t,r}))}(0,t.guard)({and:[{source:(0,t.sample)({and:[a,(0,t.merge)(Object.values(e),{name:"and",sid:"-l8g4ey"})],or:{name:"source",sid:"uf92v9"}}),filter:s.map((e=>0===e)),target:o}],or:{sid:"ciekm0"}})})),o}})),o=r((function(e,r){function n(e){return t.is.unit(e)?e.map((e=>!e)):t=>!e(t)}Object.defineProperty(r,"__esModule",{value:!0}),r.condition=function({if:e,then:r,else:o,source:i=(0,t.createEvent)({name:"source",sid:"epke23"})}){const s=t.is.unit(e)||(a=e,"function"==typeof a)?e:t=>t===e;var a;r&&(0,t.guard)({and:[{source:i,filter:s,target:r}],or:{sid:"9tug3k"}});o&&(0,t.guard)({and:[{source:i,filter:n(s),target:o}],or:{sid:"a9shb1"}});return i}})),i=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.debounce=function({source:e,timeout:r,target:n}){if(!t.is.unit(e))throw new TypeError("source must be unit from effector");if(t.is.domain(e,{sid:"iu8yzo"}))throw new TypeError("source cannot be domain");if("number"!=typeof r||r<0||!Number.isFinite(r))throw new Error(`timeout must be positive number or zero. Received: "${r}"`);let o,i;const s=n??(0,t.createEvent)({name:"tick",sid:"-xw52dh"}),a=(0,t.createEffect)((e=>(clearTimeout(i),o&&o(),new Promise(((t,n)=>{o=n,i=setTimeout(t,r,e)})))),{name:"timerFx",sid:"m8kfsq"});return(0,t.forward)({and:{from:e,to:a},or:{sid:"k4foqk"}}),(0,t.forward)({and:{from:a.done.map((({result:e})=>e)),to:s},or:{sid:"k76npd"}}),s}})),s=r((function(e,r){function n(e){return t.is.store(e,{sid:"-j30z7b"})?"store":t.is.effect(e,{sid:"-j1dlf8"})?"effect":t.is.event(e,{sid:"-io6j6k"})?"event":t.is.domain(e,{sid:"-imj5eh"})?"domain":t.is.unit(e)?"unit":"unknown"}function o(e,t,r=""){const n=r+s(e);e.watch((e=>{console.info(`[${t}] ${n}`,e)}))}function i(e){o(e.done,"effect",s(e)+"."),o(e.fail,"effect",s(e)+".")}function s(e){return e.compositeName&&e.compositeName.fullName?e.compositeName.fullName:e.shortName?e.shortName:e.name?e.name:""}Object.defineProperty(r,"__esModule",{value:!0}),r.debug=function(...e){for(const r of e){const e=n(r);(t.is.store(r,{sid:"8mdztw"})||t.is.effect(r,{sid:"-gueih2"})||t.is.event(r,{sid:"-gueh0j"}))&&o(r,e),t.is.effect(r,{sid:"-jlpzbv"})&&i(r),t.is.domain(r,{sid:"-jjisyf"})&&(r.onCreateEvent((e=>o(e,"event"))),r.onCreateStore((e=>o(e,"store"))),r.onCreateEffect(i))}}})),a=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.delay=function({source:e,timeout:r,target:n=(0,t.createEvent)({name:"target",sid:"-z2vw3w"})}){if(!t.is.unit(e))throw new TypeError("source must be a unit from effector");if(!t.is.unit(n))throw new TypeError("target must be a unit from effector");const o=function(e){if(t.is.store(e,{sid:"-va560a"})||"function"==typeof e||"number"==typeof e)return e;throw new TypeError(`'timeout' argument must be a function, Store, or a number. Passed "${typeof e}"`)}(r),i=(0,t.createEffect)((({payload:e,milliseconds:t})=>new Promise((r=>{setTimeout(r,t,e)}))),{name:"timerFx",sid:"-584o7j"});return(0,t.sample)({and:[{source:(0,t.combine)({and:[{milliseconds:o}],or:{name:"source",sid:"9rbdjo"}}),clock:e,fn:({milliseconds:e},t)=>({payload:t,milliseconds:"function"==typeof e?e(t):e}),target:i}],or:{sid:"-wmj29s"}}),(0,t.forward)({and:{from:i.doneData,to:n},or:{sid:"-vsadmx"}}),n}})),u=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.every=function(e,r){let n,o=[],i=()=>!1;Array.isArray(e)?(o=e,i=r):Array.isArray(e.stores)&&(o=e.stores,i=e.predicate);s=i,n="function"==typeof s?i:t.is.store(i,{sid:"sid3ut"})?i.map((e=>t=>e===t)):e=>e===i;var s;const a=(0,t.combine)({and:[o],or:{name:"$values",sid:"h09uhg"}}),u=n;return(0,t.combine)({and:[u,a,(e,t)=>t.every(e)],or:{sid:"hfkdw9"}})}})),c=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.format=function(e,...r){return(0,t.combine)({and:[r,t=>e.reduce(((r,n,o)=>r.concat(function(e,t){return t===e.length-1}(e,o)?n:`${n}${function(e){if(Array.isArray(e))return e.map((e=>String(e))).join(", ");return String(e)}(t[o])}`)),"")],or:{sid:"-yrbthp"}})}})),d=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.inFlight=function({effects:e,domain:r}){if(r){const e=r.createStore(0,{name:"$inFlight",sid:"-y7vg7t"});return r.onCreateEffect((t=>{e.on(t,(e=>e+1)).on(t.finally,(e=>e-1))})),e}return(0,t.combine)({and:[e.map((e=>e.inFlight)),e=>e.reduce(((e,t)=>e+t),0)],or:{sid:"ubqxa7"}})}})),f=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.interval=function({timeout:e,start:r,stop:n,leading:o=!1,trailing:i=!1}){const s=(0,t.createEvent)({name:"tick",sid:"uo9p3s"}),a=(0,t.createStore)(!1,{name:"$isRunning",sid:"-wxesi8"}),u=function(e){if(t.is.store(e,{sid:"6p7767"}))return e;if("number"==typeof e)return(0,t.createStore)(e,{and:{name:"$timeout"},sid:"5hw6se"});throw new TypeError(`timeout parameter in interval method should be number or Store. "${typeof e}" was passed`)}(e),c=a.map((e=>!e)),d=(0,t.createEvent)({name:"saveTimeout",sid:"as5clk"}),f=(0,t.createStore)(null,{name:"$timeoutId",sid:"-bh90bo"}).on(d,((e,t)=>t)),m=(0,t.createEvent)({name:"saveReject",sid:"-64swis"}),l=(0,t.createStore)((()=>{}),{name:"$rejecter",sid:"eabbu7"}).on(m,((e,t)=>t)),p=(0,t.createEffect)((e=>new Promise(((t,r)=>{const n=setTimeout(t,e);d(n),m(r)}))),{name:"timeoutFx",sid:"7lc3mj"}),y=(0,t.attach)({and:{source:[f,l],effect:([e,t])=>{t(),e&&clearTimeout(e)}},or:{name:"cleanupFx",sid:"pcn5jq"}});(0,t.guard)({and:[{clock:r,source:u,filter:c,target:p}],or:{sid:"-w5qmwp"}}),o&&(0,t.guard)({and:[{clock:r,filter:c,target:s}],or:{sid:"-vpslni"}});(0,t.sample)({and:[{clock:r,fn:()=>!0,target:a}],or:{sid:"-vaed34"}}),(0,t.guard)({and:[{clock:p.done,source:u,filter:a,target:p}],or:{sid:"-v73liy"}}),(0,t.sample)({and:[{clock:p.done,fn:()=>{},target:s}],or:{sid:"-urpcwu"}}),n&&(i&&(0,t.sample)({and:[{clock:n,target:s}],or:{sid:"-uanqf7"}}),a.on(n,(()=>!1)),(0,t.sample)({and:[{clock:n,target:y}],or:{sid:"6lcmyy"}}));return{tick:s,isRunning:a}}})),m=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.pending=function({effects:e,domain:r,of:o="some"}){if(!t.is.domain(r,{sid:"97b92c"})&&!e)throw new TypeError("domain or effects should be passed");if("some"!==o&&"every"!==o)throw new TypeError(`strategy parameter "of" can be "every" or "some". Passed: "${o}"`);let i=e??[];const s=n[o];r&&(i=[],r.onCreateEffect((e=>i.push(e))));return(0,t.combine)({and:[i.map((e=>e.pending)),s],or:{sid:"a37bj0"}})};const n={some:e=>e.some(Boolean),every:e=>e.every(Boolean)}})),l=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reset=function({clock:e,target:t}){const r=Array.isArray(t)?t:[t],n=Array.isArray(e)?e:[e];r.forEach((e=>{e.reset.call(e,n)}))}})),p=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=function({source:e,shape:t}){const r={};for(const n in t)if(n in t){const o=t[n];r[n]=e.map((e=>{const t=o(e);return void 0===t?null:t}))}return r}})),y=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.snapshot=function({source:e,clock:r,fn:n=(e=>e)}){const o=n(e.defaultState),i=r?(0,t.sample)({and:[e,r,n],or:{name:"onSnapshot",sid:"-auitd0"}}):(0,t.sample)({and:[{source:e,fn:n}],or:{name:"onSnapshot",sid:"-auir6n"}}),s=(0,t.createStore)(o,{name:"$snapshot",sid:"-7zyoaf"});return s.on(i,((e,t)=>t)),s}})),b=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.some=function(e,r){let n,o=[],i=()=>!1;Array.isArray(e)?(o=e,i=r):Array.isArray(e.stores)&&(o=e.stores,i=e.predicate);s=i,n="function"==typeof s?i:t.is.store(i,{sid:"zbwu0l"})?i.map((e=>t=>e===t)):e=>e===i;var s;const a=(0,t.combine)({and:[o],or:{name:"$values",sid:"-lv5do0"}}),u=n;return(0,t.combine)({and:[u,a,(e,t)=>t.some(e)],or:{sid:"-efc5w7"}})}})),v=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.splitMap=function({source:e,cases:r}){const n={};let o=t.is.store(e,{name:"current",sid:"-htjkz7"})?e.updates:e;for(const e in r)if(e in r){const t=r[e];n[e]=o.filterMap(t),o=o.filter({fn:e=>!t(e)})}return n.__=o,n}})),g=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.spread=function({targets:e,source:r=(0,t.createEvent)({name:"source",sid:"-iel8gi"})}){for(const n in e)if(n in e){const o=(0,t.guard)({and:[{source:r,filter:e=>"object"==typeof e&&null!==e&&n in e}],or:{name:"hasTargetKey",sid:"-gh83lo"}});t.is.store(e[n],{sid:"jliekw"})?e[n].on(o,((e,t)=>t[n])):(0,t.sample)({and:[{source:o,fn:e=>e[n],target:e[n]}],or:{sid:"lnzpe6"}})}return r}})),h=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.status=function({effect:e,defaultValue:r="initial"}){const n=(0,t.createStore)(r,{name:"$status",sid:"abrgim"});return n.on(e,(()=>"pending")).on(e.done,(()=>"done")).on(e.fail,(()=>"fail")),n}})),w=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.throttle=function({source:e,timeout:r,target:n=(0,t.createEvent)({name:"target",sid:"cenyj5"})}){if(!t.is.unit(e))throw new TypeError("source must be unit from effector");if("number"!=typeof r||r<0)throw new Error("timeout must be positive number or zero");const o=(0,t.createEffect)((()=>new Promise((e=>setTimeout(e,r)))),{name:"timerFx",sid:"uv7gwq"});return(0,t.guard)({and:[{source:e,filter:o.pending.map((e=>!e)),target:o}],or:{sid:"-iy4kn2"}}),(0,t.sample)({and:[{source:e,clock:o.done,target:n}],or:{sid:"-ija4mb"}}),n}})),j=r((function(e,r){Object.defineProperty(r,"__esModule",{value:!0}),r.time=function({clock:e,getNow:r,initial:o}){const i=r??n,s=(0,t.createEffect)(i,{name:"readNowFx",sid:"459ysb"}),a=(0,t.restore)(s,o??i(),{name:"$time",sid:"-ys9vce"});return(0,t.forward)({and:{from:e,to:s},or:{sid:"rdje9v"}}),a};const n=()=>Date.now()})),_=n.combineEvents,E=o.condition,x=i.debounce,k=s.debug,P=a.delay,M=u.every,O=c.format,$=d.inFlight,A=f.interval,S=m.pending,T=l.reset,z=p.reshape,F=y.snapshot,q=b.some,N=v.splitMap,C=g.spread,R=h.status,D=w.throttle,B=j.time,I={combineEvents:_,condition:E,debounce:x,debug:k,delay:P,every:M,format:O,inFlight:$,interval:A,pending:S,reset:T,reshape:z,snapshot:F,some:q,splitMap:N,spread:C,status:R,throttle:D,time:B};exports.combineEvents=_,exports.condition=E,exports.debounce=x,exports.debug=k,exports.default=I,exports.delay=P,exports.every=M,exports.format=O,exports.inFlight=$,exports.interval=A,exports.pending=S,exports.reset=T,exports.reshape=z,exports.snapshot=F,exports.some=q,exports.splitMap=N,exports.spread=C,exports.status=R,exports.throttle=D,exports.time=B; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("effector");function r(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function t(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function n(e){throw new Error(e)}function o(r){return e.is.unit(r)?r.map((e=>!e)):e=>!r(e)}var a={__proto__:null,condition:function(r){var{if:t,then:n,else:a,source:i=e.createEvent({name:"source",sid:"epke23"},{name:"source",sid:"epke23"})}=r,s=e.is.unit(t)||"function"==typeof t?t:e=>e===t;return n&&e.guard({and:[{source:i,filter:s,target:n}],or:{sid:"9tug3k"}}),a&&e.guard({and:[{source:i,filter:o(s),target:a}],or:{sid:"a9shb1"}}),i}};var i={__proto__:null,debounce:function(r){var t,n,{source:o,timeout:a,target:i}=r;if(!e.is.unit(o))throw new TypeError("source must be unit from effector");if(e.is.domain(o,{sid:"iu8yzo"}))throw new TypeError("source cannot be domain");if("number"!=typeof a||a<0||!Number.isFinite(a))throw new Error('timeout must be positive number or zero. Received: "'.concat(a,'"'));var s=null!=i?i:e.createEvent({name:"tick",sid:"-xw52dh"}),u=e.createEffect((e=>(clearTimeout(n),t&&t(),new Promise(((r,o)=>{t=o,n=setTimeout(r,a,e)})))),{name:"timerFx",sid:"m8kfsq"});return e.forward({and:{from:o,to:u},or:{sid:"k4foqk"}}),e.forward({and:{from:u.done.map((e=>{var{result:r}=e;return r})),to:s},or:{sid:"k76npd"}}),s}};function s(r){return e.is.store(r,{sid:"-j30z7b"})?"store":e.is.effect(r,{sid:"-j1dlf8"})?"effect":e.is.event(r,{sid:"-io6j6k"})?"event":e.is.domain(r,{sid:"-imj5eh"})?"domain":e.is.unit(r)?"unit":"unknown"}function u(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=t+d(e);e.watch((e=>{console.info("[".concat(r,"] ").concat(n),e)}))}function c(e){u(e.done,"effect",d(e)+"."),u(e.fail,"effect",d(e)+".")}function d(e){return e.compositeName&&e.compositeName.fullName?e.compositeName.fullName:e.shortName?e.shortName:e.name?e.name:""}var f={__proto__:null,debug:function(){for(var r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];for(var o of t){var a=s(o);(e.is.store(o,{sid:"8mdztw"})||e.is.effect(o,{sid:"-gueih2"})||e.is.event(o,{sid:"-gueh0j"}))&&u(o,a),e.is.effect(o,{sid:"-jlpzbv"})&&c(o),e.is.domain(o,{sid:"-jjisyf"})&&(o.onCreateEvent((e=>u(e,"event"))),o.onCreateStore((e=>u(e,"store"))),o.onCreateEffect(c))}}};var l={__proto__:null,delay:function(r){var{source:t,timeout:n,target:o=e.createEvent({name:"target",sid:"-z2vw3w"},{name:"target",sid:"-z2vw3w"})}=r;if(!e.is.unit(t))throw new TypeError("source must be a unit from effector");if(!e.is.unit(o))throw new TypeError("target must be a unit from effector");var a=function(r){if(e.is.store(r,{sid:"-va560a"})||"function"==typeof r||"number"==typeof r)return r;throw new TypeError("'timeout' argument must be a function, Store, or a number. Passed \"".concat(typeof r,'"'))}(n),i=e.createEffect((e=>{var{payload:r,milliseconds:t}=e;return new Promise((e=>{setTimeout(e,t,r)}))}),{name:"timerFx",sid:"-584o7j"});return e.sample({and:[{source:e.combine({and:[{milliseconds:a}],or:{name:"source",sid:"9rbdjo"}}),clock:t,fn:(e,r)=>{var{milliseconds:t}=e;return{payload:r,milliseconds:"function"==typeof t?t(r):t}},target:i}],or:{sid:"-wmj29s"}}),e.forward({and:{from:i.doneData,to:o},or:{sid:"-vsadmx"}}),o}};var m={__proto__:null,every:function(r,t){var n,o=[],a=()=>!1;Array.isArray(r)?(o=r,a=t):Array.isArray(r.stores)&&(o=r.stores,a=r.predicate),n="function"==typeof a?a:e.is.store(a,{sid:"sid3ut"})?a.map((e=>r=>e===r)):e=>e===a;var i=e.combine({and:[o],or:{name:"$values",sid:"h09uhg"}}),s=n;return e.combine({and:[s,i,(e,r)=>r.every(e)],or:{sid:"hfkdw9"}})}};function p(e){return Array.isArray(e)?e.map((e=>String(e))).join(", "):String(e)}function v(e,r){return r===e.length-1}var g={__proto__:null,format:function(r){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return e.combine({and:[n,e=>r.reduce(((t,n,o)=>t.concat(v(r,o)?n:"".concat(n).concat(p(e[o])))),"")],or:{sid:"-yrbthp"}})}};var y={__proto__:null,inFlight:function(r){var{effects:t,domain:n}=r;if(n){var o=n.createStore(0,{name:"$inFlight",sid:"-y7vg7t"});return n.onCreateEffect((e=>{o.on(e,(e=>e+1)).on(e.finally,(e=>e-1))})),o}return e.combine({and:[t.map((e=>e.inFlight)),e=>e.reduce(((e,r)=>e+r),0)],or:{sid:"ubqxa7"}})}};var b={__proto__:null,interval:function(r){var{timeout:t,start:n,stop:o,leading:a=!1,trailing:i=!1}=r,s=e.createEvent({name:"tick",sid:"uo9p3s"}),u=e.createStore(!1,{name:"$isRunning",sid:"-wxesi8"}),c=function(r){if(e.is.store(r,{sid:"6p7767"}))return r;if("number"==typeof r)return e.createStore(r,{and:{name:"$timeout"},sid:"5hw6se"});throw new TypeError('timeout parameter in interval method should be number or Store. "'.concat(typeof r,'" was passed'))}(t),d=u.map((e=>!e)),f=e.createEvent({name:"saveTimeout",sid:"as5clk"}),l=e.createStore(null,{name:"$timeoutId",sid:"-bh90bo"}).on(f,((e,r)=>r)),m=e.createEvent({name:"saveReject",sid:"-64swis"}),p=e.createStore((()=>{}),{name:"$rejecter",sid:"eabbu7"}).on(m,((e,r)=>r)),v=e.createEffect((e=>new Promise(((r,t)=>{var n=setTimeout(r,e);f(n),m(t)}))),{name:"timeoutFx",sid:"7lc3mj"}),g=e.attach({and:{source:[l,p],effect:e=>{var[r,t]=e;t(),r&&clearTimeout(r)}},or:{name:"cleanupFx",sid:"pcn5jq"}});return e.guard({and:[{clock:n,source:c,filter:d,target:v}],or:{sid:"-w5qmwp"}}),a&&e.guard({and:[{clock:n,filter:d,target:s}],or:{sid:"-vpslni"}}),e.sample({and:[{clock:n,fn:()=>!0,target:u}],or:{sid:"-vaed34"}}),e.guard({and:[{clock:v.done,source:c,filter:u,target:v}],or:{sid:"-v73liy"}}),e.sample({and:[{clock:v.done,fn:()=>{},target:s}],or:{sid:"-urpcwu"}}),o&&(i&&e.sample({and:[{clock:o,target:s}],or:{sid:"-uanqf7"}}),u.on(o,(()=>!1)),e.sample({and:[{clock:o,target:g}],or:{sid:"6lcmyy"}})),{tick:s,isRunning:u}}},_={some:e=>e.some(Boolean),every:e=>e.every(Boolean)};var h={__proto__:null,pending:function(r){var{effects:t,domain:n,of:o="some"}=r;if(!e.is.domain(n,{sid:"97b92c"})&&!t)throw new TypeError("domain or effects should be passed");if("some"!==o&&"every"!==o)throw new TypeError('strategy parameter "of" can be "every" or "some". Passed: "'.concat(o,'"'));var a=null!=t?t:[],i=_[o];return n&&(a=[],n.onCreateEffect((e=>a.push(e)))),e.combine({and:[a.map((e=>e.pending)),i],or:{sid:"a37bj0"}})}};var w={__proto__:null,reset:function(e){var{clock:r,target:t}=e,n=Array.isArray(t)?t:[t],o=Array.isArray(r)?r:[r];n.forEach((e=>{e.reset.call(e,o)}))}};var j={__proto__:null,reshape:function(e){var{source:r,shape:t}=e,n={};for(var o in t)o in t&&function(){var e=t[o];n[o]=r.map((r=>{var t=e(r);return void 0===t?null:t}))}();return n}};var E={__proto__:null,snapshot:function(r){var{source:t,clock:n,fn:o=(e=>e)}=r,a=o(t.defaultState),i=n?e.sample({and:[t,n,o],or:{name:"onSnapshot",sid:"-auitd0"}}):e.sample({and:[{source:t,fn:o}],or:{name:"onSnapshot",sid:"-auir6n"}}),s=e.createStore(a,{name:"$snapshot",sid:"-7zyoaf"});return s.on(i,((e,r)=>r)),s}};var k={__proto__:null,some:function(r,t){var n,o=[],a=()=>!1;Array.isArray(r)?(o=r,a=t):Array.isArray(r.stores)&&(o=r.stores,a=r.predicate),n="function"==typeof a?a:e.is.store(a,{sid:"zbwu0l"})?a.map((e=>r=>e===r)):e=>e===a;var i=e.combine({and:[o],or:{name:"$values",sid:"-lv5do0"}}),s=n;return e.combine({and:[s,i,(e,r)=>r.some(e)],or:{sid:"-efc5w7"}})}};var x={__proto__:null,splitMap:function(r){var{source:t,cases:n}=r,o={},a=e.is.store(t,{name:"current",sid:"-htjkz7"})?t.updates:t;for(var i in n)i in n&&function(){var e=n[i];o[i]=a.filterMap(e),a=a.filter({fn:r=>!e(r)})}();return o.__=a,o}};var O={__proto__:null,spread:function(r){var{targets:t,source:n=e.createEvent({name:"source",sid:"-iel8gi"},{name:"source",sid:"-iel8gi"})}=r,o=function(r){if(r in t){var o=e.guard({and:[{source:n,filter:e=>"object"==typeof e&&null!==e&&r in e}],or:{name:"hasTargetKey",sid:"-gh83lo"}});e.is.store(t[r],{sid:"jliekw"})?t[r].on(o,((e,t)=>t[r])):e.sample({and:[{source:o,fn:e=>e[r],target:t[r]}],or:{sid:"lnzpe6"}})}};for(var a in t)o(a);return n}};var A={__proto__:null,status:function(r){var{effect:t,defaultValue:n="initial"}=r,o=e.createStore(n,{name:"$status",sid:"abrgim"});return o.on(t,(()=>"pending")).on(t.done,(()=>"done")).on(t.fail,(()=>"fail")),o}};var S={__proto__:null,throttle:function(r){var{source:t,timeout:n,target:o=e.createEvent({name:"target",sid:"cenyj5"},{name:"target",sid:"cenyj5"})}=r;if(!e.is.unit(t))throw new TypeError("source must be unit from effector");if("number"!=typeof n||n<0)throw new Error("timeout must be positive number or zero");var a=e.createEffect((()=>new Promise((e=>setTimeout(e,n)))),{name:"timerFx",sid:"uv7gwq"});return e.guard({and:[{source:t,filter:a.pending.map((e=>!e)),target:a}],or:{sid:"-iy4kn2"}}),e.sample({and:[{source:t,clock:a.done,target:o}],or:{sid:"-ija4mb"}}),o}},P=()=>Date.now();var z={__proto__:null,time:function(r){var{clock:t,getNow:n,initial:o}=r,a=null!=n?n:P,i=e.createEffect(a,{name:"readNowFx",sid:"459ysb"}),s=e.restore(i,null!=o?o:a(),{name:"$time",sid:"-ys9vce"});return e.forward({and:{from:t,to:i},or:{sid:"rdje9v"}}),s}};function T(e){if(e.__esModule)return e;var r=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var F=T({__proto__:null,combineEvents:function(o){var{events:a,reset:i,target:s=e.createEvent({name:"target",sid:"3pez5"},{name:"target",sid:"3pez5"})}=o;return e.is.unit(s)||n("target should be a unit"),i&&!e.is.unit(i)&&n("reset should be a unit"),e.withRegion(s,(()=>{var n=Object.keys(a),o=Array.isArray(a)?[...n].fill(""):{},u=e.createStore(n.length,{name:"$counter",sid:"-dszn9a"}),c=e.createStore(o,{name:"$results",sid:"boz3x7"});u.reset(e.sample({and:[s],or:{sid:"-8yzcn6"}})),c.reset(s),i&&(u.reset(e.sample({and:[i],or:{sid:"-72suil"}})),c.reset(i));var d=function(n){var o=e.createStore(!1,{name:"$isDone",sid:"ucs7nc"}).on(a[n],(()=>!0)).reset(s);i&&o.reset(i),u.on(o,(e=>e-1)),c.on(a[n],((e,o)=>{var a=Array.isArray(e)?[...e]:function(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?r(Object(o),!0).forEach((function(r){t(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))}))}return e}({},e);return a[n]=o,a}))};for(var f of n)d(f);e.guard({and:[{source:e.sample({and:[c,e.merge(Object.values(a),{name:"and",sid:"-l8g4ey"})],or:{name:"source",sid:"uf92v9"}}),filter:u.map((e=>0===e)),target:s}],or:{sid:"ciekm0"}})})),s}}),$=T(a),N=T(i),q=T(f),D=T(l),M=T(m),C=T(g),R=T(y),B=T(b),I=T(h),K=T(w),V=T(j),G=T(E),H=T(k),J=T(x),L=T(O),Q=T(A),U=T(S),W=T(z),X=F.combineEvents,Y=$.condition,Z=N.debounce,ee=q.debug,re=D.delay,te=M.every,ne=C.format,oe=R.inFlight,ae=B.interval,ie=I.pending,se=K.reset,ue=V.reshape,ce=G.snapshot,de=H.some,fe=J.splitMap,le=L.spread,me=Q.status,pe=U.throttle,ve=W.time,ge={combineEvents:X,condition:Y,debounce:Z,debug:ee,delay:re,every:te,format:ne,inFlight:oe,interval:ae,pending:ie,reset:se,reshape:ue,snapshot:ce,some:de,splitMap:fe,spread:le,status:me,throttle:pe,time:ve};exports.combineEvents=X,exports.condition=Y,exports.debounce=Z,exports.debug=ee,exports.default=ge,exports.delay=re,exports.every=te,exports.format=ne,exports.inFlight=oe,exports.interval=ae,exports.pending=ie,exports.reset=se,exports.reshape=ue,exports.snapshot=ce,exports.some=de,exports.splitMap=fe,exports.spread=le,exports.status=me,exports.throttle=pe,exports.time=ve; | ||
//# sourceMappingURL=patronum.cjs.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("effector")):"function"==typeof define&&define.amd?define(["exports","effector"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).patronum={},e.effector)}(this,(function(e,t){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=n(t);function o(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var a=o((function(e,t){function n(e){throw new Error(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.combineEvents=function({events:e,reset:t,target:o=(0,r.default.createEvent)({name:"target",sid:"3pez5"})}){r.default.is.unit(o)||n("target should be a unit");t&&!r.default.is.unit(t)&&n("reset should be a unit");return(0,r.default.withRegion)(o,(()=>{const n=Object.keys(e),a=Array.isArray(e)?[...n].fill(""):{},i=(0,r.default.createStore)(n.length,{name:"$counter",sid:"-dszn9a"}),s=(0,r.default.createStore)(a,{name:"$results",sid:"boz3x7"});i.reset((0,r.default.sample)({and:[o],or:{sid:"-8yzcn6"}})),s.reset(o),t&&(i.reset((0,r.default.sample)({and:[t],or:{sid:"-72suil"}})),s.reset(t));for(const a of n){const n=(0,r.default.createStore)(!1,{name:"$isDone",sid:"ucs7nc"}).on(e[a],(()=>!0)).reset(o);t&&n.reset(t),i.on(n,(e=>e-1)),s.on(e[a],((e,t)=>{const n=Array.isArray(e)?[...e]:{...e};return n[a]=t,n}))}(0,r.default.guard)({and:[{source:(0,r.default.sample)({and:[s,(0,r.default.merge)(Object.values(e),{name:"and",sid:"-l8g4ey"})],or:{name:"source",sid:"uf92v9"}}),filter:i.map((e=>0===e)),target:o}],or:{sid:"ciekm0"}})})),o}})),i=o((function(e,t){function n(e){return r.default.is.unit(e)?e.map((e=>!e)):t=>!e(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.condition=function({if:e,then:t,else:o,source:a=(0,r.default.createEvent)({name:"source",sid:"epke23"})}){const i=r.default.is.unit(e)||(s=e,"function"==typeof s)?e:t=>t===e;var s;t&&(0,r.default.guard)({and:[{source:a,filter:i,target:t}],or:{sid:"9tug3k"}});o&&(0,r.default.guard)({and:[{source:a,filter:n(i),target:o}],or:{sid:"a9shb1"}});return a}})),s=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=function({source:e,timeout:t,target:n}){if(!r.default.is.unit(e))throw new TypeError("source must be unit from effector");if(r.default.is.domain(e,{sid:"iu8yzo"}))throw new TypeError("source cannot be domain");if("number"!=typeof t||t<0||!Number.isFinite(t))throw new Error(`timeout must be positive number or zero. Received: "${t}"`);let o,a;const i=n??(0,r.default.createEvent)({name:"tick",sid:"-xw52dh"}),s=(0,r.default.createEffect)((e=>(clearTimeout(a),o&&o(),new Promise(((n,r)=>{o=r,a=setTimeout(n,t,e)})))),{name:"timerFx",sid:"m8kfsq"});return(0,r.default.forward)({and:{from:e,to:s},or:{sid:"k4foqk"}}),(0,r.default.forward)({and:{from:s.done.map((({result:e})=>e)),to:i},or:{sid:"k76npd"}}),i}})),u=o((function(e,t){function n(e){return r.default.is.store(e,{sid:"-j30z7b"})?"store":r.default.is.effect(e,{sid:"-j1dlf8"})?"effect":r.default.is.event(e,{sid:"-io6j6k"})?"event":r.default.is.domain(e,{sid:"-imj5eh"})?"domain":r.default.is.unit(e)?"unit":"unknown"}function o(e,t,n=""){const r=n+i(e);e.watch((e=>{console.info(`[${t}] ${r}`,e)}))}function a(e){o(e.done,"effect",i(e)+"."),o(e.fail,"effect",i(e)+".")}function i(e){return e.compositeName&&e.compositeName.fullName?e.compositeName.fullName:e.shortName?e.shortName:e.name?e.name:""}Object.defineProperty(t,"__esModule",{value:!0}),t.debug=function(...e){for(const t of e){const e=n(t);(r.default.is.store(t,{sid:"8mdztw"})||r.default.is.effect(t,{sid:"-gueih2"})||r.default.is.event(t,{sid:"-gueh0j"}))&&o(t,e),r.default.is.effect(t,{sid:"-jlpzbv"})&&a(t),r.default.is.domain(t,{sid:"-jjisyf"})&&(t.onCreateEvent((e=>o(e,"event"))),t.onCreateStore((e=>o(e,"store"))),t.onCreateEffect(a))}}})),d=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.delay=function({source:e,timeout:t,target:n=(0,r.default.createEvent)({name:"target",sid:"-z2vw3w"})}){if(!r.default.is.unit(e))throw new TypeError("source must be a unit from effector");if(!r.default.is.unit(n))throw new TypeError("target must be a unit from effector");const o=function(e){if(r.default.is.store(e,{sid:"-va560a"})||"function"==typeof e||"number"==typeof e)return e;throw new TypeError(`'timeout' argument must be a function, Store, or a number. Passed "${typeof e}"`)}(t),a=(0,r.default.createEffect)((({payload:e,milliseconds:t})=>new Promise((n=>{setTimeout(n,t,e)}))),{name:"timerFx",sid:"-584o7j"});return(0,r.default.sample)({and:[{source:(0,r.default.combine)({and:[{milliseconds:o}],or:{name:"source",sid:"9rbdjo"}}),clock:e,fn:({milliseconds:e},t)=>({payload:t,milliseconds:"function"==typeof e?e(t):e}),target:a}],or:{sid:"-wmj29s"}}),(0,r.default.forward)({and:{from:a.doneData,to:n},or:{sid:"-vsadmx"}}),n}})),f=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.every=function(e,t){let n,o=[],a=()=>!1;Array.isArray(e)?(o=e,a=t):Array.isArray(e.stores)&&(o=e.stores,a=e.predicate);i=a,n="function"==typeof i?a:r.default.is.store(a,{sid:"sid3ut"})?a.map((e=>t=>e===t)):e=>e===a;var i;const s=(0,r.default.combine)({and:[o],or:{name:"$values",sid:"h09uhg"}}),u=n;return(0,r.default.combine)({and:[u,s,(e,t)=>t.every(e)],or:{sid:"hfkdw9"}})}})),c=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.format=function(e,...t){return(0,r.default.combine)({and:[t,t=>e.reduce(((n,r,o)=>n.concat(function(e,t){return t===e.length-1}(e,o)?r:`${r}${function(e){if(Array.isArray(e))return e.map((e=>String(e))).join(", ");return String(e)}(t[o])}`)),"")],or:{sid:"-yrbthp"}})}})),l=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.inFlight=function({effects:e,domain:t}){if(t){const e=t.createStore(0,{name:"$inFlight",sid:"-y7vg7t"});return t.onCreateEffect((t=>{e.on(t,(e=>e+1)).on(t.finally,(e=>e-1))})),e}return(0,r.default.combine)({and:[e.map((e=>e.inFlight)),e=>e.reduce(((e,t)=>e+t),0)],or:{sid:"ubqxa7"}})}})),m=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.interval=function({timeout:e,start:t,stop:n,leading:o=!1,trailing:a=!1}){const i=(0,r.default.createEvent)({name:"tick",sid:"uo9p3s"}),s=(0,r.default.createStore)(!1,{name:"$isRunning",sid:"-wxesi8"}),u=function(e){if(r.default.is.store(e,{sid:"6p7767"}))return e;if("number"==typeof e)return(0,r.default.createStore)(e,{and:{name:"$timeout"},sid:"5hw6se"});throw new TypeError(`timeout parameter in interval method should be number or Store. "${typeof e}" was passed`)}(e),d=s.map((e=>!e)),f=(0,r.default.createEvent)({name:"saveTimeout",sid:"as5clk"}),c=(0,r.default.createStore)(null,{name:"$timeoutId",sid:"-bh90bo"}).on(f,((e,t)=>t)),l=(0,r.default.createEvent)({name:"saveReject",sid:"-64swis"}),m=(0,r.default.createStore)((()=>{}),{name:"$rejecter",sid:"eabbu7"}).on(l,((e,t)=>t)),p=(0,r.default.createEffect)((e=>new Promise(((t,n)=>{const r=setTimeout(t,e);f(r),l(n)}))),{name:"timeoutFx",sid:"7lc3mj"}),y=(0,r.default.attach)({and:{source:[c,m],effect:([e,t])=>{t(),e&&clearTimeout(e)}},or:{name:"cleanupFx",sid:"pcn5jq"}});(0,r.default.guard)({and:[{clock:t,source:u,filter:d,target:p}],or:{sid:"-w5qmwp"}}),o&&(0,r.default.guard)({and:[{clock:t,filter:d,target:i}],or:{sid:"-vpslni"}});(0,r.default.sample)({and:[{clock:t,fn:()=>!0,target:s}],or:{sid:"-vaed34"}}),(0,r.default.guard)({and:[{clock:p.done,source:u,filter:s,target:p}],or:{sid:"-v73liy"}}),(0,r.default.sample)({and:[{clock:p.done,fn:()=>{},target:i}],or:{sid:"-urpcwu"}}),n&&(a&&(0,r.default.sample)({and:[{clock:n,target:i}],or:{sid:"-uanqf7"}}),s.on(n,(()=>!1)),(0,r.default.sample)({and:[{clock:n,target:y}],or:{sid:"6lcmyy"}}));return{tick:i,isRunning:s}}})),p=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.pending=function({effects:e,domain:t,of:o="some"}){if(!r.default.is.domain(t,{sid:"97b92c"})&&!e)throw new TypeError("domain or effects should be passed");if("some"!==o&&"every"!==o)throw new TypeError(`strategy parameter "of" can be "every" or "some". Passed: "${o}"`);let a=e??[];const i=n[o];t&&(a=[],t.onCreateEffect((e=>a.push(e))));return(0,r.default.combine)({and:[a.map((e=>e.pending)),i],or:{sid:"a37bj0"}})};const n={some:e=>e.some(Boolean),every:e=>e.every(Boolean)}})),y=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reset=function({clock:e,target:t}){const n=Array.isArray(t)?t:[t],r=Array.isArray(e)?e:[e];n.forEach((e=>{e.reset.call(e,r)}))}})),b=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=function({source:e,shape:t}){const n={};for(const r in t)if(r in t){const o=t[r];n[r]=e.map((e=>{const t=o(e);return void 0===t?null:t}))}return n}})),v=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.snapshot=function({source:e,clock:t,fn:n=(e=>e)}){const o=n(e.defaultState),a=t?(0,r.default.sample)({and:[e,t,n],or:{name:"onSnapshot",sid:"-auitd0"}}):(0,r.default.sample)({and:[{source:e,fn:n}],or:{name:"onSnapshot",sid:"-auir6n"}}),i=(0,r.default.createStore)(o,{name:"$snapshot",sid:"-7zyoaf"});return i.on(a,((e,t)=>t)),i}})),g=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.some=function(e,t){let n,o=[],a=()=>!1;Array.isArray(e)?(o=e,a=t):Array.isArray(e.stores)&&(o=e.stores,a=e.predicate);i=a,n="function"==typeof i?a:r.default.is.store(a,{sid:"zbwu0l"})?a.map((e=>t=>e===t)):e=>e===a;var i;const s=(0,r.default.combine)({and:[o],or:{name:"$values",sid:"-lv5do0"}}),u=n;return(0,r.default.combine)({and:[u,s,(e,t)=>t.some(e)],or:{sid:"-efc5w7"}})}})),h=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.splitMap=function({source:e,cases:t}){const n={};let o=r.default.is.store(e,{name:"current",sid:"-htjkz7"})?e.updates:e;for(const e in t)if(e in t){const r=t[e];n[e]=o.filterMap(r),o=o.filter({fn:e=>!r(e)})}return n.__=o,n}})),w=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.spread=function({targets:e,source:t=(0,r.default.createEvent)({name:"source",sid:"-iel8gi"})}){for(const n in e)if(n in e){const o=(0,r.default.guard)({and:[{source:t,filter:e=>"object"==typeof e&&null!==e&&n in e}],or:{name:"hasTargetKey",sid:"-gh83lo"}});r.default.is.store(e[n],{sid:"jliekw"})?e[n].on(o,((e,t)=>t[n])):(0,r.default.sample)({and:[{source:o,fn:e=>e[n],target:e[n]}],or:{sid:"lnzpe6"}})}return t}})),j=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.status=function({effect:e,defaultValue:t="initial"}){const n=(0,r.default.createStore)(t,{name:"$status",sid:"abrgim"});return n.on(e,(()=>"pending")).on(e.done,(()=>"done")).on(e.fail,(()=>"fail")),n}})),_=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.throttle=function({source:e,timeout:t,target:n=(0,r.default.createEvent)({name:"target",sid:"cenyj5"})}){if(!r.default.is.unit(e))throw new TypeError("source must be unit from effector");if("number"!=typeof t||t<0)throw new Error("timeout must be positive number or zero");const o=(0,r.default.createEffect)((()=>new Promise((e=>setTimeout(e,t)))),{name:"timerFx",sid:"uv7gwq"});return(0,r.default.guard)({and:[{source:e,filter:o.pending.map((e=>!e)),target:o}],or:{sid:"-iy4kn2"}}),(0,r.default.sample)({and:[{source:e,clock:o.done,target:n}],or:{sid:"-ija4mb"}}),n}})),E=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.time=function({clock:e,getNow:t,initial:o}){const a=t??n,i=(0,r.default.createEffect)(a,{name:"readNowFx",sid:"459ysb"}),s=(0,r.default.restore)(i,o??a(),{name:"$time",sid:"-ys9vce"});return(0,r.default.forward)({and:{from:e,to:i},or:{sid:"rdje9v"}}),s};const n=()=>Date.now()})),k=a.combineEvents,P=i.condition,M=s.debounce,O=u.debug,$=d.delay,T=f.every,A=c.format,S=l.inFlight,x=m.interval,z=p.pending,F=y.reset,q=b.reshape,N=v.snapshot,C=g.some,R=h.splitMap,D=w.spread,B=j.status,I=_.throttle,K=E.time,V={combineEvents:k,condition:P,debounce:M,debug:O,delay:$,every:T,format:A,inFlight:S,interval:x,pending:z,reset:F,reshape:q,snapshot:N,some:C,splitMap:R,spread:D,status:B,throttle:I,time:K};e.combineEvents=k,e.condition=P,e.debounce=M,e.debug=O,e.default=V,e.delay=$,e.every=T,e.format=A,e.inFlight=S,e.interval=x,e.pending=z,e.reset=F,e.reshape=q,e.snapshot=N,e.some=C,e.splitMap=R,e.spread=D,e.status=B,e.throttle=I,e.time=K,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("effector")):"function"==typeof define&&define.amd?define(["exports","effector"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).patronum={},e.effector)}(this,(function(e,r){"use strict";function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function n(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function o(e){throw new Error(e)}function a(e){return r.is.unit(e)?e.map((e=>!e)):r=>!e(r)}var i={__proto__:null,condition:function(e){var{if:t,then:n,else:o,source:i=r.createEvent({name:"source",sid:"epke23"},{name:"source",sid:"epke23"})}=e,s=r.is.unit(t)||"function"==typeof t?t:e=>e===t;return n&&r.guard({and:[{source:i,filter:s,target:n}],or:{sid:"9tug3k"}}),o&&r.guard({and:[{source:i,filter:a(s),target:o}],or:{sid:"a9shb1"}}),i}};var s={__proto__:null,debounce:function(e){var t,n,{source:o,timeout:a,target:i}=e;if(!r.is.unit(o))throw new TypeError("source must be unit from effector");if(r.is.domain(o,{sid:"iu8yzo"}))throw new TypeError("source cannot be domain");if("number"!=typeof a||a<0||!Number.isFinite(a))throw new Error('timeout must be positive number or zero. Received: "'.concat(a,'"'));var s=null!=i?i:r.createEvent({name:"tick",sid:"-xw52dh"}),u=r.createEffect((e=>(clearTimeout(n),t&&t(),new Promise(((r,o)=>{t=o,n=setTimeout(r,a,e)})))),{name:"timerFx",sid:"m8kfsq"});return r.forward({and:{from:o,to:u},or:{sid:"k4foqk"}}),r.forward({and:{from:u.done.map((e=>{var{result:r}=e;return r})),to:s},or:{sid:"k76npd"}}),s}};function u(e){return r.is.store(e,{sid:"-j30z7b"})?"store":r.is.effect(e,{sid:"-j1dlf8"})?"effect":r.is.event(e,{sid:"-io6j6k"})?"event":r.is.domain(e,{sid:"-imj5eh"})?"domain":r.is.unit(e)?"unit":"unknown"}function c(e,r){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=t+f(e);e.watch((e=>{console.info("[".concat(r,"] ").concat(n),e)}))}function d(e){c(e.done,"effect",f(e)+"."),c(e.fail,"effect",f(e)+".")}function f(e){return e.compositeName&&e.compositeName.fullName?e.compositeName.fullName:e.shortName?e.shortName:e.name?e.name:""}var l={__proto__:null,debug:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(var o of t){var a=u(o);(r.is.store(o,{sid:"8mdztw"})||r.is.effect(o,{sid:"-gueih2"})||r.is.event(o,{sid:"-gueh0j"}))&&c(o,a),r.is.effect(o,{sid:"-jlpzbv"})&&d(o),r.is.domain(o,{sid:"-jjisyf"})&&(o.onCreateEvent((e=>c(e,"event"))),o.onCreateStore((e=>c(e,"store"))),o.onCreateEffect(d))}}};var m={__proto__:null,delay:function(e){var{source:t,timeout:n,target:o=r.createEvent({name:"target",sid:"-z2vw3w"},{name:"target",sid:"-z2vw3w"})}=e;if(!r.is.unit(t))throw new TypeError("source must be a unit from effector");if(!r.is.unit(o))throw new TypeError("target must be a unit from effector");var a=function(e){if(r.is.store(e,{sid:"-va560a"})||"function"==typeof e||"number"==typeof e)return e;throw new TypeError("'timeout' argument must be a function, Store, or a number. Passed \"".concat(typeof e,'"'))}(n),i=r.createEffect((e=>{var{payload:r,milliseconds:t}=e;return new Promise((e=>{setTimeout(e,t,r)}))}),{name:"timerFx",sid:"-584o7j"});return r.sample({and:[{source:r.combine({and:[{milliseconds:a}],or:{name:"source",sid:"9rbdjo"}}),clock:t,fn:(e,r)=>{var{milliseconds:t}=e;return{payload:r,milliseconds:"function"==typeof t?t(r):t}},target:i}],or:{sid:"-wmj29s"}}),r.forward({and:{from:i.doneData,to:o},or:{sid:"-vsadmx"}}),o}};var p={__proto__:null,every:function(e,t){var n,o=[],a=()=>!1;Array.isArray(e)?(o=e,a=t):Array.isArray(e.stores)&&(o=e.stores,a=e.predicate),n="function"==typeof a?a:r.is.store(a,{sid:"sid3ut"})?a.map((e=>r=>e===r)):e=>e===a;var i=r.combine({and:[o],or:{name:"$values",sid:"h09uhg"}}),s=n;return r.combine({and:[s,i,(e,r)=>r.every(e)],or:{sid:"hfkdw9"}})}};function v(e){return Array.isArray(e)?e.map((e=>String(e))).join(", "):String(e)}function y(e,r){return r===e.length-1}var g={__proto__:null,format:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return r.combine({and:[n,r=>e.reduce(((t,n,o)=>t.concat(y(e,o)?n:"".concat(n).concat(v(r[o])))),"")],or:{sid:"-yrbthp"}})}};var b={__proto__:null,inFlight:function(e){var{effects:t,domain:n}=e;if(n){var o=n.createStore(0,{name:"$inFlight",sid:"-y7vg7t"});return n.onCreateEffect((e=>{o.on(e,(e=>e+1)).on(e.finally,(e=>e-1))})),o}return r.combine({and:[t.map((e=>e.inFlight)),e=>e.reduce(((e,r)=>e+r),0)],or:{sid:"ubqxa7"}})}};var _={__proto__:null,interval:function(e){var{timeout:t,start:n,stop:o,leading:a=!1,trailing:i=!1}=e,s=r.createEvent({name:"tick",sid:"uo9p3s"}),u=r.createStore(!1,{name:"$isRunning",sid:"-wxesi8"}),c=function(e){if(r.is.store(e,{sid:"6p7767"}))return e;if("number"==typeof e)return r.createStore(e,{and:{name:"$timeout"},sid:"5hw6se"});throw new TypeError('timeout parameter in interval method should be number or Store. "'.concat(typeof e,'" was passed'))}(t),d=u.map((e=>!e)),f=r.createEvent({name:"saveTimeout",sid:"as5clk"}),l=r.createStore(null,{name:"$timeoutId",sid:"-bh90bo"}).on(f,((e,r)=>r)),m=r.createEvent({name:"saveReject",sid:"-64swis"}),p=r.createStore((()=>{}),{name:"$rejecter",sid:"eabbu7"}).on(m,((e,r)=>r)),v=r.createEffect((e=>new Promise(((r,t)=>{var n=setTimeout(r,e);f(n),m(t)}))),{name:"timeoutFx",sid:"7lc3mj"}),y=r.attach({and:{source:[l,p],effect:e=>{var[r,t]=e;t(),r&&clearTimeout(r)}},or:{name:"cleanupFx",sid:"pcn5jq"}});return r.guard({and:[{clock:n,source:c,filter:d,target:v}],or:{sid:"-w5qmwp"}}),a&&r.guard({and:[{clock:n,filter:d,target:s}],or:{sid:"-vpslni"}}),r.sample({and:[{clock:n,fn:()=>!0,target:u}],or:{sid:"-vaed34"}}),r.guard({and:[{clock:v.done,source:c,filter:u,target:v}],or:{sid:"-v73liy"}}),r.sample({and:[{clock:v.done,fn:()=>{},target:s}],or:{sid:"-urpcwu"}}),o&&(i&&r.sample({and:[{clock:o,target:s}],or:{sid:"-uanqf7"}}),u.on(o,(()=>!1)),r.sample({and:[{clock:o,target:y}],or:{sid:"6lcmyy"}})),{tick:s,isRunning:u}}},h={some:e=>e.some(Boolean),every:e=>e.every(Boolean)};var w={__proto__:null,pending:function(e){var{effects:t,domain:n,of:o="some"}=e;if(!r.is.domain(n,{sid:"97b92c"})&&!t)throw new TypeError("domain or effects should be passed");if("some"!==o&&"every"!==o)throw new TypeError('strategy parameter "of" can be "every" or "some". Passed: "'.concat(o,'"'));var a=null!=t?t:[],i=h[o];return n&&(a=[],n.onCreateEffect((e=>a.push(e)))),r.combine({and:[a.map((e=>e.pending)),i],or:{sid:"a37bj0"}})}};var j={__proto__:null,reset:function(e){var{clock:r,target:t}=e,n=Array.isArray(t)?t:[t],o=Array.isArray(r)?r:[r];n.forEach((e=>{e.reset.call(e,o)}))}};var E={__proto__:null,reshape:function(e){var{source:r,shape:t}=e,n={};for(var o in t)o in t&&function(){var e=t[o];n[o]=r.map((r=>{var t=e(r);return void 0===t?null:t}))}();return n}};var k={__proto__:null,snapshot:function(e){var{source:t,clock:n,fn:o=(e=>e)}=e,a=o(t.defaultState),i=n?r.sample({and:[t,n,o],or:{name:"onSnapshot",sid:"-auitd0"}}):r.sample({and:[{source:t,fn:o}],or:{name:"onSnapshot",sid:"-auir6n"}}),s=r.createStore(a,{name:"$snapshot",sid:"-7zyoaf"});return s.on(i,((e,r)=>r)),s}};var O={__proto__:null,some:function(e,t){var n,o=[],a=()=>!1;Array.isArray(e)?(o=e,a=t):Array.isArray(e.stores)&&(o=e.stores,a=e.predicate),n="function"==typeof a?a:r.is.store(a,{sid:"zbwu0l"})?a.map((e=>r=>e===r)):e=>e===a;var i=r.combine({and:[o],or:{name:"$values",sid:"-lv5do0"}}),s=n;return r.combine({and:[s,i,(e,r)=>r.some(e)],or:{sid:"-efc5w7"}})}};var A={__proto__:null,splitMap:function(e){var{source:t,cases:n}=e,o={},a=r.is.store(t,{name:"current",sid:"-htjkz7"})?t.updates:t;for(var i in n)i in n&&function(){var e=n[i];o[i]=a.filterMap(e),a=a.filter({fn:r=>!e(r)})}();return o.__=a,o}};var S={__proto__:null,spread:function(e){var{targets:t,source:n=r.createEvent({name:"source",sid:"-iel8gi"},{name:"source",sid:"-iel8gi"})}=e,o=function(e){if(e in t){var o=r.guard({and:[{source:n,filter:r=>"object"==typeof r&&null!==r&&e in r}],or:{name:"hasTargetKey",sid:"-gh83lo"}});r.is.store(t[e],{sid:"jliekw"})?t[e].on(o,((r,t)=>t[e])):r.sample({and:[{source:o,fn:r=>r[e],target:t[e]}],or:{sid:"lnzpe6"}})}};for(var a in t)o(a);return n}};var P={__proto__:null,status:function(e){var{effect:t,defaultValue:n="initial"}=e,o=r.createStore(n,{name:"$status",sid:"abrgim"});return o.on(t,(()=>"pending")).on(t.done,(()=>"done")).on(t.fail,(()=>"fail")),o}};var T={__proto__:null,throttle:function(e){var{source:t,timeout:n,target:o=r.createEvent({name:"target",sid:"cenyj5"},{name:"target",sid:"cenyj5"})}=e;if(!r.is.unit(t))throw new TypeError("source must be unit from effector");if("number"!=typeof n||n<0)throw new Error("timeout must be positive number or zero");var a=r.createEffect((()=>new Promise((e=>setTimeout(e,n)))),{name:"timerFx",sid:"uv7gwq"});return r.guard({and:[{source:t,filter:a.pending.map((e=>!e)),target:a}],or:{sid:"-iy4kn2"}}),r.sample({and:[{source:t,clock:a.done,target:o}],or:{sid:"-ija4mb"}}),o}},z=()=>Date.now();var x={__proto__:null,time:function(e){var{clock:t,getNow:n,initial:o}=e,a=null!=n?n:z,i=r.createEffect(a,{name:"readNowFx",sid:"459ysb"}),s=r.restore(i,null!=o?o:a(),{name:"$time",sid:"-ys9vce"});return r.forward({and:{from:t,to:i},or:{sid:"rdje9v"}}),s}};function F(e){if(e.__esModule)return e;var r=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),r}var $=F({__proto__:null,combineEvents:function(e){var{events:a,reset:i,target:s=r.createEvent({name:"target",sid:"3pez5"},{name:"target",sid:"3pez5"})}=e;return r.is.unit(s)||o("target should be a unit"),i&&!r.is.unit(i)&&o("reset should be a unit"),r.withRegion(s,(()=>{var e=Object.keys(a),o=Array.isArray(a)?[...e].fill(""):{},u=r.createStore(e.length,{name:"$counter",sid:"-dszn9a"}),c=r.createStore(o,{name:"$results",sid:"boz3x7"});u.reset(r.sample({and:[s],or:{sid:"-8yzcn6"}})),c.reset(s),i&&(u.reset(r.sample({and:[i],or:{sid:"-72suil"}})),c.reset(i));var d=function(e){var o=r.createStore(!1,{name:"$isDone",sid:"ucs7nc"}).on(a[e],(()=>!0)).reset(s);i&&o.reset(i),u.on(o,(e=>e-1)),c.on(a[e],((r,o)=>{var a=Array.isArray(r)?[...r]:function(e){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?t(Object(o),!0).forEach((function(r){n(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))}))}return e}({},r);return a[e]=o,a}))};for(var f of e)d(f);r.guard({and:[{source:r.sample({and:[c,r.merge(Object.values(a),{name:"and",sid:"-l8g4ey"})],or:{name:"source",sid:"uf92v9"}}),filter:u.map((e=>0===e)),target:s}],or:{sid:"ciekm0"}})})),s}}),N=F(i),q=F(s),D=F(l),M=F(m),C=F(p),R=F(g),B=F(b),I=F(_),K=F(w),V=F(j),G=F(E),H=F(k),J=F(O),L=F(A),Q=F(S),U=F(P),W=F(T),X=F(x),Y=$.combineEvents,Z=N.condition,ee=q.debounce,re=D.debug,te=M.delay,ne=C.every,oe=R.format,ae=B.inFlight,ie=I.interval,se=K.pending,ue=V.reset,ce=G.reshape,de=H.snapshot,fe=J.some,le=L.splitMap,me=Q.spread,pe=U.status,ve=W.throttle,ye=X.time,ge={combineEvents:Y,condition:Z,debounce:ee,debug:re,delay:te,every:ne,format:oe,inFlight:ae,interval:ie,pending:se,reset:ue,reshape:ce,snapshot:de,some:fe,splitMap:le,spread:me,status:pe,throttle:ve,time:ye};e.combineEvents=Y,e.condition=Z,e.debounce=ee,e.debug=re,e.default=ge,e.delay=te,e.every=ne,e.format=oe,e.inFlight=ae,e.interval=ie,e.pending=se,e.reset=ue,e.reshape=ce,e.snapshot=de,e.some=fe,e.splitMap=le,e.spread=me,e.status=pe,e.throttle=ve,e.time=ye,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=patronum.umd.js.map |
@@ -8,3 +8,3 @@ import { Event, Unit } from 'effector'; | ||
}; | ||
}): EventAsReturnType<Payload>; | ||
}): EventAsReturnType<Partial<Payload>>; | ||
export declare function spread<Source, Payload extends Source extends Unit<infer S> ? S : never>(config: { | ||
@@ -11,0 +11,0 @@ source: Source; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
242821
93
2312