Comparing version 1.4.1 to 1.5.0-next.0
@@ -18,3 +18,4 @@ { | ||
"patronum/status", | ||
"patronum/throttle" | ||
"patronum/throttle", | ||
"patronum/time" | ||
], | ||
@@ -36,4 +37,5 @@ "mapping": { | ||
"status": "status", | ||
"throttle": "throttle" | ||
"throttle": "throttle", | ||
"time": "time" | ||
} | ||
} |
@@ -17,1 +17,2 @@ export { combineEvents } from './combine-events'; | ||
export { throttle } from './throttle'; | ||
export { time } from './time'; |
@@ -17,1 +17,2 @@ module.exports.combineEvents = require('./combine-events').combineEvents; | ||
module.exports.throttle = require('./throttle').throttle; | ||
module.exports.time = require('./time').time; |
{ | ||
"name": "patronum", | ||
"version": "1.4.1", | ||
"version": "1.5.0-next.0", | ||
"description": "☄️ Effector utility library delivering modularity and convenience", | ||
@@ -108,4 +108,8 @@ "type": "module", | ||
"import": "./throttle/index.mjs" | ||
}, | ||
"./time": { | ||
"require": "./time/index.js", | ||
"import": "./time/index.mjs" | ||
} | ||
} | ||
} |
@@ -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 o(e,t,o){return e(o={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&o.path)}},o.exports),o.exports}var n=o((function(e,o){function n(e){throw new Error(e)}Object.defineProperty(o,"__esModule",{value:!0}),o.combineEvents=function({events:e,reset:o,target:r=(0,t.createEvent)({name:"target",sid:"3pez5"})}){t.is.unit(r)||n("target should be a unit");o&&!t.is.unit(o)&&n("reset should be a unit");return(0,t.withRegion)(r,(()=>{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:[r],or:{sid:"-8yzcn6"}})),a.reset(r),o&&(s.reset((0,t.sample)({and:[o],or:{sid:"-72suil"}})),a.reset(o));for(const i of n){const n=(0,t.createStore)(!1,{name:"$isDone",sid:"ucs7nc"}).on(e[i],(()=>!0)).reset(r);o&&n.reset(o),s.on(n,(e=>e-1)),a.on(e[i],((e,t)=>{const o=Array.isArray(e)?[...e]:{...e};return o[i]=t,o}))}(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:r}],or:{sid:"ciekm0"}})})),r}})),r=o((function(e,o){function n(e){return t.is.unit(e)?e.map((e=>!e)):t=>!e(t)}Object.defineProperty(o,"__esModule",{value:!0}),o.condition=function({if:e,then:o,else:r,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;o&&(0,t.guard)({and:[{source:i,filter:s,target:o}],or:{sid:"9tug3k"}});r&&(0,t.guard)({and:[{source:i,filter:n(s),target:r}],or:{sid:"a9shb1"}});return i}})),i=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.debounce=function({source:e,timeout:o,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 o||o<0||!Number.isFinite(o))throw new Error(`timeout must be positive number or zero. Received: "${o}"`);let r,i;const s=n??(0,t.createEvent)({name:"tick",sid:"-xw52dh"}),a=(0,t.createEffect)((e=>(clearTimeout(i),r&&r(),new Promise(((t,n)=>{r=n,i=setTimeout(t,o,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=o((function(e,o){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 r(e,t,o=""){const n=o+s(e);e.watch((e=>{console.info(`[${t}] ${n}`,e)}))}function i(e){r(e.done,"effect",s(e)+"."),r(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(o,"__esModule",{value:!0}),o.debug=function(...e){for(const o of e){const e=n(o);(t.is.store(o,{sid:"8mdztw"})||t.is.effect(o,{sid:"-gueih2"})||t.is.event(o,{sid:"-gueh0j"}))&&r(o,e),t.is.effect(o,{sid:"-jlpzbv"})&&i(o),t.is.domain(o,{sid:"-jjisyf"})&&(o.onCreateEvent((e=>r(e,"event"))),o.onCreateStore((e=>r(e,"store"))),o.onCreateEffect(i))}}})),a=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.delay=function({source:e,timeout:o,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 r=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}"`)}(o),i=(0,t.createEffect)((({payload:e,milliseconds:t})=>new Promise((o=>{setTimeout(o,t,e)}))),{name:"timerFx",sid:"-584o7j"});return(0,t.sample)({and:[{source:(0,t.combine)({and:[{milliseconds:r}],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=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.every=function({predicate:e,stores:o}){const n=(r=e,"function"==typeof r?e:t=>t===e);var r;return(0,t.combine)({and:[o,e=>e.every(n)],or:{sid:"fmonvn"}})}})),c=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.inFlight=function({effects:e,domain:o}){if(o){const e=o.createStore(0,{name:"$inFlight",sid:"-y7vg7t"});return o.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"}})}})),d=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.interval=function({timeout:e,start:o,stop:n,leading:r=!1,trailing:i=!1}){const s=(0,t.createEvent)({name:"tick",sid:"u782pl"}),a=(0,t.createStore)(!1,{name:"$isRunning",sid:"-xegewf"}),u=function(e){if(t.is.store(e,{sid:"-uanqf7"}))return e;if("number"==typeof e)return(0,t.createStore)(e,{and:{name:"$timeout"},sid:"-etvxaz"});throw new TypeError(`timeout parameter in interval method should be number or Store. "${typeof e}" was passed`)}(e),c=a.map((e=>!e));let d;const f=(0,t.createEffect)((e=>new Promise((t=>{d=setTimeout(t,e)}))),{name:"timeoutFx",sid:"-64yxt4"}),l=(0,t.createEffect)((()=>{clearTimeout(d)}),{name:"cleanupFx",sid:"ao8vbp"});(0,t.guard)({and:[{clock:o,source:u,filter:c,target:f}],or:{sid:"-wozfoc"}}),r&&(0,t.guard)({and:[{clock:o,filter:c,target:s}],or:{sid:"-w91ef5"}});(0,t.sample)({and:[{clock:o,fn:()=>!0,target:a}],or:{sid:"-w56ubc"}}),(0,t.guard)({and:[{clock:f.done,source:u,filter:a,target:f}],or:{sid:"-vqceal"}}),(0,t.sample)({and:[{clock:f.done,fn:()=>{},target:s}],or:{sid:"-vay5oh"}}),n&&(i&&(0,t.sample)({and:[{clock:n,target:s}],or:{sid:"-utwj6u"}}),a.on(n,(()=>!1)),(0,t.sample)({and:[{clock:n,target:l}],or:{sid:"-uq1z31"}}));return{tick:s,isRunning:a}}})),f=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.pending=function({effects:e,domain:o,of:r="some"}){if(!t.is.domain(o,{sid:"97b92c"})&&!e)throw new TypeError("domain or effects should be passed");if("some"!==r&&"every"!==r)throw new TypeError(`strategy parameter "of" can be "every" or "some". Passed: "${r}"`);let i=e??[];const s=n[r];o&&(i=[],o.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=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=function({source:e,shape:t}){const o={};for(const n in t)if(n in t){const r=t[n];o[n]=e.map((e=>{const t=r(e);return void 0===t?null:t}))}return o}})),m=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.snapshot=function({source:e,clock:o,fn:n=(e=>e)}){const r=n(e.defaultState),i=o?(0,t.sample)({and:[e,o,n],or:{name:"onSnapshot",sid:"-auitd0"}}):(0,t.sample)({and:[{source:e,fn:n}],or:{name:"onSnapshot",sid:"-auir6n"}}),s=(0,t.createStore)(r,{name:"$snapshot",sid:"-7zyoaf"});return s.on(i,((e,t)=>t)),s}})),p=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.some=function({predicate:e,stores:o}){const n=(r=e,"function"==typeof r?e:t=>t===e);var r;return(0,t.combine)({and:[o,e=>e.some(n)],or:{sid:"-g8roi6"}})}})),y=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.splitMap=function({source:e,cases:o}){const n={};let r=t.is.store(e,{name:"current",sid:"-htjkz7"})?e.updates:e;for(const e in o)if(e in o){const t=o[e];n[e]=r.filterMap(t),r=r.filter({fn:e=>!t(e)})}return n.__=r,n}})),b=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.spread=function({targets:e,source:o=(0,t.createEvent)({name:"source",sid:"-iel8gi"})}){for(const n in e)if(n in e){const r=(0,t.guard)({and:[{source:o,filter:e=>"object"==typeof e&&null!==e&&n in e}],or:{name:"hasTargetKey",sid:"-gh83lo"}});(0,t.sample)({and:[{source:r,fn:e=>e[n],target:e[n]}],or:{sid:"l959bp"}})}return o}})),g=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.status=function({effect:e,defaultValue:o="initial"}){const n=(0,t.createStore)(o,{name:"$status",sid:"abrgim"});return n.on(e,(()=>"pending")).on(e.done,(()=>"done")).on(e.fail,(()=>"fail")),n}})),v=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.throttle=function({source:e,timeout:o,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 o||o<0)throw new Error("timeout must be positive number or zero");const r=(0,t.createEffect)((()=>new Promise((e=>setTimeout(e,o)))),{name:"timerFx",sid:"uv7gwq"});return(0,t.guard)({and:[{source:e,filter:r.pending.map((e=>!e)),target:r}],or:{sid:"-iy4kn2"}}),(0,t.sample)({and:[{source:e,clock:r.done,target:n}],or:{sid:"-ija4mb"}}),n}})),h=n.combineEvents,w=r.condition,j=i.debounce,_=s.debug,x=a.delay,E=u.every,k=c.inFlight,P=d.interval,M=f.pending,O=l.reshape,z=m.snapshot,T=p.some,S=y.splitMap,$=b.spread,F=g.status,q=v.throttle,N={combineEvents:h,condition:w,debounce:j,debug:_,delay:x,every:E,inFlight:k,interval:P,pending:M,reshape:O,snapshot:z,some:T,splitMap:S,spread:$,status:F,throttle:q};exports.combineEvents=h,exports.condition=w,exports.debounce=j,exports.debug=_,exports.default=N,exports.delay=x,exports.every=E,exports.inFlight=k,exports.interval=P,exports.pending=M,exports.reshape=O,exports.snapshot=z,exports.some=T,exports.splitMap=S,exports.spread=$,exports.status=F,exports.throttle=q; | ||
"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 o(e,t,o){return e(o={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&o.path)}},o.exports),o.exports}var n=o((function(e,o){function n(e){throw new Error(e)}Object.defineProperty(o,"__esModule",{value:!0}),o.combineEvents=function({events:e,reset:o,target:r=(0,t.createEvent)({name:"target",sid:"3pez5"})}){t.is.unit(r)||n("target should be a unit");o&&!t.is.unit(o)&&n("reset should be a unit");return(0,t.withRegion)(r,(()=>{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:[r],or:{sid:"-8yzcn6"}})),a.reset(r),o&&(s.reset((0,t.sample)({and:[o],or:{sid:"-72suil"}})),a.reset(o));for(const i of n){const n=(0,t.createStore)(!1,{name:"$isDone",sid:"ucs7nc"}).on(e[i],(()=>!0)).reset(r);o&&n.reset(o),s.on(n,(e=>e-1)),a.on(e[i],((e,t)=>{const o=Array.isArray(e)?[...e]:{...e};return o[i]=t,o}))}(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:r}],or:{sid:"ciekm0"}})})),r}})),r=o((function(e,o){function n(e){return t.is.unit(e)?e.map((e=>!e)):t=>!e(t)}Object.defineProperty(o,"__esModule",{value:!0}),o.condition=function({if:e,then:o,else:r,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;o&&(0,t.guard)({and:[{source:i,filter:s,target:o}],or:{sid:"9tug3k"}});r&&(0,t.guard)({and:[{source:i,filter:n(s),target:r}],or:{sid:"a9shb1"}});return i}})),i=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.debounce=function({source:e,timeout:o,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 o||o<0||!Number.isFinite(o))throw new Error(`timeout must be positive number or zero. Received: "${o}"`);let r,i;const s=n??(0,t.createEvent)({name:"tick",sid:"-xw52dh"}),a=(0,t.createEffect)((e=>(clearTimeout(i),r&&r(),new Promise(((t,n)=>{r=n,i=setTimeout(t,o,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=o((function(e,o){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 r(e,t,o=""){const n=o+s(e);e.watch((e=>{console.info(`[${t}] ${n}`,e)}))}function i(e){r(e.done,"effect",s(e)+"."),r(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(o,"__esModule",{value:!0}),o.debug=function(...e){for(const o of e){const e=n(o);(t.is.store(o,{sid:"8mdztw"})||t.is.effect(o,{sid:"-gueih2"})||t.is.event(o,{sid:"-gueh0j"}))&&r(o,e),t.is.effect(o,{sid:"-jlpzbv"})&&i(o),t.is.domain(o,{sid:"-jjisyf"})&&(o.onCreateEvent((e=>r(e,"event"))),o.onCreateStore((e=>r(e,"store"))),o.onCreateEffect(i))}}})),a=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.delay=function({source:e,timeout:o,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 r=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}"`)}(o),i=(0,t.createEffect)((({payload:e,milliseconds:t})=>new Promise((o=>{setTimeout(o,t,e)}))),{name:"timerFx",sid:"-584o7j"});return(0,t.sample)({and:[{source:(0,t.combine)({and:[{milliseconds:r}],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=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.every=function({predicate:e,stores:o}){const n=(r=e,"function"==typeof r?e:t=>t===e);var r;return(0,t.combine)({and:[o,e=>e.every(n)],or:{sid:"fmonvn"}})}})),c=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.inFlight=function({effects:e,domain:o}){if(o){const e=o.createStore(0,{name:"$inFlight",sid:"-y7vg7t"});return o.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"}})}})),d=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.interval=function({timeout:e,start:o,stop:n,leading:r=!1,trailing:i=!1}){const s=(0,t.createEvent)({name:"tick",sid:"u782pl"}),a=(0,t.createStore)(!1,{name:"$isRunning",sid:"-xegewf"}),u=function(e){if(t.is.store(e,{sid:"-uanqf7"}))return e;if("number"==typeof e)return(0,t.createStore)(e,{and:{name:"$timeout"},sid:"-etvxaz"});throw new TypeError(`timeout parameter in interval method should be number or Store. "${typeof e}" was passed`)}(e),c=a.map((e=>!e));let d;const f=(0,t.createEffect)((e=>new Promise((t=>{d=setTimeout(t,e)}))),{name:"timeoutFx",sid:"-64yxt4"}),m=(0,t.createEffect)((()=>{clearTimeout(d)}),{name:"cleanupFx",sid:"ao8vbp"});(0,t.guard)({and:[{clock:o,source:u,filter:c,target:f}],or:{sid:"-wozfoc"}}),r&&(0,t.guard)({and:[{clock:o,filter:c,target:s}],or:{sid:"-w91ef5"}});(0,t.sample)({and:[{clock:o,fn:()=>!0,target:a}],or:{sid:"-w56ubc"}}),(0,t.guard)({and:[{clock:f.done,source:u,filter:a,target:f}],or:{sid:"-vqceal"}}),(0,t.sample)({and:[{clock:f.done,fn:()=>{},target:s}],or:{sid:"-vay5oh"}}),n&&(i&&(0,t.sample)({and:[{clock:n,target:s}],or:{sid:"-utwj6u"}}),a.on(n,(()=>!1)),(0,t.sample)({and:[{clock:n,target:m}],or:{sid:"-uq1z31"}}));return{tick:s,isRunning:a}}})),f=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.pending=function({effects:e,domain:o,of:r="some"}){if(!t.is.domain(o,{sid:"97b92c"})&&!e)throw new TypeError("domain or effects should be passed");if("some"!==r&&"every"!==r)throw new TypeError(`strategy parameter "of" can be "every" or "some". Passed: "${r}"`);let i=e??[];const s=n[r];o&&(i=[],o.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)}})),m=o((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=function({source:e,shape:t}){const o={};for(const n in t)if(n in t){const r=t[n];o[n]=e.map((e=>{const t=r(e);return void 0===t?null:t}))}return o}})),l=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.snapshot=function({source:e,clock:o,fn:n=(e=>e)}){const r=n(e.defaultState),i=o?(0,t.sample)({and:[e,o,n],or:{name:"onSnapshot",sid:"-auitd0"}}):(0,t.sample)({and:[{source:e,fn:n}],or:{name:"onSnapshot",sid:"-auir6n"}}),s=(0,t.createStore)(r,{name:"$snapshot",sid:"-7zyoaf"});return s.on(i,((e,t)=>t)),s}})),p=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.some=function({predicate:e,stores:o}){const n=(r=e,"function"==typeof r?e:t=>t===e);var r;return(0,t.combine)({and:[o,e=>e.some(n)],or:{sid:"-g8roi6"}})}})),y=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.splitMap=function({source:e,cases:o}){const n={};let r=t.is.store(e,{name:"current",sid:"-htjkz7"})?e.updates:e;for(const e in o)if(e in o){const t=o[e];n[e]=r.filterMap(t),r=r.filter({fn:e=>!t(e)})}return n.__=r,n}})),b=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.spread=function({targets:e,source:o=(0,t.createEvent)({name:"source",sid:"-iel8gi"})}){for(const n in e)if(n in e){const r=(0,t.guard)({and:[{source:o,filter:e=>"object"==typeof e&&null!==e&&n in e}],or:{name:"hasTargetKey",sid:"-gh83lo"}});(0,t.sample)({and:[{source:r,fn:e=>e[n],target:e[n]}],or:{sid:"l959bp"}})}return o}})),v=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.status=function({effect:e,defaultValue:o="initial"}){const n=(0,t.createStore)(o,{name:"$status",sid:"abrgim"});return n.on(e,(()=>"pending")).on(e.done,(()=>"done")).on(e.fail,(()=>"fail")),n}})),g=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.throttle=function({source:e,timeout:o,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 o||o<0)throw new Error("timeout must be positive number or zero");const r=(0,t.createEffect)((()=>new Promise((e=>setTimeout(e,o)))),{name:"timerFx",sid:"uv7gwq"});return(0,t.guard)({and:[{source:e,filter:r.pending.map((e=>!e)),target:r}],or:{sid:"-iy4kn2"}}),(0,t.sample)({and:[{source:e,clock:r.done,target:n}],or:{sid:"-ija4mb"}}),n}})),h=o((function(e,o){Object.defineProperty(o,"__esModule",{value:!0}),o.time=function({clock:e,getNow:o,initial:r}){const i=o??n,s=(0,t.createEffect)(i,{name:"readNowFx",sid:"459ysb"}),a=(0,t.restore)(s,r??i(),{name:"$time",sid:"-ys9vce"});return(0,t.forward)({and:{from:e,to:s},or:{sid:"rdje9v"}}),a};const n=()=>Date.now()})),w=n.combineEvents,j=r.condition,_=i.debounce,x=s.debug,E=a.delay,k=u.every,P=c.inFlight,M=d.interval,O=f.pending,z=m.reshape,T=l.snapshot,$=p.some,S=y.splitMap,F=b.spread,q=v.status,N=g.throttle,C=h.time,A={combineEvents:w,condition:j,debounce:_,debug:x,delay:E,every:k,inFlight:P,interval:M,pending:O,reshape:z,snapshot:T,some:$,splitMap:S,spread:F,status:q,throttle:N,time:C};exports.combineEvents=w,exports.condition=j,exports.debounce=_,exports.debug=x,exports.default=A,exports.delay=E,exports.every=k,exports.inFlight=P,exports.interval=M,exports.pending=O,exports.reshape=z,exports.snapshot=T,exports.some=$,exports.splitMap=S,exports.spread=F,exports.status=q,exports.throttle=N,exports.time=C; | ||
//# 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 o=n(t);function r(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=r((function(e,t){function n(e){throw new Error(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.combineEvents=function({events:e,reset:t,target:r=(0,o.default.createEvent)({name:"target",sid:"3pez5"})}){o.default.is.unit(r)||n("target should be a unit");t&&!o.default.is.unit(t)&&n("reset should be a unit");return(0,o.default.withRegion)(r,(()=>{const n=Object.keys(e),a=Array.isArray(e)?[...n].fill(""):{},i=(0,o.default.createStore)(n.length,{name:"$counter",sid:"-dszn9a"}),u=(0,o.default.createStore)(a,{name:"$results",sid:"boz3x7"});i.reset((0,o.default.sample)({and:[r],or:{sid:"-8yzcn6"}})),u.reset(r),t&&(i.reset((0,o.default.sample)({and:[t],or:{sid:"-72suil"}})),u.reset(t));for(const a of n){const n=(0,o.default.createStore)(!1,{name:"$isDone",sid:"ucs7nc"}).on(e[a],(()=>!0)).reset(r);t&&n.reset(t),i.on(n,(e=>e-1)),u.on(e[a],((e,t)=>{const n=Array.isArray(e)?[...e]:{...e};return n[a]=t,n}))}(0,o.default.guard)({and:[{source:(0,o.default.sample)({and:[u,(0,o.default.merge)(Object.values(e),{name:"and",sid:"-l8g4ey"})],or:{name:"source",sid:"uf92v9"}}),filter:i.map((e=>0===e)),target:r}],or:{sid:"ciekm0"}})})),r}})),i=r((function(e,t){function n(e){return o.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:r,source:a=(0,o.default.createEvent)({name:"source",sid:"epke23"})}){const i=o.default.is.unit(e)||(u=e,"function"==typeof u)?e:t=>t===e;var u;t&&(0,o.default.guard)({and:[{source:a,filter:i,target:t}],or:{sid:"9tug3k"}});r&&(0,o.default.guard)({and:[{source:a,filter:n(i),target:r}],or:{sid:"a9shb1"}});return a}})),u=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=function({source:e,timeout:t,target:n}){if(!o.default.is.unit(e))throw new TypeError("source must be unit from effector");if(o.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 r,a;const i=n??(0,o.default.createEvent)({name:"tick",sid:"-xw52dh"}),u=(0,o.default.createEffect)((e=>(clearTimeout(a),r&&r(),new Promise(((n,o)=>{r=o,a=setTimeout(n,t,e)})))),{name:"timerFx",sid:"m8kfsq"});return(0,o.default.forward)({and:{from:e,to:u},or:{sid:"k4foqk"}}),(0,o.default.forward)({and:{from:u.done.map((({result:e})=>e)),to:i},or:{sid:"k76npd"}}),i}})),s=r((function(e,t){function n(e){return o.default.is.store(e,{sid:"-j30z7b"})?"store":o.default.is.effect(e,{sid:"-j1dlf8"})?"effect":o.default.is.event(e,{sid:"-io6j6k"})?"event":o.default.is.domain(e,{sid:"-imj5eh"})?"domain":o.default.is.unit(e)?"unit":"unknown"}function r(e,t,n=""){const o=n+i(e);e.watch((e=>{console.info(`[${t}] ${o}`,e)}))}function a(e){r(e.done,"effect",i(e)+"."),r(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);(o.default.is.store(t,{sid:"8mdztw"})||o.default.is.effect(t,{sid:"-gueih2"})||o.default.is.event(t,{sid:"-gueh0j"}))&&r(t,e),o.default.is.effect(t,{sid:"-jlpzbv"})&&a(t),o.default.is.domain(t,{sid:"-jjisyf"})&&(t.onCreateEvent((e=>r(e,"event"))),t.onCreateStore((e=>r(e,"store"))),t.onCreateEffect(a))}}})),d=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.delay=function({source:e,timeout:t,target:n=(0,o.default.createEvent)({name:"target",sid:"-z2vw3w"})}){if(!o.default.is.unit(e))throw new TypeError("source must be a unit from effector");if(!o.default.is.unit(n))throw new TypeError("target must be a unit from effector");const r=function(e){if(o.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,o.default.createEffect)((({payload:e,milliseconds:t})=>new Promise((n=>{setTimeout(n,t,e)}))),{name:"timerFx",sid:"-584o7j"});return(0,o.default.sample)({and:[{source:(0,o.default.combine)({and:[{milliseconds:r}],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,o.default.forward)({and:{from:a.doneData,to:n},or:{sid:"-vsadmx"}}),n}})),f=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.every=function({predicate:e,stores:t}){const n=(r=e,"function"==typeof r?e:t=>t===e);var r;return(0,o.default.combine)({and:[t,e=>e.every(n)],or:{sid:"fmonvn"}})}})),c=r((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,o.default.combine)({and:[e.map((e=>e.inFlight)),e=>e.reduce(((e,t)=>e+t),0)],or:{sid:"ubqxa7"}})}})),l=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.interval=function({timeout:e,start:t,stop:n,leading:r=!1,trailing:a=!1}){const i=(0,o.default.createEvent)({name:"tick",sid:"u782pl"}),u=(0,o.default.createStore)(!1,{name:"$isRunning",sid:"-xegewf"}),s=function(e){if(o.default.is.store(e,{sid:"-uanqf7"}))return e;if("number"==typeof e)return(0,o.default.createStore)(e,{and:{name:"$timeout"},sid:"-etvxaz"});throw new TypeError(`timeout parameter in interval method should be number or Store. "${typeof e}" was passed`)}(e),d=u.map((e=>!e));let f;const c=(0,o.default.createEffect)((e=>new Promise((t=>{f=setTimeout(t,e)}))),{name:"timeoutFx",sid:"-64yxt4"}),l=(0,o.default.createEffect)((()=>{clearTimeout(f)}),{name:"cleanupFx",sid:"ao8vbp"});(0,o.default.guard)({and:[{clock:t,source:s,filter:d,target:c}],or:{sid:"-wozfoc"}}),r&&(0,o.default.guard)({and:[{clock:t,filter:d,target:i}],or:{sid:"-w91ef5"}});(0,o.default.sample)({and:[{clock:t,fn:()=>!0,target:u}],or:{sid:"-w56ubc"}}),(0,o.default.guard)({and:[{clock:c.done,source:s,filter:u,target:c}],or:{sid:"-vqceal"}}),(0,o.default.sample)({and:[{clock:c.done,fn:()=>{},target:i}],or:{sid:"-vay5oh"}}),n&&(a&&(0,o.default.sample)({and:[{clock:n,target:i}],or:{sid:"-utwj6u"}}),u.on(n,(()=>!1)),(0,o.default.sample)({and:[{clock:n,target:l}],or:{sid:"-uq1z31"}}));return{tick:i,isRunning:u}}})),m=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.pending=function({effects:e,domain:t,of:r="some"}){if(!o.default.is.domain(t,{sid:"97b92c"})&&!e)throw new TypeError("domain or effects should be passed");if("some"!==r&&"every"!==r)throw new TypeError(`strategy parameter "of" can be "every" or "some". Passed: "${r}"`);let a=e??[];const i=n[r];t&&(a=[],t.onCreateEffect((e=>a.push(e))));return(0,o.default.combine)({and:[a.map((e=>e.pending)),i],or:{sid:"a37bj0"}})};const n={some:e=>e.some(Boolean),every:e=>e.every(Boolean)}})),p=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=function({source:e,shape:t}){const n={};for(const o in t)if(o in t){const r=t[o];n[o]=e.map((e=>{const t=r(e);return void 0===t?null:t}))}return n}})),y=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.snapshot=function({source:e,clock:t,fn:n=(e=>e)}){const r=n(e.defaultState),a=t?(0,o.default.sample)({and:[e,t,n],or:{name:"onSnapshot",sid:"-auitd0"}}):(0,o.default.sample)({and:[{source:e,fn:n}],or:{name:"onSnapshot",sid:"-auir6n"}}),i=(0,o.default.createStore)(r,{name:"$snapshot",sid:"-7zyoaf"});return i.on(a,((e,t)=>t)),i}})),b=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.some=function({predicate:e,stores:t}){const n=(r=e,"function"==typeof r?e:t=>t===e);var r;return(0,o.default.combine)({and:[t,e=>e.some(n)],or:{sid:"-g8roi6"}})}})),g=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.splitMap=function({source:e,cases:t}){const n={};let r=o.default.is.store(e,{name:"current",sid:"-htjkz7"})?e.updates:e;for(const e in t)if(e in t){const o=t[e];n[e]=r.filterMap(o),r=r.filter({fn:e=>!o(e)})}return n.__=r,n}})),v=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.spread=function({targets:e,source:t=(0,o.default.createEvent)({name:"source",sid:"-iel8gi"})}){for(const n in e)if(n in e){const r=(0,o.default.guard)({and:[{source:t,filter:e=>"object"==typeof e&&null!==e&&n in e}],or:{name:"hasTargetKey",sid:"-gh83lo"}});(0,o.default.sample)({and:[{source:r,fn:e=>e[n],target:e[n]}],or:{sid:"l959bp"}})}return t}})),h=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.status=function({effect:e,defaultValue:t="initial"}){const n=(0,o.default.createStore)(t,{name:"$status",sid:"abrgim"});return n.on(e,(()=>"pending")).on(e.done,(()=>"done")).on(e.fail,(()=>"fail")),n}})),w=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.throttle=function({source:e,timeout:t,target:n=(0,o.default.createEvent)({name:"target",sid:"cenyj5"})}){if(!o.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 r=(0,o.default.createEffect)((()=>new Promise((e=>setTimeout(e,t)))),{name:"timerFx",sid:"uv7gwq"});return(0,o.default.guard)({and:[{source:e,filter:r.pending.map((e=>!e)),target:r}],or:{sid:"-iy4kn2"}}),(0,o.default.sample)({and:[{source:e,clock:r.done,target:n}],or:{sid:"-ija4mb"}}),n}})),j=a.combineEvents,_=i.condition,E=u.debounce,k=s.debug,P=d.delay,M=f.every,O=c.inFlight,x=l.interval,T=m.pending,z=p.reshape,S=y.snapshot,$=b.some,F=g.splitMap,q=v.spread,N=h.status,C=w.throttle,A={combineEvents:j,condition:_,debounce:E,debug:k,delay:P,every:M,inFlight:O,interval:x,pending:T,reshape:z,snapshot:S,some:$,splitMap:F,spread:q,status:N,throttle:C};e.combineEvents=j,e.condition=_,e.debounce=E,e.debug=k,e.default=A,e.delay=P,e.every=M,e.inFlight=O,e.interval=x,e.pending=T,e.reshape=z,e.snapshot=S,e.some=$,e.splitMap=F,e.spread=q,e.status=N,e.throttle=C,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!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 o=n(t);function r(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=r((function(e,t){function n(e){throw new Error(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.combineEvents=function({events:e,reset:t,target:r=(0,o.default.createEvent)({name:"target",sid:"3pez5"})}){o.default.is.unit(r)||n("target should be a unit");t&&!o.default.is.unit(t)&&n("reset should be a unit");return(0,o.default.withRegion)(r,(()=>{const n=Object.keys(e),a=Array.isArray(e)?[...n].fill(""):{},i=(0,o.default.createStore)(n.length,{name:"$counter",sid:"-dszn9a"}),u=(0,o.default.createStore)(a,{name:"$results",sid:"boz3x7"});i.reset((0,o.default.sample)({and:[r],or:{sid:"-8yzcn6"}})),u.reset(r),t&&(i.reset((0,o.default.sample)({and:[t],or:{sid:"-72suil"}})),u.reset(t));for(const a of n){const n=(0,o.default.createStore)(!1,{name:"$isDone",sid:"ucs7nc"}).on(e[a],(()=>!0)).reset(r);t&&n.reset(t),i.on(n,(e=>e-1)),u.on(e[a],((e,t)=>{const n=Array.isArray(e)?[...e]:{...e};return n[a]=t,n}))}(0,o.default.guard)({and:[{source:(0,o.default.sample)({and:[u,(0,o.default.merge)(Object.values(e),{name:"and",sid:"-l8g4ey"})],or:{name:"source",sid:"uf92v9"}}),filter:i.map((e=>0===e)),target:r}],or:{sid:"ciekm0"}})})),r}})),i=r((function(e,t){function n(e){return o.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:r,source:a=(0,o.default.createEvent)({name:"source",sid:"epke23"})}){const i=o.default.is.unit(e)||(u=e,"function"==typeof u)?e:t=>t===e;var u;t&&(0,o.default.guard)({and:[{source:a,filter:i,target:t}],or:{sid:"9tug3k"}});r&&(0,o.default.guard)({and:[{source:a,filter:n(i),target:r}],or:{sid:"a9shb1"}});return a}})),u=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=function({source:e,timeout:t,target:n}){if(!o.default.is.unit(e))throw new TypeError("source must be unit from effector");if(o.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 r,a;const i=n??(0,o.default.createEvent)({name:"tick",sid:"-xw52dh"}),u=(0,o.default.createEffect)((e=>(clearTimeout(a),r&&r(),new Promise(((n,o)=>{r=o,a=setTimeout(n,t,e)})))),{name:"timerFx",sid:"m8kfsq"});return(0,o.default.forward)({and:{from:e,to:u},or:{sid:"k4foqk"}}),(0,o.default.forward)({and:{from:u.done.map((({result:e})=>e)),to:i},or:{sid:"k76npd"}}),i}})),s=r((function(e,t){function n(e){return o.default.is.store(e,{sid:"-j30z7b"})?"store":o.default.is.effect(e,{sid:"-j1dlf8"})?"effect":o.default.is.event(e,{sid:"-io6j6k"})?"event":o.default.is.domain(e,{sid:"-imj5eh"})?"domain":o.default.is.unit(e)?"unit":"unknown"}function r(e,t,n=""){const o=n+i(e);e.watch((e=>{console.info(`[${t}] ${o}`,e)}))}function a(e){r(e.done,"effect",i(e)+"."),r(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);(o.default.is.store(t,{sid:"8mdztw"})||o.default.is.effect(t,{sid:"-gueih2"})||o.default.is.event(t,{sid:"-gueh0j"}))&&r(t,e),o.default.is.effect(t,{sid:"-jlpzbv"})&&a(t),o.default.is.domain(t,{sid:"-jjisyf"})&&(t.onCreateEvent((e=>r(e,"event"))),t.onCreateStore((e=>r(e,"store"))),t.onCreateEffect(a))}}})),d=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.delay=function({source:e,timeout:t,target:n=(0,o.default.createEvent)({name:"target",sid:"-z2vw3w"})}){if(!o.default.is.unit(e))throw new TypeError("source must be a unit from effector");if(!o.default.is.unit(n))throw new TypeError("target must be a unit from effector");const r=function(e){if(o.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,o.default.createEffect)((({payload:e,milliseconds:t})=>new Promise((n=>{setTimeout(n,t,e)}))),{name:"timerFx",sid:"-584o7j"});return(0,o.default.sample)({and:[{source:(0,o.default.combine)({and:[{milliseconds:r}],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,o.default.forward)({and:{from:a.doneData,to:n},or:{sid:"-vsadmx"}}),n}})),f=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.every=function({predicate:e,stores:t}){const n=(r=e,"function"==typeof r?e:t=>t===e);var r;return(0,o.default.combine)({and:[t,e=>e.every(n)],or:{sid:"fmonvn"}})}})),c=r((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,o.default.combine)({and:[e.map((e=>e.inFlight)),e=>e.reduce(((e,t)=>e+t),0)],or:{sid:"ubqxa7"}})}})),l=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.interval=function({timeout:e,start:t,stop:n,leading:r=!1,trailing:a=!1}){const i=(0,o.default.createEvent)({name:"tick",sid:"u782pl"}),u=(0,o.default.createStore)(!1,{name:"$isRunning",sid:"-xegewf"}),s=function(e){if(o.default.is.store(e,{sid:"-uanqf7"}))return e;if("number"==typeof e)return(0,o.default.createStore)(e,{and:{name:"$timeout"},sid:"-etvxaz"});throw new TypeError(`timeout parameter in interval method should be number or Store. "${typeof e}" was passed`)}(e),d=u.map((e=>!e));let f;const c=(0,o.default.createEffect)((e=>new Promise((t=>{f=setTimeout(t,e)}))),{name:"timeoutFx",sid:"-64yxt4"}),l=(0,o.default.createEffect)((()=>{clearTimeout(f)}),{name:"cleanupFx",sid:"ao8vbp"});(0,o.default.guard)({and:[{clock:t,source:s,filter:d,target:c}],or:{sid:"-wozfoc"}}),r&&(0,o.default.guard)({and:[{clock:t,filter:d,target:i}],or:{sid:"-w91ef5"}});(0,o.default.sample)({and:[{clock:t,fn:()=>!0,target:u}],or:{sid:"-w56ubc"}}),(0,o.default.guard)({and:[{clock:c.done,source:s,filter:u,target:c}],or:{sid:"-vqceal"}}),(0,o.default.sample)({and:[{clock:c.done,fn:()=>{},target:i}],or:{sid:"-vay5oh"}}),n&&(a&&(0,o.default.sample)({and:[{clock:n,target:i}],or:{sid:"-utwj6u"}}),u.on(n,(()=>!1)),(0,o.default.sample)({and:[{clock:n,target:l}],or:{sid:"-uq1z31"}}));return{tick:i,isRunning:u}}})),m=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.pending=function({effects:e,domain:t,of:r="some"}){if(!o.default.is.domain(t,{sid:"97b92c"})&&!e)throw new TypeError("domain or effects should be passed");if("some"!==r&&"every"!==r)throw new TypeError(`strategy parameter "of" can be "every" or "some". Passed: "${r}"`);let a=e??[];const i=n[r];t&&(a=[],t.onCreateEffect((e=>a.push(e))));return(0,o.default.combine)({and:[a.map((e=>e.pending)),i],or:{sid:"a37bj0"}})};const n={some:e=>e.some(Boolean),every:e=>e.every(Boolean)}})),p=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.reshape=function({source:e,shape:t}){const n={};for(const o in t)if(o in t){const r=t[o];n[o]=e.map((e=>{const t=r(e);return void 0===t?null:t}))}return n}})),y=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.snapshot=function({source:e,clock:t,fn:n=(e=>e)}){const r=n(e.defaultState),a=t?(0,o.default.sample)({and:[e,t,n],or:{name:"onSnapshot",sid:"-auitd0"}}):(0,o.default.sample)({and:[{source:e,fn:n}],or:{name:"onSnapshot",sid:"-auir6n"}}),i=(0,o.default.createStore)(r,{name:"$snapshot",sid:"-7zyoaf"});return i.on(a,((e,t)=>t)),i}})),b=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.some=function({predicate:e,stores:t}){const n=(r=e,"function"==typeof r?e:t=>t===e);var r;return(0,o.default.combine)({and:[t,e=>e.some(n)],or:{sid:"-g8roi6"}})}})),g=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.splitMap=function({source:e,cases:t}){const n={};let r=o.default.is.store(e,{name:"current",sid:"-htjkz7"})?e.updates:e;for(const e in t)if(e in t){const o=t[e];n[e]=r.filterMap(o),r=r.filter({fn:e=>!o(e)})}return n.__=r,n}})),v=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.spread=function({targets:e,source:t=(0,o.default.createEvent)({name:"source",sid:"-iel8gi"})}){for(const n in e)if(n in e){const r=(0,o.default.guard)({and:[{source:t,filter:e=>"object"==typeof e&&null!==e&&n in e}],or:{name:"hasTargetKey",sid:"-gh83lo"}});(0,o.default.sample)({and:[{source:r,fn:e=>e[n],target:e[n]}],or:{sid:"l959bp"}})}return t}})),h=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.status=function({effect:e,defaultValue:t="initial"}){const n=(0,o.default.createStore)(t,{name:"$status",sid:"abrgim"});return n.on(e,(()=>"pending")).on(e.done,(()=>"done")).on(e.fail,(()=>"fail")),n}})),w=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.throttle=function({source:e,timeout:t,target:n=(0,o.default.createEvent)({name:"target",sid:"cenyj5"})}){if(!o.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 r=(0,o.default.createEffect)((()=>new Promise((e=>setTimeout(e,t)))),{name:"timerFx",sid:"uv7gwq"});return(0,o.default.guard)({and:[{source:e,filter:r.pending.map((e=>!e)),target:r}],or:{sid:"-iy4kn2"}}),(0,o.default.sample)({and:[{source:e,clock:r.done,target:n}],or:{sid:"-ija4mb"}}),n}})),j=r((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.time=function({clock:e,getNow:t,initial:r}){const a=t??n,i=(0,o.default.createEffect)(a,{name:"readNowFx",sid:"459ysb"}),u=(0,o.default.restore)(i,r??a(),{name:"$time",sid:"-ys9vce"});return(0,o.default.forward)({and:{from:e,to:i},or:{sid:"rdje9v"}}),u};const n=()=>Date.now()})),_=a.combineEvents,E=i.condition,k=u.debounce,P=s.debug,M=d.delay,O=f.every,x=c.inFlight,T=l.interval,z=m.pending,$=p.reshape,S=y.snapshot,F=b.some,q=g.splitMap,N=v.spread,C=h.status,A=w.throttle,D=j.time,R={combineEvents:_,condition:E,debounce:k,debug:P,delay:M,every:O,inFlight:x,interval:T,pending:z,reshape:$,snapshot:S,some:F,splitMap:q,spread:N,status:C,throttle:A,time:D};e.combineEvents=_,e.condition=E,e.debounce=k,e.debug=P,e.default=R,e.delay=M,e.every=O,e.inFlight=x,e.interval=T,e.pending=z,e.reshape=$,e.snapshot=S,e.some=F,e.splitMap=q,e.spread=N,e.status=C,e.throttle=A,e.time=D,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=patronum.umd.js.map |
@@ -21,3 +21,3 @@ # <img src="logo.svg" title="effector patronum" alt="Effector Patronum logo" width="640px"> | ||
### Timeout | ||
### Time | ||
@@ -28,2 +28,3 @@ - [Debounce](#debounce) — Creates event which waits until time passes after previous trigger. | ||
- [Interval](#interval) — Creates a dynamic interval with any timeout. | ||
- [Time](#time) — Allows reading current timestamp by triggering clock. | ||
@@ -529,4 +530,26 @@ ### Combination/Decomposition | ||
## Time | ||
[Method documentation & API](/src/time) | ||
```ts | ||
import { createEvent } from 'effector'; | ||
import { time } from 'patronum/time'; | ||
const readTime = createEvent(); | ||
const $now = time({ clock: readTime }); | ||
$now.watch((now) => console.log('Now is:', now)); | ||
// => Now is: 1636914286675 | ||
readTime(); | ||
// => Now is: 1636914300691 | ||
``` | ||
[Try it](https://share.effector.dev/BFlhNGvk) | ||
# Development | ||
You can review [CONTRIBUTING.md](./CONTRIBUTING.md) | ||
## Release process | ||
@@ -533,0 +556,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
203651
68
2046
559
3