fp-tuple

1.0.8 • Public • Published

TupleJS

Getting Started

$ npm i --save touplejs

Usage

// ResponseStatus('ok', {data: {someData: 3}})
const ResponseStatus = Tuple(String, 'any')
 
const apiResponse = ResponseStatus('ok', {data: 'asdf'})
const serverResp = ResponseStatus('error', {error: 'there was an error'})
 
serverResp.equals(apiResponse) // false
 
const [, error] = serverResp
const [status, data] = apiResponse

Methods

Tuple - Used to create a tuple

(types) -> Function Allows creation of tuples with type saftey

For demo's I will be using a Name tuple (Tuple(String, String))

map

const myName = Name('first', 'last')
 
myName.map((item) => item.toUpperCase())

reduce

const myName = Name('Steve', 'Jobs')
 
myName.reduce('', R.concat) // 'SteveJobs'

equals

Name('Steve', 'Jobs').equals(Name('Steve', 'Wozniak')) // false

length

Name('Steve', 'Jobs').length // 2

Readme

Keywords

Package Sidebar

Install

npm i fp-tuple

Weekly Downloads

27

Version

1.0.8

License

MIT

Last publish

Collaborators

  • mikaak