Comparing version 0.2.0-beta.42 to 0.2.0-beta.43
import { FieldModel } from './models/field'; | ||
import { ValidateOption } from './validate'; | ||
export declare function useMAppendWith<Value>(model: FieldModel<Value>, ...args: ((model: FieldModel<Value>) => (value: Value) => void)[]): (value: Value) => void; | ||
export declare function useMAppend<T>(...fns: ((t: T) => void)[]): (t: T) => void; | ||
export declare function usePipe<T0, T1, T2>(fn0: (t0: T0) => T1, fn1: (t1: T1) => T2): (t0: T0) => T2; | ||
@@ -5,0 +5,0 @@ export declare function usePipe<T0, T1, T2, T3>(fn0: (t0: T0) => T1, fn1: (t1: T1) => T2, fn2: (t2: T2) => T3): (t0: T0) => T3; |
import { useCallback, useMemo, useRef } from 'react'; | ||
import { unstable_IdlePriority as IdlePriority, unstable_scheduleCallback as scheduleCallback, } from 'scheduler'; | ||
export function useMAppendWith(model) { | ||
var args = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args[_i - 1] = arguments[_i]; | ||
export function useMAppend() { | ||
var fns = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
fns[_i] = arguments[_i]; | ||
} | ||
return useMemo(function () { | ||
var fns = args.map(function (it) { return it(model); }); | ||
return function (value) { | ||
for (var i = 0; i < fns.length; i += 1) { | ||
var f = fns[i]; | ||
f(value); | ||
} | ||
}; | ||
}, [model].concat(args)); | ||
return useCallback(function (value) { | ||
for (var i = 0; i < fns.length; i += 1) { | ||
var f = fns[i]; | ||
f(value); | ||
} | ||
}, fns); | ||
} | ||
@@ -24,3 +21,3 @@ export function usePipe() { | ||
return useMemo(function () { | ||
var fn = args.reduce(function (next, f) { return function (arg) { return next(f(arg)); }; }, function (arg) { return arg; }); | ||
var fn = args.reduceRight(function (next, f) { return function (arg) { return next(f(arg)); }; }, function (arg) { return arg; }); | ||
return function (t) { return fn(t); }; | ||
@@ -27,0 +24,0 @@ }, args); |
{ | ||
"name": "formulr", | ||
"version": "0.2.0-beta.42", | ||
"version": "0.2.0-beta.43", | ||
"description": "Form toolkit for React", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -10,15 +10,9 @@ import { useCallback, useMemo, useRef } from 'react'; | ||
export function useMAppendWith<Value>( | ||
model: FieldModel<Value>, | ||
...args: ((model: FieldModel<Value>) => (value: Value) => void)[] | ||
): (value: Value) => void { | ||
return useMemo(() => { | ||
const fns = args.map(it => it(model)); | ||
return (value: Value) => { | ||
for (let i = 0; i < fns.length; i += 1) { | ||
const f = fns[i]; | ||
f(value); | ||
} | ||
}; | ||
}, [model as any].concat(args)); | ||
export function useMAppend<T>(...fns: ((t: T) => void)[]): (t: T) => void { | ||
return useCallback((value: T) => { | ||
for (let i = 0; i < fns.length; i += 1) { | ||
const f = fns[i]; | ||
f(value); | ||
} | ||
}, fns); | ||
} | ||
@@ -71,3 +65,3 @@ | ||
return useMemo(() => { | ||
const fn = args.reduce((next, f) => (arg: any) => next(f(arg)), (arg: any) => arg); | ||
const fn = args.reduceRight((next, f) => (arg: any) => next(f(arg)), (arg: any) => arg); | ||
return (t: T): R => fn(t); | ||
@@ -74,0 +68,0 @@ }, args); |
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
7
202572
3686