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

realar

Package Overview
Dependencies
Maintainers
1
Versions
129
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

realar - npm Package Compare versions

Comparing version 0.5.25 to 0.5.26

37

build/index.d.ts

@@ -32,2 +32,3 @@ import { FC } from 'react';

val: T & K;
get(): K;
update: (fn: (state: K) => T) => void;

@@ -38,10 +39,11 @@ sub: {

};
get(): K;
set(value: T): void;
} & {
wrap<P>(set: () => T, get: (data: K) => P): Value<void, P>;
wrap<P, M = T>(set: (data: M) => T, get: (data: K) => P): Value<M, P>;
wrap(set: () => T): Value<void, K>;
wrap<M = T>(set: (data: M) => T): Value<M, K>;
filter(fn: (data: T) => any): Value<T, K>;
wrap: {
<P>(set: () => T, get: (data: K) => P): Value<void, P>;
<P, M = T>(set: (data: M) => T, get: (data: K) => P): Value<M, P>;
(set: () => T): Value<void, K>;
<M = T>(set: (data: M) => T): Value<M, K>;
filter(fn: (data: T) => any): Value<T, K>;
};
view<P>(get: (data: K) => P): Value<T, P>;

@@ -63,2 +65,8 @@ select<P>(get: (data: K) => P): Selector<P>;

reset(): void;
update: (fn: (state: K) => T) => void;
sub: {
<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void;
once<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void;
};
set(value: T): void;
}> = Callable<T> & Pick<Promise<T>, 'then' | 'catch' | 'finally'> & {

@@ -70,7 +78,9 @@ 0: () => K;

} & {
wrap<P>(set: () => T, get: (data: K) => P): Signal<void, P, X, E>;
wrap<P, M = T>(set: (data: M) => T, get: (data: K) => P): Signal<M, P, X, E>;
wrap(set: () => T): Signal<void, K, X, E>;
wrap<M = T>(set: (data: M) => T): Signal<M, K, X, E>;
filter(fn: (data: T) => any): Signal<T, K, X, E>;
wrap: {
<P>(set: () => T, get: (data: K) => P): Signal<void, P, X, E>;
<P, M = T>(set: (data: M) => T, get: (data: K) => P): Signal<M, P, X, E>;
(set: () => T): Signal<void, K, X, E>;
<M = T>(set: (data: M) => T): Signal<M, K, X, E>;
filter(fn: (data: T) => any): Signal<T, K, X, E>;
};
view<P>(get: (data: K) => P): Signal<T, P, X, E>;

@@ -91,2 +101,7 @@ select<P>(get: (data: K) => P): Selector<P>;

stop(): void;
set(): void;
sub: {
(reactionable: Reactionable<any>): () => void;
once(reactionable: Reactionable<any>): () => void;
};
}, {}>;

