fp-tuple
v1.0.8
Published
Tuples in javascript!
Downloads
60
Readme
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