Comparing version 0.1.12 to 0.1.13
@@ -1,2 +0,8 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class s{constructor(){this.subscribers=new Set,this.subscribersHot=new Set,this.dispatched=!1,this.hot=!1,this.isSubject=!1}dispatch(s){if(this.isSubject)throw new Error("Can't dispatch on subject");return this.internalDispatch(s),this}subscribe(s){return this.dispatched&&s(this.val),this.subscribeNext(s)}unsubscribe(s){this.subscribers.delete(s),this.notifyHotSubscribers()}subscribeHot(s){return this.subscribersHot.add(s),{unsubscribe:()=>{this.subscribersHot.delete(s)}}}clear(){this.subscribers.clear(),this.subscribersHot.clear()}value(){return this.val}observable(){const s=this.map(s=>s);return s.isSubject=!0,s}promise(){return new Promise(s=>{const t=this.subscribe((function(e){t.unsubscribe(),s(e)}))})}map(t){const e=new s,r=s=>{e.internalDispatch(t(s))};return e.subscribeHot(s=>{s?this.subscribe(r):this.unsubscribe(r)}),e}filter(t){const e=new s,r=s=>{t(s)&&e.dispatch(s)};return e.subscribeHot(s=>{s?this.subscribe(r):this.unsubscribe(r)}),e}notifyHotSubscribers(){this.subscribers.size>0!=this.hot&&(this.hot=this.subscribers.size>0,this.subscribersHot.forEach(s=>s(this.hot)))}subscribeNext(s){return this.subscribers.add(s),this.notifyHotSubscribers(),{unsubscribe:()=>{this.subscribers.delete(s)}}}internalDispatch(s){const t=this.val;this.val=s,this.dispatched=!0,this.subscribers.forEach(e=>e(s,t))}}exports.Cuprum=s,exports.combine=function(...t){const e=new s,r=new Set;return e.subscribeHot(s=>{s?t.forEach(s=>{r.add(s.subscribe(()=>{e.dispatch(t.map(s=>s.value()))}))}):r.forEach(s=>s.unsubscribe())}),e},exports.fromEvent=function(t,e){const r=new s,i=s=>{r.dispatch(s)};return r.subscribeHot(s=>{s?t.addEventListener(e,i,!1):t.removeEventListener(e,i,!1)}),r},exports.interval=function(t){const e=new s;let r,i=null;return e.subscribeHot(s=>{s?(r=0,i=setInterval(()=>{e.dispatch(r++)},t)):clearInterval(i)}),e},exports.merge=function(...t){const e=new s,r=new Set;return e.subscribeHot(s=>{s?t.forEach(s=>{r.add(s.subscribe(s=>{e.dispatch(s)}))}):r.forEach(s=>s.unsubscribe())}),e}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}); | ||
/**! | ||
@preserve cuprum 0.1.13 | ||
@copyright 2020 Edwin Martin <edwin@bitstorm.org> | ||
@license MIT | ||
*/ | ||
class s{constructor(){this.subscribers=new Set,this.subscribersHot=new Set,this.dispatched=!1,this.hot=!1,this.isSubject=!1}dispatch(s){if(this.isSubject)throw new Error("Can't dispatch on subject");return this.internalDispatch(s),this}subscribe(s){return this.dispatched&&s(this.val),this.subscribeNext(s)}unsubscribe(s){this.subscribers.delete(s),this.notifyHotSubscribers()}subscribeHot(s){return this.subscribersHot.add(s),{unsubscribe:()=>{this.subscribersHot.delete(s)}}}clear(){this.subscribers.clear(),this.subscribersHot.clear()}value(){return this.val}observable(){const s=this.map(s=>s);return s.isSubject=!0,s}promise(){return new Promise(s=>{const t=this.subscribe((function(e){t.unsubscribe(),s(e)}))})}map(t){const e=new s,r=s=>{e.internalDispatch(t(s))};return e.subscribeHot(s=>{s?this.subscribe(r):this.unsubscribe(r)}),e}filter(t){const e=new s,r=s=>{t(s)&&e.dispatch(s)};return e.subscribeHot(s=>{s?this.subscribe(r):this.unsubscribe(r)}),e}notifyHotSubscribers(){this.subscribers.size>0!=this.hot&&(this.hot=this.subscribers.size>0,this.subscribersHot.forEach(s=>s(this.hot)))}subscribeNext(s){return this.subscribers.add(s),this.notifyHotSubscribers(),{unsubscribe:()=>{this.subscribers.delete(s)}}}internalDispatch(s){const t=this.val;this.val=s,this.dispatched=!0,this.subscribers.forEach(e=>e(s,t))}}exports.Cuprum=s,exports.combine=function(...t){const e=new s,r=new Set;return e.subscribeHot(s=>{s?t.forEach(s=>{r.add(s.subscribe(()=>{e.dispatch(t.map(s=>s.value()))}))}):r.forEach(s=>s.unsubscribe())}),e},exports.fromEvent=function(t,e,r){const i=new s,b=s=>{i.dispatch(s)};return i.subscribeHot(s=>{s?t.addEventListener(e,b,r):t.removeEventListener(e,b,r)}),i},exports.interval=function(t){const e=new s;let r,i=null;return e.subscribeHot(s=>{s?(r=0,i=setInterval(()=>{e.dispatch(r++)},t)):clearInterval(i)}),e},exports.merge=function(...t){const e=new s,r=new Set;return e.subscribeHot(s=>{s?t.forEach(s=>{r.add(s.subscribe(s=>{e.dispatch(s)}))}):r.forEach(s=>s.unsubscribe())}),e}; | ||
//# sourceMappingURL=bundle.common.min.js.map |
@@ -1,2 +0,7 @@ | ||
class s{constructor(){this.subscribers=new Set,this.subscribersHot=new Set,this.dispatched=!1,this.hot=!1,this.isSubject=!1}dispatch(s){if(this.isSubject)throw new Error("Can't dispatch on subject");return this.internalDispatch(s),this}subscribe(s){return this.dispatched&&s(this.val),this.subscribeNext(s)}unsubscribe(s){this.subscribers.delete(s),this.notifyHotSubscribers()}subscribeHot(s){return this.subscribersHot.add(s),{unsubscribe:()=>{this.subscribersHot.delete(s)}}}clear(){this.subscribers.clear(),this.subscribersHot.clear()}value(){return this.val}observable(){const s=this.map(s=>s);return s.isSubject=!0,s}promise(){return new Promise(s=>{const t=this.subscribe((function(e){t.unsubscribe(),s(e)}))})}map(t){const e=new s,i=s=>{e.internalDispatch(t(s))};return e.subscribeHot(s=>{s?this.subscribe(i):this.unsubscribe(i)}),e}filter(t){const e=new s,i=s=>{t(s)&&e.dispatch(s)};return e.subscribeHot(s=>{s?this.subscribe(i):this.unsubscribe(i)}),e}notifyHotSubscribers(){this.subscribers.size>0!=this.hot&&(this.hot=this.subscribers.size>0,this.subscribersHot.forEach(s=>s(this.hot)))}subscribeNext(s){return this.subscribers.add(s),this.notifyHotSubscribers(),{unsubscribe:()=>{this.subscribers.delete(s)}}}internalDispatch(s){const t=this.val;this.val=s,this.dispatched=!0,this.subscribers.forEach(e=>e(s,t))}}function t(t,e){const i=new s,r=s=>{i.dispatch(s)};return i.subscribeHot(s=>{s?t.addEventListener(e,r,!1):t.removeEventListener(e,r,!1)}),i}function e(...t){const e=new s,i=new Set;return e.subscribeHot(s=>{s?t.forEach(s=>{i.add(s.subscribe(()=>{e.dispatch(t.map(s=>s.value()))}))}):i.forEach(s=>s.unsubscribe())}),e}function i(...t){const e=new s,i=new Set;return e.subscribeHot(s=>{s?t.forEach(s=>{i.add(s.subscribe(s=>{e.dispatch(s)}))}):i.forEach(s=>s.unsubscribe())}),e}function r(t){const e=new s;let i,r=null;return e.subscribeHot(s=>{s?(i=0,r=setInterval(()=>{e.dispatch(i++)},t)):clearInterval(r)}),e}export{s as Cuprum,e as combine,t as fromEvent,r as interval,i as merge}; | ||
/**! | ||
@preserve cuprum 0.1.13 | ||
@copyright 2020 Edwin Martin <edwin@bitstorm.org> | ||
@license MIT | ||
*/ | ||
class s{constructor(){this.subscribers=new Set,this.subscribersHot=new Set,this.dispatched=!1,this.hot=!1,this.isSubject=!1}dispatch(s){if(this.isSubject)throw new Error("Can't dispatch on subject");return this.internalDispatch(s),this}subscribe(s){return this.dispatched&&s(this.val),this.subscribeNext(s)}unsubscribe(s){this.subscribers.delete(s),this.notifyHotSubscribers()}subscribeHot(s){return this.subscribersHot.add(s),{unsubscribe:()=>{this.subscribersHot.delete(s)}}}clear(){this.subscribers.clear(),this.subscribersHot.clear()}value(){return this.val}observable(){const s=this.map(s=>s);return s.isSubject=!0,s}promise(){return new Promise(s=>{const t=this.subscribe((function(e){t.unsubscribe(),s(e)}))})}map(t){const e=new s,i=s=>{e.internalDispatch(t(s))};return e.subscribeHot(s=>{s?this.subscribe(i):this.unsubscribe(i)}),e}filter(t){const e=new s,i=s=>{t(s)&&e.dispatch(s)};return e.subscribeHot(s=>{s?this.subscribe(i):this.unsubscribe(i)}),e}notifyHotSubscribers(){this.subscribers.size>0!=this.hot&&(this.hot=this.subscribers.size>0,this.subscribersHot.forEach(s=>s(this.hot)))}subscribeNext(s){return this.subscribers.add(s),this.notifyHotSubscribers(),{unsubscribe:()=>{this.subscribers.delete(s)}}}internalDispatch(s){const t=this.val;this.val=s,this.dispatched=!0,this.subscribers.forEach(e=>e(s,t))}}function t(t,e,i){const r=new s,b=s=>{r.dispatch(s)};return r.subscribeHot(s=>{s?t.addEventListener(e,b,i):t.removeEventListener(e,b,i)}),r}function e(...t){const e=new s,i=new Set;return e.subscribeHot(s=>{s?t.forEach(s=>{i.add(s.subscribe(()=>{e.dispatch(t.map(s=>s.value()))}))}):i.forEach(s=>s.unsubscribe())}),e}function i(...t){const e=new s,i=new Set;return e.subscribeHot(s=>{s?t.forEach(s=>{i.add(s.subscribe(s=>{e.dispatch(s)}))}):i.forEach(s=>s.unsubscribe())}),e}function r(t){const e=new s;let i,r=null;return e.subscribeHot(s=>{s?(i=0,r=setInterval(()=>{e.dispatch(i++)},t)):clearInterval(r)}),e}export{s as Cuprum,e as combine,t as fromEvent,r as interval,i as merge}; | ||
//# sourceMappingURL=bundle.min.js.map |
@@ -0,1 +1,6 @@ | ||
/**! | ||
@preserve cuprum 0.1.13 | ||
@copyright 2020 Edwin Martin <edwin@bitstorm.org> | ||
@license MIT | ||
*/ | ||
export declare class Cuprum<T> { | ||
@@ -22,3 +27,3 @@ private val; | ||
} | ||
export declare function fromEvent<K extends keyof HTMLElementEventMap>(element: HTMLElement, eventType: K): Cuprum<HTMLElementEventMap[K]>; | ||
export declare function fromEvent<K extends keyof HTMLElementEventMap>(element: HTMLElement, eventType: K, options?: boolean | AddEventListenerOptions): Cuprum<HTMLElementEventMap[K]>; | ||
export declare function combine<T>(obs1$: Observable<T>): Observable<[T]>; | ||
@@ -25,0 +30,0 @@ export declare function combine<T, U>(obs1$: Observable<T>, obs2$: Observable<U>): Observable<[T, U]>; |
{ | ||
"name": "cuprum", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "Tiny state management library", | ||
@@ -5,0 +5,0 @@ "main": "dist/bundle.common.min.js", |
@@ -0,1 +1,6 @@ | ||
/**! | ||
@preserve cuprum 0.1.13 | ||
@copyright 2020 Edwin Martin <edwin@bitstorm.org> | ||
@license MIT | ||
*/ | ||
export class Cuprum<T> { | ||
@@ -2,0 +7,0 @@ private val: T; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
34260
295