Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cuprum

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cuprum - npm Package Compare versions

Comparing version 0.1.10 to 0.1.11

2

dist/bundle.common.min.js

@@ -1,2 +0,2 @@

"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"Can't dispatch on subject";this.internalDispatch(s)}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))}}exports.Cuprum=s,exports.combine=function(...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},exports.fromEvent=function(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},exports.merge=function(...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},exports.tap=function(s){return s(this.val),this};
"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"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};
//# sourceMappingURL=bundle.common.min.js.map

@@ -1,2 +0,2 @@

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"Can't dispatch on subject";this.internalDispatch(s)}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(i){t.unsubscribe(),s(i)}))})}map(t){const i=new s,e=s=>{i.internalDispatch(t(s))};return i.subscribeHot(s=>{s?this.subscribe(e):this.unsubscribe(e)}),i}filter(t){const i=new s,e=s=>{t(s)&&i.dispatch(s)};return i.subscribeHot(s=>{s?this.subscribe(e):this.unsubscribe(e)}),i}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(i=>i(s,t))}}function t(s){return s(this.val),this}function i(t,i){const e=new s,r=s=>{e.dispatch(s)};return e.subscribeHot(s=>{s?t.addEventListener(i,r,!1):t.removeEventListener(i,r,!1)}),e}function e(...t){const i=new s,e=new Set;return i.subscribeHot(s=>{s?t.forEach(s=>{e.add(s.subscribe(()=>{i.dispatch(t.map(s=>s.value()))}))}):e.forEach(s=>s.unsubscribe())}),i}function r(...t){const i=new s,e=new Set;return i.subscribeHot(s=>{s?t.forEach(s=>{e.add(s.subscribe(s=>{i.dispatch(s)}))}):e.forEach(s=>s.unsubscribe())}),i}export{s as Cuprum,e as combine,i as fromEvent,r as merge,t as tap};
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"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};
//# sourceMappingURL=bundle.min.js.map

