Comparing version 0.1.14 to 0.1.16
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}); | ||
/**! | ||
@preserve cuprum 0.1.14 | ||
/** | ||
cuprum 0.1.16 | ||
@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}; | ||
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)))}}function t(t,e,r){const i=new s,c=s=>{i.dispatch(s)};return i.subscribeHot((s=>{s?t.addEventListener(e,c,r):t.removeEventListener(e,c,r)})),i}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.fromCustomEvent=t,exports.fromEvent=function(s,e,r){return t(s,e,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}; | ||
//# sourceMappingURL=bundle.common.min.js.map |
@@ -1,7 +0,7 @@ | ||
/**! | ||
@preserve cuprum 0.1.14 | ||
/** | ||
cuprum 0.1.16 | ||
@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}; | ||
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(s,t,i){return e(s,t,i)}function e(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 i(...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 r(...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 b(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,i as combine,e as fromCustomEvent,t as fromEvent,b as interval,r as merge}; | ||
//# sourceMappingURL=bundle.min.js.map |
@@ -1,3 +0,3 @@ | ||
/**! | ||
@preserve cuprum 0.1.14 | ||
/** | ||
cuprum 0.1.16 | ||
@copyright 2020 Edwin Martin <edwin@bitstorm.org> | ||
@@ -30,2 +30,3 @@ @license MIT | ||
export declare function fromEvent<K extends keyof HTMLElementEventMap>(element: HTMLElement, eventType: K, options?: boolean | AddEventListenerOptions): Cuprum<HTMLElementEventMap[K]>; | ||
export declare function fromCustomEvent(element: HTMLElement | Document | Window, eventType: string, options?: boolean | AddEventListenerOptions): Cuprum<unknown>; | ||
export declare function combine<T>(obs1$: Observable<T>): Observable<[T]>; | ||
@@ -32,0 +33,0 @@ export declare function combine<T, U>(obs1$: Observable<T>, obs2$: Observable<U>): Observable<[T, U]>; |
{ | ||
"name": "cuprum", | ||
"version": "0.1.14", | ||
"version": "0.1.16", | ||
"description": "Tiny state management library", | ||
@@ -10,2 +10,3 @@ "main": "dist/bundle.common.min.js", | ||
"scripts": { | ||
"prepare": "husky install", | ||
"start": "http-server -o demo/ --silent", | ||
@@ -40,13 +41,13 @@ "build": "rollup --config --sourcemap", | ||
"homepage": "https://github.com/edwinm/cuprum#readme", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/mocha": "^7.0.2", | ||
"@types/node": "^14.0.4", | ||
"@typescript-eslint/eslint-plugin": "^3.0.2", | ||
"@typescript-eslint/parser": "^3.0.2", | ||
"eslint": "^7.1.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"http-server": "^0.12.3", | ||
"husky": "^4.2.5", | ||
"karma": "^5.0.9", | ||
"@rollup/plugin-replace": "^3.0.0", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^17.0.1", | ||
"@typescript-eslint/eslint-plugin": "^5.7.0", | ||
"@typescript-eslint/parser": "^5.7.0", | ||
"eslint": "^8.5.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"http-server": "^14.0.0", | ||
"husky": "^7.0.4", | ||
"karma": "^6.3.9", | ||
"karma-chai": "^0.1.0", | ||
@@ -57,16 +58,11 @@ "karma-chrome-launcher": "^3.1.0", | ||
"karma-typescript": "^5.0.3", | ||
"mocha": "^7.2.0", | ||
"mocha": "^9.1.3", | ||
"prettier": "^2.0.5", | ||
"pretty-quick": "^2.0.1", | ||
"pretty-quick": "^3.1.2", | ||
"rollup": "^2.10.2", | ||
"rollup-plugin-terser": "^5.3.0", | ||
"rollup-plugin-typescript2": "^0.27.1", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.31.1", | ||
"tslib": "^2.0.0", | ||
"typescript": "^3.9.2" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "pretty-quick --staged" | ||
} | ||
"typescript": "^3.9.10" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
![test](https://github.com/edwinm/cuprum/workflows/Test/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/edwinm/cuprum/badge.svg?branch=master)](https://coveralls.io/github/edwinm/cuprum?branch=master) [![CodeFactor](https://www.codefactor.io/repository/github/edwinm/cuprum/badge)](https://www.codefactor.io/repository/github/edwinm/cuprum) [![Size](https://img.badgesize.io/edwinm/cuprum/master/dist/bundle.min.js?compression=gzip)](https://github.com/edwinm/cuprum/blob/master/dist/bundle.min.js) [![npm version](https://badge.fury.io/js/cuprum.svg)](https://www.npmjs.com/package/cuprum) [![GitHub](https://img.shields.io/github/license/edwinm/cuprum.svg)](https://github.com/edwinm/cuprum/blob/master/LICENSE) | ||
![test](https://github.com/edwinm/cuprum/workflows/Test/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/edwinm/cuprum/badge.svg?branch=master)](https://coveralls.io/github/edwinm/cuprum?branch=master) [![CodeFactor](https://www.codefactor.io/repository/github/edwinm/cuprum/badge)](https://www.codefactor.io/repository/github/edwinm/cuprum) [![Size](https://img.shields.io/github/size/edwinm/cuprum/dist/bundle.min.js)](https://github.com/edwinm/cuprum/blob/master/dist/bundle.min.js) [![npm version](https://badge.fury.io/js/cuprum.svg)](https://www.npmjs.com/package/cuprum) [![GitHub](https://img.shields.io/github/license/edwinm/cuprum.svg)](https://github.com/edwinm/cuprum/blob/master/LICENSE) | ||
@@ -3,0 +3,0 @@ # Cuprum |
@@ -1,3 +0,3 @@ | ||
/**! | ||
@preserve cuprum 0.1.14 | ||
/** | ||
cuprum __buildVersion__ | ||
@copyright 2020 Edwin Martin <edwin@bitstorm.org> | ||
@@ -126,5 +126,3 @@ @license MIT | ||
export function fromEvent< | ||
K extends keyof WindowEventMap | ||
>( | ||
export function fromEvent<K extends keyof WindowEventMap>( | ||
element: Window, | ||
@@ -135,5 +133,3 @@ eventType: K, | ||
export function fromEvent< | ||
K extends keyof DocumentEventMap | ||
>( | ||
export function fromEvent<K extends keyof DocumentEventMap>( | ||
element: Document, | ||
@@ -144,5 +140,3 @@ eventType: K, | ||
export function fromEvent< | ||
K extends keyof HTMLElementEventMap | ||
>( | ||
export function fromEvent<K extends keyof HTMLElementEventMap>( | ||
element: HTMLElement, | ||
@@ -158,2 +152,10 @@ eventType: K, | ||
) { | ||
return fromCustomEvent(element, eventType, options); | ||
} | ||
export function fromCustomEvent( | ||
element: HTMLElement | Document | Window, | ||
eventType: string, | ||
options?: boolean | AddEventListenerOptions | ||
) { | ||
const obs$ = new Cuprum(); | ||
@@ -160,0 +162,0 @@ const dispatch = (evt: unknown) => { |
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
37312
321
23