1.0.8 • Published 7 years ago

fp-tuple v1.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

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
1.0.8

7 years ago

1.0.7

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago