universal-stores
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -60,11 +60,14 @@ function makeSignal() { | ||
start: (set) => { | ||
const cache = new Array(readonlyStores.length); | ||
let cache = new Array(readonlyStores.length); | ||
let subscriptionCounter = 0; | ||
const subscriptions = readonlyStores.map((r, i) => r.subscribe((newValue) => { | ||
cache[i] = newValue; | ||
if (subscriptionCounter < readonlyStores.length) { | ||
cache[i] = newValue; | ||
subscriptionCounter++; | ||
} | ||
if (subscriptionCounter === readonlyStores.length) { | ||
set(deriveValues(cache)); | ||
const updatedCached = [...cache]; | ||
updatedCached[i] = newValue; | ||
set(deriveValues(updatedCached)); | ||
cache = updatedCached; | ||
} | ||
@@ -71,0 +74,0 @@ })); |
@@ -1,2 +0,2 @@ | ||
(function(o,a){typeof exports=="object"&&typeof module!="undefined"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(o=typeof globalThis!="undefined"?globalThis:o||self,a(o.universalStores={}))})(this,function(o){"use strict";function a(){const u=[];function e(t){for(const c of[...u])c(t)}function n(t){const c=u.indexOf(t);c!==-1&&u.splice(c,1)}function s(t){return u.indexOf(t)===-1&&u.push(t),()=>n(t)}function r(t){const c=s(b=>{c(),t(b)});return c}return{emit:e,subscribe:s,subscribeOnce:r,get nOfSubscriptions(){return u.length}}}/** | ||
(function(o,a){typeof exports=="object"&&typeof module!="undefined"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(o=typeof globalThis!="undefined"?globalThis:o||self,a(o.universalStores={}))})(this,function(o){"use strict";function a(){const i=[];function e(t){for(const c of[...i])c(t)}function n(t){const c=i.indexOf(t);c!==-1&&i.splice(c,1)}function s(t){return i.indexOf(t)===-1&&i.push(t),()=>n(t)}function r(t){const c=s(b=>{c(),t(b)});return c}return{emit:e,subscribe:s,subscribeOnce:r,get nOfSubscriptions(){return i.length}}}/** | ||
* @license | ||
@@ -10,3 +10,3 @@ * Copyright (c) 2016-22 [these people](https://github.com/sveltejs/svelte/graphs/contributors) | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/function y(u,e,n){const s=Array.isArray(u),r=s?u:[u],t=b=>e(s?b:b[0]);return S(void 0,{comparator:n==null?void 0:n.comparator,start:b=>{const f=new Array(r.length);let d=0;const v=r.map((p,i)=>p.subscribe(l=>{f[i]=l,d<r.length&&d++,d===r.length&&b(t(f))}));return()=>{for(const p of v)p();d=0}}})}/** | ||
*/function h(i,e,n){const s=Array.isArray(i),r=s?i:[i],t=b=>e(s?b:b[0]);return v(void 0,{comparator:n==null?void 0:n.comparator,start:b=>{let d=new Array(r.length),f=0;const y=r.map((l,u)=>l.subscribe(p=>{if(f<r.length&&(d[u]=p,f++),f===r.length){const m=[...d];m[u]=p,b(t(m)),d=m}}));return()=>{for(const l of y)l();f=0}}})}/** | ||
* @license | ||
@@ -20,2 +20,2 @@ * Copyright (c) 2016-22 [these people](https://github.com/sveltejs/svelte/graphs/contributors) | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/function m(u,e){var p;let n=u;const s=a();let r;const t=typeof e=="function"?e:e==null?void 0:e.start,c=(p=typeof e=="function"||e==null?void 0:e.comparator)!=null?p:(i,l)=>i===l,b=()=>{if(s.nOfSubscriptions>0)return n;let i;return d(h=>i=h)(),i},f=i=>{n!==void 0&&c(n,i)||(n=i,s.emit(n))},d=i=>{s.nOfSubscriptions===0&&(r=t==null?void 0:t(f));const l=s.subscribe(i);return i(n),()=>{l(),s.nOfSubscriptions===0&&(r==null||r(),r=void 0)}};return{get value(){return b()},set:f,subscribe:d,update:i=>{f(i(b()))},get nOfSubscriptions(){return s.nOfSubscriptions}}}function S(u,e){const n=m(u,e);return{get value(){return n.value},subscribe:n.subscribe,get nOfSubscriptions(){return n.nOfSubscriptions}}}o.makeDerivedStore=y,o.makeReadonlyStore=S,o.makeStore=m,Object.defineProperty(o,"__esModule",{value:!0}),o[Symbol.toStringTag]="Module"}); | ||
*/function S(i,e){var l;let n=i;const s=a();let r;const t=typeof e=="function"?e:e==null?void 0:e.start,c=(l=typeof e=="function"||e==null?void 0:e.comparator)!=null?l:(u,p)=>u===p,b=()=>{if(s.nOfSubscriptions>0)return n;let u;return f(m=>u=m)(),u},d=u=>{n!==void 0&&c(n,u)||(n=u,s.emit(n))},f=u=>{s.nOfSubscriptions===0&&(r=t==null?void 0:t(d));const p=s.subscribe(u);return u(n),()=>{p(),s.nOfSubscriptions===0&&(r==null||r(),r=void 0)}};return{get value(){return b()},set:d,subscribe:f,update:u=>{d(u(b()))},get nOfSubscriptions(){return s.nOfSubscriptions}}}function v(i,e){const n=S(i,e);return{get value(){return n.value},subscribe:n.subscribe,get nOfSubscriptions(){return n.nOfSubscriptions}}}o.makeDerivedStore=h,o.makeReadonlyStore=v,o.makeStore=S,Object.defineProperty(o,"__esModule",{value:!0}),o[Symbol.toStringTag]="Module"}); |
@@ -5,3 +5,3 @@ { | ||
"description": "State management made simple", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"type": "module", | ||
@@ -8,0 +8,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
36739
461