Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@action-land/tarz
Advanced tools
Readme
Provides a specification and basic type classes for update function. Essentially there are two kinds of update functions —
ReducerFunction
: takes in action
and state
and returns a new state
.CommandFunction
: takes in action
and state
and return a new action
.Value
and State
.State
.export type ReducerFunction<Value, State> = {
(value: Value, state: State): State
}
Value
and State
.Action
. It can consider returning Nil if no meaningful value is intended.export type CommandFunction<Value, State, Output> = {
(value: Value, state: State): Action<Output>
}
Takes in multiple ReducerFunction
(s) as arguments and returns a new ReducerFunction
as a result.
ReducerFunction
(s) R0
R1
then two statements will be logically equivalent —
concatR(R0, R1)(action, state)
R1(action, R0(action, state))
concatR(concatR(R0, R1), R2) === concatR(R0, concatR(R1, R2))
concatR(R0, zeroR) === R0
.Usage
import {concatR} from 'update-function-type'
const R0 = (a, b) => a + b
const R1 = (a, b) => a * b
concatR(R0, R1)(10, 20) // 10 * (10 + 20) === 300
Takes in multiple CommandFunction
(s) as arguments and returns a new CommandFunction
as a result.
CommandFunction
(s) C0
C1
then two statements will be logically equivalent —
concatC(C0, C1)(action, state)
List(C0(action, state), C1(action, state))
concatC(concatC(C0, C1), C2) === concatC(C0, concatC(C1, C2))
concatC(C0, zeroC) === C0
Usage
import {concatC} from 'update-function-type'
const C0 = (a, b) => action('+', a + b)
const C1 = (a, b) => action('*', a * b)
concatC(C0, C1)(10, 500) // List(action('+', 510), action('B', 5000))
ReducerFunction
(s) and returns another ReducerFunction
.Action
and State
internally calls the function matching the action's type.Usage
import {matchR} from 'update-function-type'
const reducer = matchR({
add: (a, b) => a + b,
mul: (a, b) => a * b
})
reducer(action('add', 10), 1000) // returns 1010
CommandFunction
(s) and returns another CommandFunction
.Action
and State
internally calls the function matching the action's type.Usage
import {matchC} from 'update-function-type'
const reducer = matchC({
add: (a, b) => action('added', a + b),
mul: (a, b) => action('multiplied', a * b)
})
reducer(action('add', 10), 1000) // returns action('added', 1010)
ReducerFunction
.action
and a state
and returns the same state.CommandFunction
.action
and a state
and returns the same action
.FAQs
Functional utils for performing logical operations on Action
The npm package @action-land/tarz receives a total of 960 weekly downloads. As such, @action-land/tarz popularity was classified as not popular.
We found that @action-land/tarz demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.