@@ -93,0 +108,0 @@ declare type ReadySignal<T, K = T> = Signal<T, K, {

@@ -46,3 +46,3 @@ "use strict";

let is_sync;
let no_reset;
let is_stop_signal;
let is_observe;

@@ -77,3 +77,3 @@ let scope_context;

resolve = def_promisify(fn);
def_format(fn, () => get()[0], fn, 1);
def_format(fn, () => get()[0], fn, 0, 1);
fn.reset = () => set([init]);

@@ -97,4 +97,4 @@ return fn;

resolve = def_promisify(fn);
def_format(fn, () => get()[0], fn, 1, 1);
if (!no_reset) {
def_format(fn, () => get()[0], fn, is_stop_signal, 1, 1);
if (!is_stop_signal) {
fn.reset = () => {

@@ -110,3 +110,3 @@ resolve = def_promisify(fn);

function stop_signal() {
no_reset = 1;
is_stop_signal = 1;
try {

@@ -117,6 +117,6 @@ const ctx = ready(false).to(true);

finally {
no_reset = 0;
is_stop_signal = 0;
}
}
function def_format(ctx, get, set, no_set_update, has_to) {
function def_format(ctx, get, set, no_update, readonly_val, has_to) {
if (!Array.isArray(ctx)) {

@@ -134,9 +134,10 @@ ctx[Symbol.iterator] = function* () {

ctx[1] = set;
if (!no_set_update) {
ctx.set = set;
if (!no_update) {
ctx.update = (fn) => set(fn(get()));
}
ctx.set = set;
if (!readonly_val)
val_prop.set = set;
ctx.sub = (s, fn) => on(s, (v, v_prev) => set(fn(get(), v, v_prev)));
ctx.sub.once = (s, fn) => once(s, (v, v_prev) => set(fn(get(), v, v_prev)));
}
ctx.sub = (s, fn) => on(s, (v, v_prev) => set(fn ? fn(get(), v, v_prev) : void 0));
ctx.sub.once = (s, fn) => once(s, (v, v_prev) => set(fn ? fn(get(), v, v_prev) : void 0));
}

@@ -149,3 +150,3 @@ def_prop(ctx, key, val_prop);

ctx.wrap = (set, get) => wrap(ctx, set, get);
ctx.filter = (fn) => wrap(ctx, (v) => (fn(v) ? v : stoppable().stop()));
ctx.wrap.filter = (fn) => wrap(ctx, (v) => (fn(v) ? v : stoppable().stop()));
}

@@ -217,3 +218,3 @@ ctx.view = (get) => wrap(ctx, 0, get);

target.stop = target;
def_format(dest, get ? () => get(source_get()) : source_get, dest_set || source_set, !target.update, target.to);
def_format(dest, get ? () => get(source_get()) : source_get, dest_set || source_set, !target.update, target.then, target.to);
return dest;

@@ -220,0 +221,0 @@ }

{
"name": "realar",
"version": "0.5.25",
"version": "0.5.26",
"description": "React state manager",

@@ -88,3 +88,3 @@ "repository": {

},
"gitHead": "fcfd72b2963e25713744f9b1f57048ceb22c1a4b"
"gitHead": "dbc0f2b37250f7353e0900974774200c6a7879ee"
}

@@ -76,3 +76,3 @@ import React, { Context, FC } from 'react';

let is_sync: any;
let no_reset: any;
let is_stop_signal: any;
let is_observe: any;

@@ -117,4 +117,5 @@ let scope_context: any;

val: T & K;
get(): K;
update: (fn: (state: K) => T) => void;
sub: {

@@ -124,12 +125,12 @@ <S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void;

};
get(): K;
set(value: T): void;
} & {
wrap<P>(set: () => T, get: (data: K) => P): Value<void, P>;
wrap<P, M = T>(set: (data: M) => T, get: (data: K) => P): Value<M, P>;
wrap(set: () => T): Value<void, K>;
wrap<M = T>(set: (data: M) => T): Value<M, K>;
wrap: {
<P>(set: () => T, get: (data: K) => P): Value<void, P>;
<P, M = T>(set: (data: M) => T, get: (data: K) => P): Value<M, P>;
(set: () => T): Value<void, K>;
<M = T>(set: (data: M) => T): Value<M, K>;
filter(fn: (data: T) => any): Value<T, K>;
filter(fn: (data: T) => any): Value<T, K>;
}

@@ -149,15 +150,25 @@ view<P>(get: (data: K) => P): Value<T, P>;

type Signal<T, K = T, X = {}, E = { reset(): void }> = Callable<T> &
type Signal<T, K = T, X = {}, E = {
reset(): void;
update: (fn: (state: K) => T) => void;
sub: {
<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void;
once<S>(reactionable: Reactionable<S>, fn: (data?: K, value?: S, prev?: S) => T): () => void;
};
set(value: T): void;
}> = Callable<T> &
Pick<Promise<T>, 'then' | 'catch' | 'finally'> & {
0: () => K;
1: (value: T) => void;
readonly val: K;
readonly val: K
get(): K;
} & {
wrap<P>(set: () => T, get: (data: K) => P): Signal<void, P, X, E>;
wrap<P, M = T>(set: (data: M) => T, get: (data: K) => P): Signal<M, P, X, E>;
wrap(set: () => T): Signal<void, K, X, E>;
wrap<M = T>(set: (data: M) => T): Signal<M, K, X, E>;
wrap: {
<P>(set: () => T, get: (data: K) => P): Signal<void, P, X, E>;
<P, M = T>(set: (data: M) => T, get: (data: K) => P): Signal<M, P, X, E>;
(set: () => T): Signal<void, K, X, E>;
<M = T>(set: (data: M) => T): Signal<M, K, X, E>;
filter(fn: (data: T) => any): Signal<T, K, X, E>;
filter(fn: (data: T) => any): Signal<T, K, X, E>;
}

@@ -184,2 +195,7 @@ view<P>(get: (data: K) => P): Signal<T, P, X, E>;

stop(): void;
set(): void;
sub: {
(reactionable: Reactionable<any>): () => void;
once(reactionable: Reactionable<any>): () => void;
};
},

@@ -233,3 +249,3 @@ {}

resolve = def_promisify(fn);
def_format(fn, () => get()[0], fn, 1);
def_format(fn, () => get()[0], fn, 0, 1);
fn.reset = () => set([init]);

@@ -258,5 +274,5 @@ return fn as any;

resolve = def_promisify(fn);
def_format(fn, () => get()[0], fn, 1, 1);
def_format(fn, () => get()[0], fn, is_stop_signal, 1, 1);
if (!no_reset) {
if (!is_stop_signal) {
fn.reset = () => {

@@ -273,3 +289,3 @@ resolve = def_promisify(fn);

function stop_signal(): StopSignal {
no_reset = 1;
is_stop_signal = 1;
try {

@@ -279,7 +295,7 @@ const ctx = ready(false).to(true) as any;

} finally {
no_reset = 0;
is_stop_signal = 0;
}
}
function def_format(ctx: any, get: any, set?: any, no_set_update?: any, has_to?: any) {
function def_format(ctx: any, get: any, set?: any, no_update?: any, readonly_val?: any, has_to?: any) {
if (!Array.isArray(ctx)) {

@@ -297,9 +313,10 @@ ctx[Symbol.iterator] = function* () {

ctx[1] = set;
if (!no_set_update) {
ctx.set = set;
if (!no_update) {
ctx.update = (fn: any) => set(fn(get()));
val_prop.set = set;
ctx.sub = (s: any, fn: any) => on(s, (v, v_prev) => set(fn(get(), v, v_prev)));
ctx.sub.once = (s: any, fn: any) => once(s, (v, v_prev) => set(fn(get(), v, v_prev)));
}
ctx.set = set;
if (!readonly_val) val_prop.set = set;
ctx.sub = (s: any, fn: any) => on(s, (v, v_prev) => set(fn ? fn(get(), v, v_prev) : void 0));
ctx.sub.once = (s: any, fn: any) => once(s, (v, v_prev) => set(fn ? fn(get(), v, v_prev) : void 0));
}

@@ -313,3 +330,3 @@ def_prop(ctx, key, val_prop);

ctx.wrap = (set: any, get: any) => wrap(ctx, set, get);
ctx.filter = (fn: any) => wrap(ctx, (v: any) => (fn(v) ? v : stoppable().stop()));
ctx.wrap.filter = (fn: any) => wrap(ctx, (v: any) => (fn(v) ? v : stoppable().stop()));
}

@@ -388,2 +405,3 @@ ctx.view = (get: any) => wrap(ctx, 0, get);

!target.update,
target.then,
target.to

@@ -390,0 +408,0 @@ );

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