ts-pair
Pair classes for TypeScript and JavaScript
Install
npm install ts-pair --save
Example
;console.log pair.first, ', ', pair.second ; // 1, Helloconsole.log 'Pair is ' + pair ; // Pair is [ 1, Hello ] pair.first = 2;pair.second = "hi"; console.log 'JSON', pair.toJSON ; // Pair is { "first": 2, "second": "hi" } ;console.log first, second ; // 2, hi // chainableconsole.log pair.setFirst 10 .setSecond "bye" .toString ; // [ 10, bye ] ;console.log otherPair.equals pair ? 'equal': 'different' ; // different ;console.log aImmutable.equals otherPair ? 'equal': 'different' ; // equal aImmutable.first = "baz"; // Error
Available Types
IPair
interface, withgetFirst()
,getSecond()
,equals()
,toArray()
, andtoJSON()
AbstractPair
that implementsIPair
and declarestoString()
Pair
that extendsAbstractPair
ImmutablePair
that extendsAbstractPair