@@ -8,3 +8,3 @@ export declare class Cuprum<T> {

private isSubject;
dispatch(value: T): void;
dispatch(value: T): this;
subscribe(fn: (value: T, oldValue?: T) => void): Subscription;

@@ -25,22 +25,21 @@ unsubscribe(fn: (value: T, oldValue?: T) => void): void;

}
export declare function tap(fn: (val: any) => any): any;
export declare function fromEvent(element: any, eventType: any): Cuprum<Event>;
export declare function combine<T>(obs1$: Cuprum<T>): Cuprum<[T]>;
export declare function combine<T, U>(obs1$: Cuprum<T>, obs2$: Cuprum<U>): Cuprum<[T, U]>;
export declare function combine<T, U, V>(obs1$: Cuprum<T>, obs2$: Cuprum<U>, obs3$: Cuprum<V>): Cuprum<[T, U, V]>;
export declare function combine<T, U, V, W>(obs1$: Cuprum<T>, obs2$: Cuprum<U>, obs3$: Cuprum<V>, obs4$: Cuprum<W>): Cuprum<[T, U, V, W]>;
export declare function combine<T, U, V, W, X>(obs1$: Cuprum<T>, obs2$: Cuprum<U>, obs3$: Cuprum<V>, obs4$: Cuprum<W>, obs5$: Cuprum<X>): Cuprum<[T, U, V, W, X]>;
export declare function combine<T, U, V, W, X, Y>(obs1$: Cuprum<T>, obs2$: Cuprum<U>, obs3$: Cuprum<V>, obs4$: Cuprum<W>, obs5$: Cuprum<X>, obs6$: Cuprum<Y>): Cuprum<[T, U, V, W, X, Y]>;
export declare function combine<T, U, V, W, X, Y, Z>(obs1$: Cuprum<T>, obs2$: Cuprum<U>, obs3$: Cuprum<V>, obs4$: Cuprum<W>, obs5$: Cuprum<X>, obs6$: Cuprum<Y>, obs7$: Cuprum<Z>): Cuprum<[T, U, V, W, X, Y, Z]>;
export declare function merge<T>(obs1$: Cuprum<T>): Cuprum<[T]>;
export declare function merge<T>(obs1$: Cuprum<T>, obs2$: Cuprum<T>): Cuprum<T>;
export declare function merge<T>(obs1$: Cuprum<T>, obs2$: Cuprum<T>, obs3$: Cuprum<T>): Cuprum<T>;
export declare function merge<T>(obs1$: Cuprum<T>, obs2$: Cuprum<T>, obs3$: Cuprum<T>, obs4$: Cuprum<T>): Cuprum<T>;
export declare function merge<T>(obs1$: Cuprum<T>, obs2$: Cuprum<T>, obs3$: Cuprum<T>, obs4$: Cuprum<T>, obs5$: Cuprum<T>): Cuprum<T>;
export declare function merge<T>(obs1$: Cuprum<T>, obs2$: Cuprum<T>, obs3$: Cuprum<T>, obs4$: Cuprum<T>, obs5$: Cuprum<T>, obs6$: Cuprum<T>): Cuprum<T>;
export declare function merge<T>(obs1$: Cuprum<T>, obs2$: Cuprum<T>, obs3$: Cuprum<T>, obs4$: Cuprum<T>, obs5$: Cuprum<T>, obs6$: Cuprum<T>, obs7$: Cuprum<T>): Cuprum<T>;
declare type Observable<T> = Omit<Cuprum<T>, "dispatch">;
interface Subscription {
export declare function combine<T>(obs1$: Observable<T>): Observable<[T]>;
export declare function combine<T, U>(obs1$: Observable<T>, obs2$: Observable<U>): Observable<[T, U]>;
export declare function combine<T, U, V>(obs1$: Observable<T>, obs2$: Observable<U>, obs3$: Observable<V>): Observable<[T, U, V]>;
export declare function combine<T, U, V, W>(obs1$: Observable<T>, obs2$: Observable<U>, obs3$: Observable<V>, obs4$: Observable<W>): Observable<[T, U, V, W]>;
export declare function combine<T, U, V, W, X>(obs1$: Observable<T>, obs2$: Observable<U>, obs3$: Observable<V>, obs4$: Observable<W>, obs5$: Observable<X>): Observable<[T, U, V, W, X]>;
export declare function combine<T, U, V, W, X, Y>(obs1$: Observable<T>, obs2$: Observable<U>, obs3$: Observable<V>, obs4$: Observable<W>, obs5$: Observable<X>, obs6$: Observable<Y>): Observable<[T, U, V, W, X, Y]>;
export declare function combine<T, U, V, W, X, Y, Z>(obs1$: Observable<T>, obs2$: Observable<U>, obs3$: Observable<V>, obs4$: Observable<W>, obs5$: Observable<X>, obs6$: Observable<Y>, obs7$: Observable<Z>): Observable<[T, U, V, W, X, Y, Z]>;
export declare function merge<T>(obs1$: Observable<T>): Observable<T>;
export declare function merge<T>(obs1$: Observable<T>, obs2$: Observable<T>): Observable<T>;
export declare function merge<T>(obs1$: Observable<T>, obs2$: Observable<T>, obs3$: Observable<T>): Observable<T>;
export declare function merge<T>(obs1$: Observable<T>, obs2$: Observable<T>, obs3$: Observable<T>, obs4$: Observable<T>): Observable<T>;
export declare function merge<T>(obs1$: Observable<T>, obs2$: Observable<T>, obs3$: Observable<T>, obs4$: Observable<T>, obs5$: Observable<T>): Observable<T>;
export declare function merge<T>(obs1$: Observable<T>, obs2$: Observable<T>, obs3$: Observable<T>, obs4$: Observable<T>, obs5$: Observable<T>, obs6$: Observable<T>): Observable<T>;
export declare function merge<T>(obs1$: Observable<T>, obs2$: Observable<T>, obs3$: Observable<T>, obs4$: Observable<T>, obs5$: Observable<T>, obs6$: Observable<T>, obs7$: Observable<T>): Observable<T>;
export declare function interval(msec: any): Cuprum<unknown>;
export declare type Observable<T> = Omit<Cuprum<T>, "dispatch">;
export interface Subscription {
unsubscribe: () => void;
}
export {};
{
"name": "cuprum",
"version": "0.1.10",
"version": "0.1.11",
"description": "Tiny state management library",

@@ -5,0 +5,0 @@ "main": "dist/bundle.common.min.js",

@@ -14,2 +14,3 @@ export class Cuprum<T> {

this.internalDispatch(value);
return this;
}

@@ -62,4 +63,2 @@

// TODO: pipe
// TODO: async map

@@ -124,7 +123,2 @@

export function tap(fn: (val: any) => any) {
fn(this.val);
return this;
}
export function fromEvent(element, eventType) {

@@ -145,44 +139,44 @@ const obs$ = new Cuprum<Event>();

export function combine<T>(obs1$: Cuprum<T>): Cuprum<[T]>;
export function combine<T>(obs1$: Observable<T>): Observable<[T]>;
export function combine<T, U>(
obs1$: Cuprum<T>,
obs2$: Cuprum<U>
): Cuprum<[T, U]>;
obs1$: Observable<T>,
obs2$: Observable<U>
): Observable<[T, U]>;
export function combine<T, U, V>(
obs1$: Cuprum<T>,
obs2$: Cuprum<U>,
obs3$: Cuprum<V>
): Cuprum<[T, U, V]>;
obs1$: Observable<T>,
obs2$: Observable<U>,
obs3$: Observable<V>
): Observable<[T, U, V]>;
export function combine<T, U, V, W>(
obs1$: Cuprum<T>,
obs2$: Cuprum<U>,
obs3$: Cuprum<V>,
obs4$: Cuprum<W>
): Cuprum<[T, U, V, W]>;
obs1$: Observable<T>,
obs2$: Observable<U>,
obs3$: Observable<V>,
obs4$: Observable<W>
): Observable<[T, U, V, W]>;
export function combine<T, U, V, W, X>(
obs1$: Cuprum<T>,
obs2$: Cuprum<U>,
obs3$: Cuprum<V>,
obs4$: Cuprum<W>,
obs5$: Cuprum<X>
): Cuprum<[T, U, V, W, X]>;
obs1$: Observable<T>,
obs2$: Observable<U>,
obs3$: Observable<V>,
obs4$: Observable<W>,
obs5$: Observable<X>
): Observable<[T, U, V, W, X]>;
export function combine<T, U, V, W, X, Y>(
obs1$: Cuprum<T>,
obs2$: Cuprum<U>,
obs3$: Cuprum<V>,
obs4$: Cuprum<W>,
obs5$: Cuprum<X>,
obs6$: Cuprum<Y>
): Cuprum<[T, U, V, W, X, Y]>;
obs1$: Observable<T>,
obs2$: Observable<U>,
obs3$: Observable<V>,
obs4$: Observable<W>,
obs5$: Observable<X>,
obs6$: Observable<Y>
): Observable<[T, U, V, W, X, Y]>;
export function combine<T, U, V, W, X, Y, Z>(
obs1$: Cuprum<T>,
obs2$: Cuprum<U>,
obs3$: Cuprum<V>,
obs4$: Cuprum<W>,
obs5$: Cuprum<X>,
obs6$: Cuprum<Y>,
obs7$: Cuprum<Z>
): Cuprum<[T, U, V, W, X, Y, Z]>;
obs1$: Observable<T>,
obs2$: Observable<U>,
obs3$: Observable<V>,
obs4$: Observable<W>,
obs5$: Observable<X>,
obs6$: Observable<Y>,
obs7$: Observable<Z>
): Observable<[T, U, V, W, X, Y, Z]>;
export function combine(...cuprumList: Cuprum<unknown>[]) {
export function combine(...cuprumList: Observable<unknown>[]) {
const obs$ = new Cuprum();

@@ -205,43 +199,46 @@ const subs = new Set<Subscription>();

return obs$;
return <Observable<unknown>>obs$;
}
export function merge<T>(obs1$: Cuprum<T>): Cuprum<[T]>;
export function merge<T>(obs1$: Cuprum<T>, obs2$: Cuprum<T>): Cuprum<T>;
export function merge<T>(obs1$: Observable<T>): Observable<T>;
export function merge<T>(
obs1$: Cuprum<T>,
obs2$: Cuprum<T>,
obs3$: Cuprum<T>
): Cuprum<T>;
obs1$: Observable<T>,
obs2$: Observable<T>
): Observable<T>;
export function merge<T>(
obs1$: Cuprum<T>,
obs2$: Cuprum<T>,
obs3$: Cuprum<T>,
obs4$: Cuprum<T>
): Cuprum<T>;
obs1$: Observable<T>,
obs2$: Observable<T>,
obs3$: Observable<T>
): Observable<T>;
export function merge<T>(
obs1$: Cuprum<T>,
obs2$: Cuprum<T>,
obs3$: Cuprum<T>,
obs4$: Cuprum<T>,
obs5$: Cuprum<T>
): Cuprum<T>;
obs1$: Observable<T>,
obs2$: Observable<T>,
obs3$: Observable<T>,
obs4$: Observable<T>
): Observable<T>;
export function merge<T>(
obs1$: Cuprum<T>,
obs2$: Cuprum<T>,
obs3$: Cuprum<T>,
obs4$: Cuprum<T>,
obs5$: Cuprum<T>,
obs6$: Cuprum<T>
): Cuprum<T>;
obs1$: Observable<T>,
obs2$: Observable<T>,
obs3$: Observable<T>,
obs4$: Observable<T>,
obs5$: Observable<T>
): Observable<T>;
export function merge<T>(
obs1$: Cuprum<T>,
obs2$: Cuprum<T>,
obs3$: Cuprum<T>,
obs4$: Cuprum<T>,
obs5$: Cuprum<T>,
obs6$: Cuprum<T>,
obs7$: Cuprum<T>
): Cuprum<T>;
export function merge(...cuprumList: Cuprum<unknown>[]) {
obs1$: Observable<T>,
obs2$: Observable<T>,
obs3$: Observable<T>,
obs4$: Observable<T>,
obs5$: Observable<T>,
obs6$: Observable<T>
): Observable<T>;
export function merge<T>(
obs1$: Observable<T>,
obs2$: Observable<T>,
obs3$: Observable<T>,
obs4$: Observable<T>,
obs5$: Observable<T>,
obs6$: Observable<T>,
obs7$: Observable<T>
): Observable<T>;
export function merge(...cuprumList: Observable<unknown>[]) {
const obs$ = new Cuprum();

@@ -264,9 +261,28 @@ const subs = new Set<Subscription>();

return <Observable<unknown>>obs$;
}
export function interval(msec) {
const obs$ = new Cuprum();
let timer = <NodeJS.Timeout>null;
let counter;
obs$.subscribeHot((hot) => {
if (hot) {
counter = 0;
timer = setInterval(() => {
obs$.dispatch(counter++);
}, msec);
} else {
clearInterval(timer);
}
});
return obs$;
}
type Observable<T> = Omit<Cuprum<T>, "dispatch">;
export type Observable<T> = Omit<Cuprum<T>, "dispatch">;
interface Subscription {
export interface Subscription {
unsubscribe: () => void;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc