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

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.814latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.814
1.0.70
1.0.50
1.0.40
1.0.30
1.0.10

Package Sidebar

Install

npm i fp-tuple

Weekly Downloads

14

Version

1.0.8

License

MIT

Last publish

Collaborators

  • mikaak