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

quarx

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quarx - npm Package Compare versions

Comparing version 5.1.0 to 5.2.0

4

index.d.ts

@@ -27,3 +27,3 @@ type ObservableOptions<T> = {

type Subscribable<R> = {
subscribe: (subscriber: (result: R) => void, onError?: (error: any) => void) => () => void;
subscribe: (subscriber: (result: R) => void, onError?: (error: any) => void, onStale?: (flow: unknown) => void) => () => void;
}

@@ -54,4 +54,4 @@

declare module 'quarx/adapters' {
export function fromObservable<R>(obs: Observable<R>, options?: CoreOptions): Subscribable<R>;
export function subscribable<R>(computation: () => R, options?: CoreOptions): Subscribable<R>;
export function toObservable<R>(subs: Subscribable<R>, options?: ObservableOptions<R>): Observable<R>;
}
{
"name": "quarx",
"version": "5.1.0",
"version": "5.2.0",
"description": "Simple tiny reactivity engine",

@@ -5,0 +5,0 @@ "type": "module",

@@ -118,6 +118,6 @@ # 🜉 Quarx

type Subscribable<R> = {
subscribe: (subscriber: (result: R) => void, onError?: (error: any) => void) => () => void;
subscribe: (subscriber: (result: R) => void, onError?: (error: any) => void, onStale?: (flow: unknown) => void) => () => void;
}
export function fromObservable<R>(obs: Observable<R>, options?: CoreOptions): Subscribable<R>;
export function subscribable<R>(computation: () => R, options?: CoreOptions): Subscribable<R>;
export function toObservable<R>(subs: Subscribable<R>, options?: ObservableOptions<R>): Observable<R>;

@@ -124,0 +124,0 @@ ```

import { autorun, createAtom, untrack } from './core.js';
export function fromObservable(obs, options = {}) {
export function subscribable(evaluate, options = {}) {
return {
subscribe(subscriber, onError = options.onError || console.error) {
return autorun(() => subscriber(obs.get()), {
subscribe(subscriber, onError = options.onError) {
return autorun(() => subscriber(evaluate()), {
onError,
name: options.name || 'fromObservable'
name: options.name || 'subscribable'
});

@@ -16,3 +16,3 @@ }

let result, error;
const off = subscribe(value => result = value, e => error = e);
const off = subscribe(value => result = value, e => error = e, e => error = e);
off();

@@ -41,3 +41,3 @@ if (error) throw error;

const atom = createAtom(() => subscribe(r => set(null, r), set), { name });
const atom = createAtom(() => subscribe(r => set(null, r), set, set), { name });

@@ -44,0 +44,0 @@ return {

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

import { createAtom, autorun } from './core.js';
import { subscribable, toObservable } from './adapters.js';

@@ -9,26 +9,4 @@ export function computed(evaluate, options = {}) {

let result, error;
function set(e, r) {
if (e && error === e) return;
if (!e && equals(result, r)) return;
[result, error] = [r, e];
atom.reportChanged();
}
const atom = createAtom(
() => autorun(() => set(null, evaluate()), { name, onError: set }),
{ name: 'result:' + name }
);
return {
get() {
if (!atom.reportObserved()) {
return evaluate();
};
if (error) throw error;
return result;
}
};
const subs = subscribable(evaluate, { name });
return toObservable(subs, { name: 'result:' + name, equals });
}
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