Socket
Book a DemoInstallSign in
Socket

@action-land/core

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@action-land/core

Typeclass for action

latest
npmnpm
Version
8.0.0
Version published
Weekly downloads
1.9K
25.6%
Maintainers
1
Weekly downloads
 
Created
Source

@action-type/core

Core library for action.

Index

  • Installation
  • Specification
  • Action
  • API
  • Related Libraries

Installation

npm i @action-land/core

Specification

  • An Action consists of two properties viz. type and value.
  • action.type is of type string or number.
  • action.value is of type any. It could also be of type Action
  • The object is an immutable and should never be updated.

Action Type

An action is an object which contains two properties — type and value.

interface Action<T> {
  type: string
  value: T
}

API

action

A utility that helps in creating a new object of action type. The function is curried by default and provides type guarantee.

import {action} from '@action-land/core'

action('click', {x: 10, y: 20})

action('click')({x: 10, y: 20}) // curried version

isAction

A utility function that detects if the object is of Action type.

import {isAction} from '@action-land/core'

isAction({}) // returns false
isAction(action('WWW', null)) // returns true

Nil

A default action that represents nothingness.

import {Nil} from '@action-land/core'

function logic(a: number) {
  if (a > 10) return action('greater', a - 10)
  if (a < 10) return action('lesser', 10 - a)
  return Nil
}

List

A utility function that creates an Action from a list of Action[].

import {List} from '@action-land/core'

const list = List(action('A', 1), action('B', 2))

isList

A utility function that checks if the action is of list type

import {isList} from '@action-land/core'

const list = List(action('A', 1), action('B', 2))

isList(list) //true

isNil

A utility function that checks if the action is of Nil

import {isNil, Nil} from '@action-land/core'

isNil(Nil) // true
isNil({type: '@@NIL', value: {}}) // true
isNil({type: 'click', value: {}}) // false

FAQs

Package last updated on 22 Aug 2019

Did you know?

Socket

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.

Install

Related posts