prelude.ts
Advanced tools
Comparing version 0.1.3 to 0.2.0
var typedoc = typedoc || {}; | ||
typedoc.search = typedoc.search || {}; | ||
typedoc.search.data = {"kinds":{"4":"Enumeration","16":"Enumeration member","64":"Function","128":"Class","256":"Interface","512":"Constructor","2048":"Method","65536":"Type literal","4194304":"Type alias"},"rows":[{"id":0,"kind":4,"name":"Ordering","url":"enums/ordering.html","classes":"tsd-kind-enum"},{"id":1,"kind":16,"name":"LT","url":"enums/ordering.html#lt","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"Ordering"},{"id":2,"kind":16,"name":"EQ","url":"enums/ordering.html#eq","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"Ordering"},{"id":3,"kind":16,"name":"GT","url":"enums/ordering.html#gt","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"Ordering"},{"id":4,"kind":4194304,"name":"WithEquality","url":"globals.html#withequality","classes":"tsd-kind-type-alias"},{"id":5,"kind":4194304,"name":"HasEquals","url":"globals.html#hasequals","classes":"tsd-kind-type-alias"},{"id":6,"kind":65536,"name":"__type","url":"globals.html#hasequals.__type","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"HasEquals"},{"id":7,"kind":64,"name":"hasEquals","url":"globals.html#hasequals","classes":"tsd-kind-function"},{"id":8,"kind":64,"name":"fieldsHashCode","url":"globals.html#fieldshashcode","classes":"tsd-kind-function"},{"id":9,"kind":64,"name":"stringHashCode","url":"globals.html#stringhashcode","classes":"tsd-kind-function"},{"id":10,"kind":64,"name":"areEqual","url":"globals.html#areequal","classes":"tsd-kind-function"},{"id":11,"kind":64,"name":"getHashCode","url":"globals.html#gethashcode","classes":"tsd-kind-function"},{"id":12,"kind":256,"name":"Value","url":"interfaces/value.html","classes":"tsd-kind-interface"},{"id":13,"kind":2048,"name":"equals","url":"interfaces/value.html#equals","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Value"},{"id":14,"kind":2048,"name":"hashCode","url":"interfaces/value.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Value"},{"id":15,"kind":2048,"name":"toString","url":"interfaces/value.html#tostring","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Value"},{"id":16,"kind":256,"name":"Seq","url":"interfaces/seq.html","classes":"tsd-kind-interface tsd-has-type-parameter"},{"id":17,"kind":2048,"name":"size","url":"interfaces/seq.html#size","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":18,"kind":2048,"name":"isEmpty","url":"interfaces/seq.html#isempty","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":19,"kind":2048,"name":"toArray","url":"interfaces/seq.html#toarray","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":20,"kind":2048,"name":"appendStruct","url":"interfaces/seq.html#appendstruct","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":21,"kind":2048,"name":"append","url":"interfaces/seq.html#append","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":22,"kind":2048,"name":"appendAll","url":"interfaces/seq.html#appendall","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":23,"kind":2048,"name":"appendAllStruct","url":"interfaces/seq.html#appendallstruct","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":24,"kind":2048,"name":"forEach","url":"interfaces/seq.html#foreach","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":25,"kind":2048,"name":"head","url":"interfaces/seq.html#head","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":26,"kind":2048,"name":"last","url":"interfaces/seq.html#last","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":27,"kind":2048,"name":"tail","url":"interfaces/seq.html#tail","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":28,"kind":2048,"name":"mapStruct","url":"interfaces/seq.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":29,"kind":2048,"name":"map","url":"interfaces/seq.html#map","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":30,"kind":2048,"name":"filter","url":"interfaces/seq.html#filter","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":31,"kind":2048,"name":"find","url":"interfaces/seq.html#find","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":32,"kind":2048,"name":"flatMap","url":"interfaces/seq.html#flatmap","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":33,"kind":2048,"name":"flatMapStruct","url":"interfaces/seq.html#flatmapstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":34,"kind":2048,"name":"groupBy","url":"interfaces/seq.html#groupby","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":35,"kind":2048,"name":"sortBy","url":"interfaces/seq.html#sortby","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":36,"kind":2048,"name":"prependStruct","url":"interfaces/seq.html#prependstruct","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":37,"kind":2048,"name":"prepend","url":"interfaces/seq.html#prepend","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":38,"kind":2048,"name":"prependAll","url":"interfaces/seq.html#prependall","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":39,"kind":2048,"name":"prependAllStruct","url":"interfaces/seq.html#prependallstruct","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":40,"kind":2048,"name":"foldLeft","url":"interfaces/seq.html#foldleft","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":41,"kind":2048,"name":"foldRight","url":"interfaces/seq.html#foldright","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":42,"kind":2048,"name":"mkString","url":"interfaces/seq.html#mkstring","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":43,"kind":2048,"name":"zip","url":"interfaces/seq.html#zip","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":44,"kind":2048,"name":"zipStruct","url":"interfaces/seq.html#zipstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":45,"kind":2048,"name":"get","url":"interfaces/seq.html#get","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":46,"kind":2048,"name":"drop","url":"interfaces/seq.html#drop","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":47,"kind":2048,"name":"dropWhile","url":"interfaces/seq.html#dropwhile","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":48,"kind":2048,"name":"dropRight","url":"interfaces/seq.html#dropright","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":49,"kind":2048,"name":"takeWhile","url":"interfaces/seq.html#takewhile","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":50,"kind":2048,"name":"distinctBy","url":"interfaces/seq.html#distinctby","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":51,"kind":2048,"name":"reverse","url":"interfaces/seq.html#reverse","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":52,"kind":2048,"name":"partition","url":"interfaces/seq.html#partition","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":53,"kind":2048,"name":"toMap","url":"interfaces/seq.html#tomap","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":54,"kind":2048,"name":"toMapStruct","url":"interfaces/seq.html#tomapstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":55,"kind":2048,"name":"equals","url":"interfaces/seq.html#equals","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"Seq"},{"id":56,"kind":2048,"name":"hashCode","url":"interfaces/seq.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"Seq"},{"id":57,"kind":2048,"name":"toString","url":"interfaces/seq.html#tostring","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"Seq"},{"id":58,"kind":256,"name":"ISet","url":"interfaces/iset.html","classes":"tsd-kind-interface tsd-has-type-parameter"},{"id":59,"kind":2048,"name":"size","url":"interfaces/iset.html#size","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":60,"kind":2048,"name":"isEmpty","url":"interfaces/iset.html#isempty","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":61,"kind":2048,"name":"add","url":"interfaces/iset.html#add","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":62,"kind":2048,"name":"contains","url":"interfaces/iset.html#contains","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":63,"kind":2048,"name":"diff","url":"interfaces/iset.html#diff","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":64,"kind":2048,"name":"removeAll","url":"interfaces/iset.html#removeall","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":65,"kind":2048,"name":"toArray","url":"interfaces/iset.html#toarray","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":66,"kind":2048,"name":"equals","url":"interfaces/iset.html#equals","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"ISet"},{"id":67,"kind":2048,"name":"hashCode","url":"interfaces/iset.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"ISet"},{"id":68,"kind":2048,"name":"toString","url":"interfaces/iset.html#tostring","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"ISet"},{"id":69,"kind":128,"name":"HashSet","url":"classes/hashset.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":70,"kind":2048,"name":"empty","url":"classes/hashset.html#empty","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"HashSet"},{"id":71,"kind":2048,"name":"ofIterable","url":"classes/hashset.html#ofiterable","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"HashSet"},{"id":72,"kind":2048,"name":"of","url":"classes/hashset.html#of","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"HashSet"},{"id":73,"kind":2048,"name":"__@iterator","url":"classes/hashset.html#___iterator","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":74,"kind":2048,"name":"add","url":"classes/hashset.html#add","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":75,"kind":2048,"name":"contains","url":"classes/hashset.html#contains","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":76,"kind":2048,"name":"toArray","url":"classes/hashset.html#toarray","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":77,"kind":2048,"name":"size","url":"classes/hashset.html#size","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":78,"kind":2048,"name":"isEmpty","url":"classes/hashset.html#isempty","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":79,"kind":2048,"name":"diff","url":"classes/hashset.html#diff","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":80,"kind":2048,"name":"removeAll","url":"classes/hashset.html#removeall","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":81,"kind":2048,"name":"equals","url":"classes/hashset.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":82,"kind":2048,"name":"hashCode","url":"classes/hashset.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":83,"kind":2048,"name":"toString","url":"classes/hashset.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":84,"kind":128,"name":"Vector","url":"classes/vector.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":85,"kind":2048,"name":"empty","url":"classes/vector.html#empty","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Vector"},{"id":86,"kind":2048,"name":"ofIterableStruct","url":"classes/vector.html#ofiterablestruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Vector"},{"id":87,"kind":2048,"name":"ofIterable","url":"classes/vector.html#ofiterable","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Vector"},{"id":88,"kind":2048,"name":"ofStruct","url":"classes/vector.html#ofstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Vector"},{"id":89,"kind":2048,"name":"of","url":"classes/vector.html#of","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Vector"},{"id":90,"kind":2048,"name":"__@iterator","url":"classes/vector.html#___iterator","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":91,"kind":2048,"name":"toArray","url":"classes/vector.html#toarray","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":92,"kind":2048,"name":"size","url":"classes/vector.html#size","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":93,"kind":2048,"name":"isEmpty","url":"classes/vector.html#isempty","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":94,"kind":2048,"name":"head","url":"classes/vector.html#head","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":95,"kind":2048,"name":"last","url":"classes/vector.html#last","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":96,"kind":2048,"name":"tail","url":"classes/vector.html#tail","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":97,"kind":2048,"name":"appendStruct","url":"classes/vector.html#appendstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":98,"kind":2048,"name":"append","url":"classes/vector.html#append","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":99,"kind":2048,"name":"prependStruct","url":"classes/vector.html#prependstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":100,"kind":2048,"name":"prepend","url":"classes/vector.html#prepend","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":101,"kind":2048,"name":"prependAll","url":"classes/vector.html#prependall","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":102,"kind":2048,"name":"prependAllStruct","url":"classes/vector.html#prependallstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":103,"kind":2048,"name":"forEach","url":"classes/vector.html#foreach","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":104,"kind":2048,"name":"appendAllStruct","url":"classes/vector.html#appendallstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":105,"kind":2048,"name":"appendAll","url":"classes/vector.html#appendall","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":106,"kind":2048,"name":"mapStruct","url":"classes/vector.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":107,"kind":2048,"name":"map","url":"classes/vector.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":108,"kind":2048,"name":"filter","url":"classes/vector.html#filter","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":109,"kind":2048,"name":"find","url":"classes/vector.html#find","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":110,"kind":2048,"name":"flatMapStruct","url":"classes/vector.html#flatmapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":111,"kind":2048,"name":"flatMap","url":"classes/vector.html#flatmap","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":112,"kind":2048,"name":"foldLeft","url":"classes/vector.html#foldleft","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":113,"kind":2048,"name":"foldRight","url":"classes/vector.html#foldright","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":114,"kind":2048,"name":"mkString","url":"classes/vector.html#mkstring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":115,"kind":2048,"name":"get","url":"classes/vector.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":116,"kind":2048,"name":"drop","url":"classes/vector.html#drop","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":117,"kind":2048,"name":"dropWhile","url":"classes/vector.html#dropwhile","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":118,"kind":2048,"name":"takeWhile","url":"classes/vector.html#takewhile","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":119,"kind":2048,"name":"dropRight","url":"classes/vector.html#dropright","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":120,"kind":2048,"name":"sortBy","url":"classes/vector.html#sortby","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":121,"kind":2048,"name":"groupBy","url":"classes/vector.html#groupby","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":122,"kind":2048,"name":"toMap","url":"classes/vector.html#tomap","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":123,"kind":2048,"name":"toMapStruct","url":"classes/vector.html#tomapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":124,"kind":2048,"name":"zipStruct","url":"classes/vector.html#zipstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":125,"kind":2048,"name":"zip","url":"classes/vector.html#zip","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":126,"kind":2048,"name":"reverse","url":"classes/vector.html#reverse","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":127,"kind":2048,"name":"partition","url":"classes/vector.html#partition","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":128,"kind":2048,"name":"distinctBy","url":"classes/vector.html#distinctby","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":129,"kind":2048,"name":"equals","url":"classes/vector.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":130,"kind":2048,"name":"hashCode","url":"classes/vector.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":131,"kind":2048,"name":"toString","url":"classes/vector.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":132,"kind":128,"name":"Option","url":"classes/option.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":133,"kind":2048,"name":"of","url":"classes/option.html#of","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":134,"kind":2048,"name":"ofStruct","url":"classes/option.html#ofstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":135,"kind":2048,"name":"none","url":"classes/option.html#none","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":136,"kind":2048,"name":"sequence","url":"classes/option.html#sequence","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":137,"kind":2048,"name":"liftA2","url":"classes/option.html#lifta2","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":138,"kind":2048,"name":"liftA2Struct","url":"classes/option.html#lifta2struct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":139,"kind":2048,"name":"isSome","url":"classes/option.html#issome","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":140,"kind":2048,"name":"isNone","url":"classes/option.html#isnone","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":141,"kind":2048,"name":"orElse","url":"classes/option.html#orelse","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":142,"kind":2048,"name":"getOrThrow","url":"classes/option.html#getorthrow","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":143,"kind":2048,"name":"getOrElse","url":"classes/option.html#getorelse","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":144,"kind":2048,"name":"contains","url":"classes/option.html#contains","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":145,"kind":2048,"name":"getOrUndefined","url":"classes/option.html#getorundefined","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":146,"kind":2048,"name":"map","url":"classes/option.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Option"},{"id":147,"kind":2048,"name":"mapStruct","url":"classes/option.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Option"},{"id":148,"kind":2048,"name":"flatMap","url":"classes/option.html#flatmap","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Option"},{"id":149,"kind":2048,"name":"flatMapStruct","url":"classes/option.html#flatmapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Option"},{"id":150,"kind":2048,"name":"filter","url":"classes/option.html#filter","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":151,"kind":2048,"name":"toVector","url":"classes/option.html#tovector","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":152,"kind":2048,"name":"equals","url":"classes/option.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":153,"kind":2048,"name":"hashCode","url":"classes/option.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":154,"kind":2048,"name":"toString","url":"classes/option.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":155,"kind":256,"name":"IMap","url":"interfaces/imap.html","classes":"tsd-kind-interface tsd-has-type-parameter"},{"id":156,"kind":2048,"name":"keySet","url":"interfaces/imap.html#keyset","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":157,"kind":2048,"name":"valueSet","url":"interfaces/imap.html#valueset","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":158,"kind":2048,"name":"get","url":"interfaces/imap.html#get","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":159,"kind":2048,"name":"put","url":"interfaces/imap.html#put","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":160,"kind":2048,"name":"putStruct","url":"interfaces/imap.html#putstruct","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":161,"kind":2048,"name":"putWithMerge","url":"interfaces/imap.html#putwithmerge","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":162,"kind":2048,"name":"putStructWithMerge","url":"interfaces/imap.html#putstructwithmerge","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":163,"kind":2048,"name":"mapStruct","url":"interfaces/imap.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"IMap"},{"id":164,"kind":2048,"name":"map","url":"interfaces/imap.html#map","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"IMap"},{"id":165,"kind":2048,"name":"mapValuesStruct","url":"interfaces/imap.html#mapvaluesstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"IMap"},{"id":166,"kind":2048,"name":"mapValues","url":"interfaces/imap.html#mapvalues","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"IMap"},{"id":167,"kind":2048,"name":"toVector","url":"interfaces/imap.html#tovector","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":168,"kind":2048,"name":"size","url":"interfaces/imap.html#size","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":169,"kind":2048,"name":"isEmpty","url":"interfaces/imap.html#isempty","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":170,"kind":2048,"name":"mergeWith","url":"interfaces/imap.html#mergewith","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":171,"kind":2048,"name":"equals","url":"interfaces/imap.html#equals","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"IMap"},{"id":172,"kind":2048,"name":"hashCode","url":"interfaces/imap.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"IMap"},{"id":173,"kind":2048,"name":"toString","url":"interfaces/imap.html#tostring","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"IMap"},{"id":174,"kind":128,"name":"HashMap","url":"classes/hashmap.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":175,"kind":512,"name":"constructor","url":"classes/hashmap.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-protected","parent":"HashMap"},{"id":176,"kind":2048,"name":"empty","url":"classes/hashmap.html#empty","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"HashMap"},{"id":177,"kind":2048,"name":"get","url":"classes/hashmap.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":178,"kind":2048,"name":"__@iterator","url":"classes/hashmap.html#___iterator","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":179,"kind":2048,"name":"putStruct","url":"classes/hashmap.html#putstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":180,"kind":2048,"name":"put","url":"classes/hashmap.html#put","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":181,"kind":2048,"name":"putStructWithMerge","url":"classes/hashmap.html#putstructwithmerge","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":182,"kind":2048,"name":"putWithMerge","url":"classes/hashmap.html#putwithmerge","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":183,"kind":2048,"name":"size","url":"classes/hashmap.html#size","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":184,"kind":2048,"name":"isEmpty","url":"classes/hashmap.html#isempty","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":185,"kind":2048,"name":"keySet","url":"classes/hashmap.html#keyset","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":186,"kind":2048,"name":"valueSet","url":"classes/hashmap.html#valueset","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":187,"kind":2048,"name":"mergeWith","url":"classes/hashmap.html#mergewith","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":188,"kind":2048,"name":"mapStruct","url":"classes/hashmap.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"HashMap"},{"id":189,"kind":2048,"name":"map","url":"classes/hashmap.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"HashMap"},{"id":190,"kind":2048,"name":"mapValuesStruct","url":"classes/hashmap.html#mapvaluesstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"HashMap"},{"id":191,"kind":2048,"name":"mapValues","url":"classes/hashmap.html#mapvalues","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"HashMap"},{"id":192,"kind":2048,"name":"toVector","url":"classes/hashmap.html#tovector","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":193,"kind":2048,"name":"equals","url":"classes/hashmap.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":194,"kind":2048,"name":"hashCode","url":"classes/hashmap.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":195,"kind":2048,"name":"toString","url":"classes/hashmap.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":196,"kind":128,"name":"Stream","url":"classes/stream.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":197,"kind":2048,"name":"iterateStruct","url":"classes/stream.html#iteratestruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":198,"kind":2048,"name":"iterate","url":"classes/stream.html#iterate","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":199,"kind":2048,"name":"continuallyStruct","url":"classes/stream.html#continuallystruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":200,"kind":2048,"name":"continually","url":"classes/stream.html#continually","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":201,"kind":2048,"name":"__@iterator","url":"classes/stream.html#___iterator","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":202,"kind":2048,"name":"isEmpty","url":"classes/stream.html#isempty","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":203,"kind":2048,"name":"head","url":"classes/stream.html#head","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":204,"kind":2048,"name":"tail","url":"classes/stream.html#tail","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":205,"kind":2048,"name":"take","url":"classes/stream.html#take","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":206,"kind":2048,"name":"takeWhile","url":"classes/stream.html#takewhile","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":207,"kind":2048,"name":"mapStruct","url":"classes/stream.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":208,"kind":2048,"name":"map","url":"classes/stream.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":209,"kind":2048,"name":"filter","url":"classes/stream.html#filter","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":210,"kind":2048,"name":"toArray","url":"classes/stream.html#toarray","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":211,"kind":2048,"name":"toVector","url":"classes/stream.html#tovector","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":212,"kind":128,"name":"Tuple2","url":"classes/tuple2.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":213,"kind":2048,"name":"of","url":"classes/tuple2.html#of","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Tuple2"},{"id":214,"kind":2048,"name":"ofStruct","url":"classes/tuple2.html#ofstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Tuple2"},{"id":215,"kind":2048,"name":"ofArray","url":"classes/tuple2.html#ofarray","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Tuple2"},{"id":216,"kind":2048,"name":"ofArrayStruct","url":"classes/tuple2.html#ofarraystruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Tuple2"},{"id":217,"kind":2048,"name":"fst","url":"classes/tuple2.html#fst","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"},{"id":218,"kind":2048,"name":"snd","url":"classes/tuple2.html#snd","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"},{"id":219,"kind":2048,"name":"map1","url":"classes/tuple2.html#map1","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Tuple2"},{"id":220,"kind":2048,"name":"map1Struct","url":"classes/tuple2.html#map1struct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Tuple2"},{"id":221,"kind":2048,"name":"map2","url":"classes/tuple2.html#map2","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Tuple2"},{"id":222,"kind":2048,"name":"map2Struct","url":"classes/tuple2.html#map2struct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Tuple2"},{"id":223,"kind":2048,"name":"map","url":"classes/tuple2.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Tuple2"},{"id":224,"kind":2048,"name":"equals","url":"classes/tuple2.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"},{"id":225,"kind":2048,"name":"hashCode","url":"classes/tuple2.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"},{"id":226,"kind":2048,"name":"toString","url":"classes/tuple2.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"}]}; | ||
typedoc.search.data = {"kinds":{"4":"Enumeration","16":"Enumeration member","64":"Function","128":"Class","256":"Interface","512":"Constructor","2048":"Method","65536":"Type literal","4194304":"Type alias"},"rows":[{"id":0,"kind":4,"name":"Ordering","url":"enums/ordering.html","classes":"tsd-kind-enum"},{"id":1,"kind":16,"name":"LT","url":"enums/ordering.html#lt","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"Ordering"},{"id":2,"kind":16,"name":"EQ","url":"enums/ordering.html#eq","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"Ordering"},{"id":3,"kind":16,"name":"GT","url":"enums/ordering.html#gt","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"Ordering"},{"id":4,"kind":4194304,"name":"WithEquality","url":"globals.html#withequality","classes":"tsd-kind-type-alias"},{"id":5,"kind":4194304,"name":"HasEquals","url":"globals.html#hasequals","classes":"tsd-kind-type-alias"},{"id":6,"kind":65536,"name":"__type","url":"globals.html#hasequals.__type","classes":"tsd-kind-type-literal tsd-parent-kind-type-alias tsd-is-not-exported","parent":"HasEquals"},{"id":7,"kind":64,"name":"hasEquals","url":"globals.html#hasequals","classes":"tsd-kind-function"},{"id":8,"kind":64,"name":"fieldsHashCode","url":"globals.html#fieldshashcode","classes":"tsd-kind-function"},{"id":9,"kind":64,"name":"stringHashCode","url":"globals.html#stringhashcode","classes":"tsd-kind-function"},{"id":10,"kind":64,"name":"areEqual","url":"globals.html#areequal","classes":"tsd-kind-function"},{"id":11,"kind":64,"name":"getHashCode","url":"globals.html#gethashcode","classes":"tsd-kind-function"},{"id":12,"kind":256,"name":"Value","url":"interfaces/value.html","classes":"tsd-kind-interface"},{"id":13,"kind":2048,"name":"equals","url":"interfaces/value.html#equals","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Value"},{"id":14,"kind":2048,"name":"hashCode","url":"interfaces/value.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Value"},{"id":15,"kind":2048,"name":"toString","url":"interfaces/value.html#tostring","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Value"},{"id":16,"kind":2048,"name":"inspect","url":"interfaces/value.html#inspect","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Value"},{"id":17,"kind":256,"name":"Seq","url":"interfaces/seq.html","classes":"tsd-kind-interface tsd-has-type-parameter"},{"id":18,"kind":2048,"name":"length","url":"interfaces/seq.html#length","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":19,"kind":2048,"name":"isEmpty","url":"interfaces/seq.html#isempty","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":20,"kind":2048,"name":"toArray","url":"interfaces/seq.html#toarray","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":21,"kind":2048,"name":"appendStruct","url":"interfaces/seq.html#appendstruct","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":22,"kind":2048,"name":"append","url":"interfaces/seq.html#append","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":23,"kind":2048,"name":"appendAll","url":"interfaces/seq.html#appendall","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":24,"kind":2048,"name":"appendAllStruct","url":"interfaces/seq.html#appendallstruct","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":25,"kind":2048,"name":"forEach","url":"interfaces/seq.html#foreach","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":26,"kind":2048,"name":"head","url":"interfaces/seq.html#head","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":27,"kind":2048,"name":"last","url":"interfaces/seq.html#last","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":28,"kind":2048,"name":"tail","url":"interfaces/seq.html#tail","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":29,"kind":2048,"name":"mapStruct","url":"interfaces/seq.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":30,"kind":2048,"name":"map","url":"interfaces/seq.html#map","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":31,"kind":2048,"name":"filter","url":"interfaces/seq.html#filter","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":32,"kind":2048,"name":"find","url":"interfaces/seq.html#find","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":33,"kind":2048,"name":"contains","url":"interfaces/seq.html#contains","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":34,"kind":2048,"name":"flatMap","url":"interfaces/seq.html#flatmap","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":35,"kind":2048,"name":"flatMapStruct","url":"interfaces/seq.html#flatmapstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":36,"kind":2048,"name":"allMatch","url":"interfaces/seq.html#allmatch","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":37,"kind":2048,"name":"anyMatch","url":"interfaces/seq.html#anymatch","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":38,"kind":2048,"name":"groupBy","url":"interfaces/seq.html#groupby","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":39,"kind":2048,"name":"sortBy","url":"interfaces/seq.html#sortby","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":40,"kind":2048,"name":"prependStruct","url":"interfaces/seq.html#prependstruct","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":41,"kind":2048,"name":"prepend","url":"interfaces/seq.html#prepend","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":42,"kind":2048,"name":"prependAll","url":"interfaces/seq.html#prependall","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":43,"kind":2048,"name":"prependAllStruct","url":"interfaces/seq.html#prependallstruct","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":44,"kind":2048,"name":"foldLeft","url":"interfaces/seq.html#foldleft","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":45,"kind":2048,"name":"foldRight","url":"interfaces/seq.html#foldright","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":46,"kind":2048,"name":"mkString","url":"interfaces/seq.html#mkstring","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":47,"kind":2048,"name":"zip","url":"interfaces/seq.html#zip","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":48,"kind":2048,"name":"zipStruct","url":"interfaces/seq.html#zipstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":49,"kind":2048,"name":"get","url":"interfaces/seq.html#get","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":50,"kind":2048,"name":"drop","url":"interfaces/seq.html#drop","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":51,"kind":2048,"name":"dropWhile","url":"interfaces/seq.html#dropwhile","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":52,"kind":2048,"name":"dropRight","url":"interfaces/seq.html#dropright","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":53,"kind":2048,"name":"takeWhile","url":"interfaces/seq.html#takewhile","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":54,"kind":2048,"name":"distinctBy","url":"interfaces/seq.html#distinctby","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":55,"kind":2048,"name":"reverse","url":"interfaces/seq.html#reverse","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":56,"kind":2048,"name":"partition","url":"interfaces/seq.html#partition","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"Seq"},{"id":57,"kind":2048,"name":"toMap","url":"interfaces/seq.html#tomap","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":58,"kind":2048,"name":"toMapStruct","url":"interfaces/seq.html#tomapstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"Seq"},{"id":59,"kind":2048,"name":"equals","url":"interfaces/seq.html#equals","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"Seq"},{"id":60,"kind":2048,"name":"hashCode","url":"interfaces/seq.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"Seq"},{"id":61,"kind":2048,"name":"toString","url":"interfaces/seq.html#tostring","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"Seq"},{"id":62,"kind":2048,"name":"inspect","url":"interfaces/seq.html#inspect","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"Seq"},{"id":63,"kind":256,"name":"ISet","url":"interfaces/iset.html","classes":"tsd-kind-interface tsd-has-type-parameter"},{"id":64,"kind":2048,"name":"length","url":"interfaces/iset.html#length","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":65,"kind":2048,"name":"isEmpty","url":"interfaces/iset.html#isempty","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":66,"kind":2048,"name":"add","url":"interfaces/iset.html#add","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":67,"kind":2048,"name":"addAll","url":"interfaces/iset.html#addall","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":68,"kind":2048,"name":"contains","url":"interfaces/iset.html#contains","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":69,"kind":2048,"name":"diff","url":"interfaces/iset.html#diff","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":70,"kind":2048,"name":"removeAll","url":"interfaces/iset.html#removeall","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":71,"kind":2048,"name":"allMatch","url":"interfaces/iset.html#allmatch","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":72,"kind":2048,"name":"anyMatch","url":"interfaces/iset.html#anymatch","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":73,"kind":2048,"name":"toArray","url":"interfaces/iset.html#toarray","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"ISet"},{"id":74,"kind":2048,"name":"equals","url":"interfaces/iset.html#equals","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"ISet"},{"id":75,"kind":2048,"name":"hashCode","url":"interfaces/iset.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"ISet"},{"id":76,"kind":2048,"name":"toString","url":"interfaces/iset.html#tostring","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"ISet"},{"id":77,"kind":2048,"name":"inspect","url":"interfaces/iset.html#inspect","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"ISet"},{"id":78,"kind":128,"name":"HashSet","url":"classes/hashset.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":79,"kind":2048,"name":"empty","url":"classes/hashset.html#empty","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"HashSet"},{"id":80,"kind":2048,"name":"ofIterable","url":"classes/hashset.html#ofiterable","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"HashSet"},{"id":81,"kind":2048,"name":"of","url":"classes/hashset.html#of","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"HashSet"},{"id":82,"kind":2048,"name":"__@iterator","url":"classes/hashset.html#___iterator","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":83,"kind":2048,"name":"add","url":"classes/hashset.html#add","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":84,"kind":2048,"name":"addAll","url":"classes/hashset.html#addall","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":85,"kind":2048,"name":"contains","url":"classes/hashset.html#contains","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":86,"kind":2048,"name":"toArray","url":"classes/hashset.html#toarray","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":87,"kind":2048,"name":"length","url":"classes/hashset.html#length","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":88,"kind":2048,"name":"isEmpty","url":"classes/hashset.html#isempty","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":89,"kind":2048,"name":"diff","url":"classes/hashset.html#diff","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":90,"kind":2048,"name":"removeAll","url":"classes/hashset.html#removeall","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":91,"kind":2048,"name":"allMatch","url":"classes/hashset.html#allmatch","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":92,"kind":2048,"name":"anyMatch","url":"classes/hashset.html#anymatch","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":93,"kind":2048,"name":"equals","url":"classes/hashset.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":94,"kind":2048,"name":"hashCode","url":"classes/hashset.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":95,"kind":2048,"name":"toString","url":"classes/hashset.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":96,"kind":2048,"name":"inspect","url":"classes/hashset.html#inspect","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashSet"},{"id":97,"kind":128,"name":"Vector","url":"classes/vector.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":98,"kind":2048,"name":"empty","url":"classes/vector.html#empty","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Vector"},{"id":99,"kind":2048,"name":"ofIterableStruct","url":"classes/vector.html#ofiterablestruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Vector"},{"id":100,"kind":2048,"name":"ofIterable","url":"classes/vector.html#ofiterable","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Vector"},{"id":101,"kind":2048,"name":"ofStruct","url":"classes/vector.html#ofstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Vector"},{"id":102,"kind":2048,"name":"of","url":"classes/vector.html#of","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Vector"},{"id":103,"kind":2048,"name":"__@iterator","url":"classes/vector.html#___iterator","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":104,"kind":2048,"name":"toArray","url":"classes/vector.html#toarray","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":105,"kind":2048,"name":"length","url":"classes/vector.html#length","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":106,"kind":2048,"name":"isEmpty","url":"classes/vector.html#isempty","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":107,"kind":2048,"name":"head","url":"classes/vector.html#head","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":108,"kind":2048,"name":"last","url":"classes/vector.html#last","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":109,"kind":2048,"name":"tail","url":"classes/vector.html#tail","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":110,"kind":2048,"name":"appendStruct","url":"classes/vector.html#appendstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":111,"kind":2048,"name":"append","url":"classes/vector.html#append","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":112,"kind":2048,"name":"prependStruct","url":"classes/vector.html#prependstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":113,"kind":2048,"name":"prepend","url":"classes/vector.html#prepend","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":114,"kind":2048,"name":"prependAll","url":"classes/vector.html#prependall","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":115,"kind":2048,"name":"prependAllStruct","url":"classes/vector.html#prependallstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":116,"kind":2048,"name":"forEach","url":"classes/vector.html#foreach","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":117,"kind":2048,"name":"appendAllStruct","url":"classes/vector.html#appendallstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":118,"kind":2048,"name":"appendAll","url":"classes/vector.html#appendall","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":119,"kind":2048,"name":"mapStruct","url":"classes/vector.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":120,"kind":2048,"name":"map","url":"classes/vector.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":121,"kind":2048,"name":"filter","url":"classes/vector.html#filter","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":122,"kind":2048,"name":"find","url":"classes/vector.html#find","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":123,"kind":2048,"name":"contains","url":"classes/vector.html#contains","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":124,"kind":2048,"name":"flatMapStruct","url":"classes/vector.html#flatmapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":125,"kind":2048,"name":"flatMap","url":"classes/vector.html#flatmap","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":126,"kind":2048,"name":"foldLeft","url":"classes/vector.html#foldleft","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":127,"kind":2048,"name":"foldRight","url":"classes/vector.html#foldright","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":128,"kind":2048,"name":"mkString","url":"classes/vector.html#mkstring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":129,"kind":2048,"name":"get","url":"classes/vector.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":130,"kind":2048,"name":"drop","url":"classes/vector.html#drop","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":131,"kind":2048,"name":"dropWhile","url":"classes/vector.html#dropwhile","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":132,"kind":2048,"name":"takeWhile","url":"classes/vector.html#takewhile","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":133,"kind":2048,"name":"dropRight","url":"classes/vector.html#dropright","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":134,"kind":2048,"name":"allMatch","url":"classes/vector.html#allmatch","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":135,"kind":2048,"name":"anyMatch","url":"classes/vector.html#anymatch","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":136,"kind":2048,"name":"sortBy","url":"classes/vector.html#sortby","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":137,"kind":2048,"name":"groupBy","url":"classes/vector.html#groupby","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":138,"kind":2048,"name":"toMap","url":"classes/vector.html#tomap","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":139,"kind":2048,"name":"toMapStruct","url":"classes/vector.html#tomapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":140,"kind":2048,"name":"zipStruct","url":"classes/vector.html#zipstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":141,"kind":2048,"name":"zip","url":"classes/vector.html#zip","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":142,"kind":2048,"name":"reverse","url":"classes/vector.html#reverse","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":143,"kind":2048,"name":"partition","url":"classes/vector.html#partition","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":144,"kind":2048,"name":"distinctBy","url":"classes/vector.html#distinctby","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Vector"},{"id":145,"kind":2048,"name":"equals","url":"classes/vector.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":146,"kind":2048,"name":"hashCode","url":"classes/vector.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":147,"kind":2048,"name":"toString","url":"classes/vector.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":148,"kind":2048,"name":"inspect","url":"classes/vector.html#inspect","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Vector"},{"id":149,"kind":128,"name":"Option","url":"classes/option.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":150,"kind":2048,"name":"of","url":"classes/option.html#of","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":151,"kind":2048,"name":"ofStruct","url":"classes/option.html#ofstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":152,"kind":2048,"name":"none","url":"classes/option.html#none","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":153,"kind":2048,"name":"sequence","url":"classes/option.html#sequence","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":154,"kind":2048,"name":"liftA2","url":"classes/option.html#lifta2","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":155,"kind":2048,"name":"liftA2Struct","url":"classes/option.html#lifta2struct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Option"},{"id":156,"kind":2048,"name":"isSome","url":"classes/option.html#issome","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":157,"kind":2048,"name":"isNone","url":"classes/option.html#isnone","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":158,"kind":2048,"name":"orElse","url":"classes/option.html#orelse","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":159,"kind":2048,"name":"getOrThrow","url":"classes/option.html#getorthrow","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":160,"kind":2048,"name":"getOrElse","url":"classes/option.html#getorelse","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":161,"kind":2048,"name":"contains","url":"classes/option.html#contains","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":162,"kind":2048,"name":"getOrUndefined","url":"classes/option.html#getorundefined","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":163,"kind":2048,"name":"map","url":"classes/option.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Option"},{"id":164,"kind":2048,"name":"mapStruct","url":"classes/option.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Option"},{"id":165,"kind":2048,"name":"flatMap","url":"classes/option.html#flatmap","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Option"},{"id":166,"kind":2048,"name":"flatMapStruct","url":"classes/option.html#flatmapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Option"},{"id":167,"kind":2048,"name":"filter","url":"classes/option.html#filter","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":168,"kind":2048,"name":"ifPresent","url":"classes/option.html#ifpresent","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":169,"kind":2048,"name":"toVector","url":"classes/option.html#tovector","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":170,"kind":2048,"name":"equals","url":"classes/option.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":171,"kind":2048,"name":"hashCode","url":"classes/option.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":172,"kind":2048,"name":"toString","url":"classes/option.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":173,"kind":2048,"name":"inspect","url":"classes/option.html#inspect","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Option"},{"id":174,"kind":256,"name":"IMap","url":"interfaces/imap.html","classes":"tsd-kind-interface tsd-has-type-parameter"},{"id":175,"kind":2048,"name":"keySet","url":"interfaces/imap.html#keyset","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":176,"kind":2048,"name":"valueSet","url":"interfaces/imap.html#valueset","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":177,"kind":2048,"name":"get","url":"interfaces/imap.html#get","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":178,"kind":2048,"name":"put","url":"interfaces/imap.html#put","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":179,"kind":2048,"name":"putStruct","url":"interfaces/imap.html#putstruct","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":180,"kind":2048,"name":"putWithMerge","url":"interfaces/imap.html#putwithmerge","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":181,"kind":2048,"name":"putStructWithMerge","url":"interfaces/imap.html#putstructwithmerge","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":182,"kind":2048,"name":"mapStruct","url":"interfaces/imap.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"IMap"},{"id":183,"kind":2048,"name":"map","url":"interfaces/imap.html#map","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"IMap"},{"id":184,"kind":2048,"name":"mapValuesStruct","url":"interfaces/imap.html#mapvaluesstruct","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"IMap"},{"id":185,"kind":2048,"name":"mapValues","url":"interfaces/imap.html#mapvalues","classes":"tsd-kind-method tsd-parent-kind-interface tsd-has-type-parameter","parent":"IMap"},{"id":186,"kind":2048,"name":"toVector","url":"interfaces/imap.html#tovector","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":187,"kind":2048,"name":"length","url":"interfaces/imap.html#length","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":188,"kind":2048,"name":"isEmpty","url":"interfaces/imap.html#isempty","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":189,"kind":2048,"name":"mergeWith","url":"interfaces/imap.html#mergewith","classes":"tsd-kind-method tsd-parent-kind-interface","parent":"IMap"},{"id":190,"kind":2048,"name":"equals","url":"interfaces/imap.html#equals","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"IMap"},{"id":191,"kind":2048,"name":"hashCode","url":"interfaces/imap.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"IMap"},{"id":192,"kind":2048,"name":"toString","url":"interfaces/imap.html#tostring","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"IMap"},{"id":193,"kind":2048,"name":"inspect","url":"interfaces/imap.html#inspect","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-inherited","parent":"IMap"},{"id":194,"kind":128,"name":"HashMap","url":"classes/hashmap.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":195,"kind":512,"name":"constructor","url":"classes/hashmap.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-protected","parent":"HashMap"},{"id":196,"kind":2048,"name":"empty","url":"classes/hashmap.html#empty","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"HashMap"},{"id":197,"kind":2048,"name":"get","url":"classes/hashmap.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":198,"kind":2048,"name":"__@iterator","url":"classes/hashmap.html#___iterator","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":199,"kind":2048,"name":"putStruct","url":"classes/hashmap.html#putstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":200,"kind":2048,"name":"put","url":"classes/hashmap.html#put","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":201,"kind":2048,"name":"putStructWithMerge","url":"classes/hashmap.html#putstructwithmerge","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":202,"kind":2048,"name":"putWithMerge","url":"classes/hashmap.html#putwithmerge","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":203,"kind":2048,"name":"length","url":"classes/hashmap.html#length","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":204,"kind":2048,"name":"isEmpty","url":"classes/hashmap.html#isempty","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":205,"kind":2048,"name":"keySet","url":"classes/hashmap.html#keyset","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":206,"kind":2048,"name":"valueSet","url":"classes/hashmap.html#valueset","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":207,"kind":2048,"name":"mergeWith","url":"classes/hashmap.html#mergewith","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":208,"kind":2048,"name":"mapStruct","url":"classes/hashmap.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"HashMap"},{"id":209,"kind":2048,"name":"map","url":"classes/hashmap.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"HashMap"},{"id":210,"kind":2048,"name":"mapValuesStruct","url":"classes/hashmap.html#mapvaluesstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"HashMap"},{"id":211,"kind":2048,"name":"mapValues","url":"classes/hashmap.html#mapvalues","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"HashMap"},{"id":212,"kind":2048,"name":"toVector","url":"classes/hashmap.html#tovector","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":213,"kind":2048,"name":"equals","url":"classes/hashmap.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":214,"kind":2048,"name":"hashCode","url":"classes/hashmap.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":215,"kind":2048,"name":"toString","url":"classes/hashmap.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":216,"kind":2048,"name":"inspect","url":"classes/hashmap.html#inspect","classes":"tsd-kind-method tsd-parent-kind-class","parent":"HashMap"},{"id":217,"kind":128,"name":"Stream","url":"classes/stream.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":218,"kind":2048,"name":"empty","url":"classes/stream.html#empty","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":219,"kind":2048,"name":"ofStruct","url":"classes/stream.html#ofstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":220,"kind":2048,"name":"of","url":"classes/stream.html#of","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":221,"kind":2048,"name":"ofArrayStruct","url":"classes/stream.html#ofarraystruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":222,"kind":2048,"name":"ofArray","url":"classes/stream.html#ofarray","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":223,"kind":2048,"name":"iterateStruct","url":"classes/stream.html#iteratestruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":224,"kind":2048,"name":"iterate","url":"classes/stream.html#iterate","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":225,"kind":2048,"name":"continuallyStruct","url":"classes/stream.html#continuallystruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":226,"kind":2048,"name":"continually","url":"classes/stream.html#continually","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Stream"},{"id":227,"kind":2048,"name":"__@iterator","url":"classes/stream.html#___iterator","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":228,"kind":2048,"name":"length","url":"classes/stream.html#length","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":229,"kind":2048,"name":"isEmpty","url":"classes/stream.html#isempty","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":230,"kind":2048,"name":"head","url":"classes/stream.html#head","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":231,"kind":2048,"name":"tail","url":"classes/stream.html#tail","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":232,"kind":2048,"name":"last","url":"classes/stream.html#last","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":233,"kind":2048,"name":"get","url":"classes/stream.html#get","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":234,"kind":2048,"name":"find","url":"classes/stream.html#find","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":235,"kind":2048,"name":"take","url":"classes/stream.html#take","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":236,"kind":2048,"name":"takeWhile","url":"classes/stream.html#takewhile","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":237,"kind":2048,"name":"drop","url":"classes/stream.html#drop","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":238,"kind":2048,"name":"dropWhile","url":"classes/stream.html#dropwhile","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":239,"kind":2048,"name":"foldLeft","url":"classes/stream.html#foldleft","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":240,"kind":2048,"name":"foldRight","url":"classes/stream.html#foldright","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":241,"kind":2048,"name":"zipStruct","url":"classes/stream.html#zipstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":242,"kind":2048,"name":"zip","url":"classes/stream.html#zip","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":243,"kind":2048,"name":"reverse","url":"classes/stream.html#reverse","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":244,"kind":2048,"name":"appendStruct","url":"classes/stream.html#appendstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":245,"kind":2048,"name":"append","url":"classes/stream.html#append","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":246,"kind":2048,"name":"appendAllStruct","url":"classes/stream.html#appendallstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":247,"kind":2048,"name":"appendAll","url":"classes/stream.html#appendall","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":248,"kind":2048,"name":"appendStreamStruct","url":"classes/stream.html#appendstreamstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":249,"kind":2048,"name":"appendStream","url":"classes/stream.html#appendstream","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":250,"kind":2048,"name":"prepend","url":"classes/stream.html#prepend","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":251,"kind":2048,"name":"prependStruct","url":"classes/stream.html#prependstruct","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":252,"kind":2048,"name":"cycle","url":"classes/stream.html#cycle","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":253,"kind":2048,"name":"mapStruct","url":"classes/stream.html#mapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":254,"kind":2048,"name":"map","url":"classes/stream.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":255,"kind":2048,"name":"flatMapStruct","url":"classes/stream.html#flatmapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":256,"kind":2048,"name":"flatMap","url":"classes/stream.html#flatmap","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":257,"kind":2048,"name":"filter","url":"classes/stream.html#filter","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":258,"kind":2048,"name":"sortBy","url":"classes/stream.html#sortby","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":259,"kind":2048,"name":"distinctBy","url":"classes/stream.html#distinctby","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":260,"kind":2048,"name":"forEach","url":"classes/stream.html#foreach","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":261,"kind":2048,"name":"mkString","url":"classes/stream.html#mkstring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":262,"kind":2048,"name":"toArray","url":"classes/stream.html#toarray","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":263,"kind":2048,"name":"toVector","url":"classes/stream.html#tovector","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":264,"kind":2048,"name":"toMap","url":"classes/stream.html#tomap","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":265,"kind":2048,"name":"toMapStruct","url":"classes/stream.html#tomapstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Stream"},{"id":266,"kind":2048,"name":"equals","url":"classes/stream.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":267,"kind":2048,"name":"toString","url":"classes/stream.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":268,"kind":2048,"name":"hashCode","url":"classes/stream.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":269,"kind":2048,"name":"inspect","url":"classes/stream.html#inspect","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Stream"},{"id":270,"kind":128,"name":"Tuple2","url":"classes/tuple2.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":271,"kind":2048,"name":"of","url":"classes/tuple2.html#of","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Tuple2"},{"id":272,"kind":2048,"name":"ofStruct","url":"classes/tuple2.html#ofstruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Tuple2"},{"id":273,"kind":2048,"name":"ofArray","url":"classes/tuple2.html#ofarray","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Tuple2"},{"id":274,"kind":2048,"name":"ofArrayStruct","url":"classes/tuple2.html#ofarraystruct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-static","parent":"Tuple2"},{"id":275,"kind":2048,"name":"fst","url":"classes/tuple2.html#fst","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"},{"id":276,"kind":2048,"name":"snd","url":"classes/tuple2.html#snd","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"},{"id":277,"kind":2048,"name":"map1","url":"classes/tuple2.html#map1","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Tuple2"},{"id":278,"kind":2048,"name":"map1Struct","url":"classes/tuple2.html#map1struct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Tuple2"},{"id":279,"kind":2048,"name":"map2","url":"classes/tuple2.html#map2","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Tuple2"},{"id":280,"kind":2048,"name":"map2Struct","url":"classes/tuple2.html#map2struct","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Tuple2"},{"id":281,"kind":2048,"name":"map","url":"classes/tuple2.html#map","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter","parent":"Tuple2"},{"id":282,"kind":2048,"name":"equals","url":"classes/tuple2.html#equals","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"},{"id":283,"kind":2048,"name":"hashCode","url":"classes/tuple2.html#hashcode","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"},{"id":284,"kind":2048,"name":"toString","url":"classes/tuple2.html#tostring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"},{"id":285,"kind":2048,"name":"inspect","url":"classes/tuple2.html#inspect","classes":"tsd-kind-method tsd-parent-kind-class","parent":"Tuple2"}]}; |
@@ -47,2 +47,8 @@ /** | ||
/** | ||
* Utility function to help converting a value to string | ||
* util.inspect seems to depend on node. | ||
* @hidden | ||
*/ | ||
export declare function toStringHelper(obj: any | null): string; | ||
/** | ||
* Enumeration used to express ordering relationships. | ||
@@ -49,0 +55,0 @@ * it's a const enum, is replaced by integers in the source. |
@@ -88,3 +88,18 @@ "use strict"; | ||
exports.getHashCode = getHashCode; | ||
/** | ||
* Utility function to help converting a value to string | ||
* util.inspect seems to depend on node. | ||
* @hidden | ||
*/ | ||
function toStringHelper(obj) { | ||
switch (obj.constructor) { | ||
case Array: | ||
return "[" + obj.map(toStringHelper) + "]"; | ||
case String: | ||
return "'" + obj + "'"; | ||
} | ||
return obj + ""; | ||
} | ||
exports.toStringHelper = toStringHelper; | ||
; | ||
//# sourceMappingURL=Comparison.js.map |
@@ -69,3 +69,3 @@ import { IMap } from "./IMap"; | ||
*/ | ||
size(): number; | ||
length(): number; | ||
/** | ||
@@ -141,2 +141,3 @@ * true if the map is empty, false otherwise. | ||
toString(): string; | ||
inspect(): string; | ||
} |
@@ -101,3 +101,3 @@ "use strict"; | ||
*/ | ||
HashMap.prototype.size = function () { | ||
HashMap.prototype.length = function () { | ||
return this.hamt.size; | ||
@@ -204,3 +204,3 @@ }; | ||
var sz = this.hamt.size; | ||
if (other.size() === 0 && sz === 0) { | ||
if (other.length() === 0 && sz === 0) { | ||
// we could get that i'm not the empty map | ||
@@ -210,3 +210,3 @@ // but my size is zero, after some filtering and such. | ||
} | ||
if (sz !== other.size()) { | ||
if (sz !== other.length()) { | ||
return false; | ||
@@ -243,4 +243,7 @@ } | ||
return "{" + | ||
this.hamt.fold(function (acc, value, key) { acc.push(key + " => " + value); return acc; }, []).join(", ") + "}"; | ||
this.hamt.fold(function (acc, value, key) { acc.push(key + " => " + Comparison_1.toStringHelper(value)); return acc; }, []).join(", ") + "}"; | ||
}; | ||
HashMap.prototype.inspect = function () { | ||
return this.toString(); | ||
}; | ||
return HashMap; | ||
@@ -282,3 +285,3 @@ }()); | ||
}; | ||
EmptyHashMap.prototype.size = function () { | ||
EmptyHashMap.prototype.length = function () { | ||
return 0; | ||
@@ -311,3 +314,3 @@ }; | ||
} | ||
return other === emptyHashMap || other.size() === 0; | ||
return other === emptyHashMap || other.length() === 0; | ||
}; | ||
@@ -314,0 +317,0 @@ EmptyHashMap.prototype.hashCode = function () { |
@@ -39,2 +39,6 @@ import { ISet } from "./ISet"; | ||
/** | ||
* Add multiple elements to this set. | ||
*/ | ||
addAll(elts: Iterable<T & WithEquality>): HashSet<T>; | ||
/** | ||
* Returns true if the element you give is present in | ||
@@ -45,2 +49,8 @@ * the set, false otherwise. | ||
/** | ||
* Return a new collection where each element was transformed | ||
* by the mapper function you give. | ||
* The resulting set may be smaller than the source. | ||
*/ | ||
map<U>(mapper: (v: T) => U & WithEquality): HashSet<U>; | ||
/** | ||
* Converts this set to an array | ||
@@ -52,3 +62,3 @@ */ | ||
*/ | ||
size(): number; | ||
length(): number; | ||
/** | ||
@@ -71,2 +81,12 @@ * true if the set is empty, false otherwise. | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
allMatch(predicate: (v: T) => boolean): boolean; | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
anyMatch(predicate: (v: T) => boolean): boolean; | ||
/** | ||
* Two objects are equal if they represent the same value, | ||
@@ -87,2 +107,3 @@ * regardless of whether they are the same object physically | ||
toString(): string; | ||
inspect(): string; | ||
} |
@@ -40,10 +40,3 @@ "use strict"; | ||
HashSet.ofIterable = function (elts) { | ||
return new HashSet(hamt.empty.mutate(function (h) { | ||
var iterator = elts[Symbol.iterator](); | ||
var curItem = iterator.next(); | ||
while (!curItem.done) { | ||
h.set(curItem.value, curItem.value); | ||
curItem = iterator.next(); | ||
} | ||
})); | ||
return new HashSet(hamt.empty).addAll(elts); | ||
}; | ||
@@ -74,2 +67,15 @@ /** | ||
/** | ||
* Add multiple elements to this set. | ||
*/ | ||
HashSet.prototype.addAll = function (elts) { | ||
return new HashSet(this.hamt.mutate(function (h) { | ||
var iterator = elts[Symbol.iterator](); | ||
var curItem = iterator.next(); | ||
while (!curItem.done) { | ||
h.set(curItem.value, curItem.value); | ||
curItem = iterator.next(); | ||
} | ||
})); | ||
}; | ||
/** | ||
* Returns true if the element you give is present in | ||
@@ -79,5 +85,15 @@ * the set, false otherwise. | ||
HashSet.prototype.contains = function (elt) { | ||
return this.hamt.get(elt) !== undefined; | ||
return this.hamt.has(elt); | ||
}; | ||
/** | ||
* Return a new collection where each element was transformed | ||
* by the mapper function you give. | ||
* The resulting set may be smaller than the source. | ||
*/ | ||
HashSet.prototype.map = function (mapper) { | ||
return this.hamt.fold(function (acc, value, key) { | ||
return acc.add(mapper(value)); | ||
}, HashSet.empty()); | ||
}; | ||
/** | ||
* Converts this set to an array | ||
@@ -91,3 +107,3 @@ */ | ||
*/ | ||
HashSet.prototype.size = function () { | ||
HashSet.prototype.length = function () { | ||
return this.hamt.size; | ||
@@ -120,2 +136,32 @@ }; | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
HashSet.prototype.allMatch = function (predicate) { | ||
var iterator = this.hamt.values(); | ||
var curItem = iterator.next(); | ||
while (!curItem.done) { | ||
if (!predicate(curItem.value)) { | ||
return false; | ||
} | ||
curItem = iterator.next(); | ||
} | ||
return true; | ||
}; | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
HashSet.prototype.anyMatch = function (predicate) { | ||
var iterator = this.hamt.values(); | ||
var curItem = iterator.next(); | ||
while (!curItem.done) { | ||
if (predicate(curItem.value)) { | ||
return true; | ||
} | ||
curItem = iterator.next(); | ||
} | ||
return false; | ||
}; | ||
/** | ||
* Two objects are equal if they represent the same value, | ||
@@ -166,4 +212,7 @@ * regardless of whether they are the same object physically | ||
return "{" + | ||
this.hamt.fold(function (acc, value, key) { acc.push(key + ""); return acc; }, []).join(", ") + "}"; | ||
this.hamt.fold(function (acc, value, key) { acc.push(Comparison_1.toStringHelper(key)); return acc; }, []).join(", ") + "}"; | ||
}; | ||
HashSet.prototype.inspect = function () { | ||
return this.toString(); | ||
}; | ||
return HashSet; | ||
@@ -190,9 +239,21 @@ }()); | ||
}; | ||
/** | ||
* Add multiple elements to this set. | ||
*/ | ||
EmptyHashSet.prototype.addAll = function (elts) { | ||
return HashSet.ofIterable(elts); | ||
}; | ||
EmptyHashSet.prototype.contains = function (elt) { | ||
return false; | ||
}; | ||
EmptyHashSet.prototype.map = function (mapper) { | ||
return emptyHashSet; | ||
}; | ||
EmptyHashSet.prototype.toArray = function () { | ||
return []; | ||
}; | ||
EmptyHashSet.prototype[Symbol.iterator] = function () { | ||
return { next: function () { return ({ done: true, value: undefined }); } }; | ||
}; | ||
EmptyHashSet.prototype.size = function () { | ||
EmptyHashSet.prototype.length = function () { | ||
return 0; | ||
@@ -206,7 +267,13 @@ }; | ||
}; | ||
EmptyHashSet.prototype.anyMatch = function (predicate) { | ||
return false; | ||
}; | ||
EmptyHashSet.prototype.allMatch = function (predicate) { | ||
return true; | ||
}; | ||
EmptyHashSet.prototype.equals = function (other) { | ||
if (!other || !other.size) { | ||
if (!other || !other.length) { | ||
return false; | ||
} | ||
return other === emptyHashSet || other.size() === 0; | ||
return other === emptyHashSet || other.length() === 0; | ||
}; | ||
@@ -213,0 +280,0 @@ EmptyHashSet.prototype.hashCode = function () { |
@@ -100,3 +100,3 @@ import { WithEquality } from "./Comparison"; | ||
*/ | ||
size(): number; | ||
length(): number; | ||
/** | ||
@@ -103,0 +103,0 @@ * true if the map is empty, false otherwise. |
@@ -11,3 +11,3 @@ import { WithEquality } from "./Comparison"; | ||
*/ | ||
size(): number; | ||
length(): number; | ||
/** | ||
@@ -22,2 +22,6 @@ * true if the set is empty, false otherwise. | ||
/** | ||
* Add multiple elements to this set. | ||
*/ | ||
addAll(elts: Iterable<T & WithEquality>): ISet<T>; | ||
/** | ||
* Returns true if the element you give is present in | ||
@@ -28,2 +32,8 @@ * the set, false otherwise. | ||
/** | ||
* Return a new collection where each element was transformed | ||
* by the mapper function you give. | ||
* The resulting set may be smaller than the source. | ||
*/ | ||
map<U>(mapper: (v: T) => U & WithEquality): ISet<U>; | ||
/** | ||
* Returns a new Set containing the difference | ||
@@ -41,2 +51,12 @@ * between this set and the other Set passed as parameter. | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
allMatch(predicate: (v: T) => boolean): boolean; | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
anyMatch(predicate: (v: T) => boolean): boolean; | ||
/** | ||
* Converts this set to an array | ||
@@ -43,0 +63,0 @@ */ |
@@ -79,4 +79,6 @@ import { Value } from "./Value"; | ||
* throw an exception. | ||
* You can optionally pass a message that'll be used as the | ||
* exception message. | ||
*/ | ||
abstract getOrThrow(): T; | ||
abstract getOrThrow(message?: string): T; | ||
/** | ||
@@ -132,2 +134,7 @@ * Get the value from this option; if it's a None (no value | ||
/** | ||
* Execute a side-effecting function if the option | ||
* is a Some, returns the option. | ||
*/ | ||
abstract ifPresent(fn: (v: T) => void): Option<T>; | ||
/** | ||
* Convert to a vector. If it's a None, it's the empty | ||
@@ -154,2 +161,6 @@ * vector, if it's a Some, it's a one-element vector with | ||
abstract toString(): string; | ||
/** | ||
* Used by the node REPL to display values. | ||
*/ | ||
abstract inspect(): string; | ||
} | ||
@@ -165,3 +176,3 @@ /** | ||
orElse(other: Option<T>): Option<T>; | ||
getOrThrow(): T; | ||
getOrThrow(message?: string): T; | ||
contains(v: T): boolean; | ||
@@ -175,2 +186,3 @@ getOrUndefined(): T | undefined; | ||
filter(fn: (v: T) => boolean): Option<T>; | ||
ifPresent(fn: (v: T) => void): Option<T>; | ||
toVector(): Vector<T>; | ||
@@ -180,2 +192,3 @@ equals(other: Option<T>): boolean; | ||
toString(): string; | ||
inspect(): string; | ||
} | ||
@@ -189,3 +202,3 @@ /** | ||
orElse(other: Option<T>): Option<T>; | ||
getOrThrow(): T & WithEquality; | ||
getOrThrow(message?: string): T & WithEquality; | ||
contains(v: T): boolean; | ||
@@ -199,2 +212,3 @@ getOrUndefined(): T | undefined; | ||
filter(fn: (v: T) => boolean): Option<T>; | ||
ifPresent(fn: (v: T) => void): Option<T>; | ||
toVector(): Vector<T>; | ||
@@ -204,2 +218,3 @@ equals(other: Option<T>): boolean; | ||
toString(): string; | ||
inspect(): string; | ||
} | ||
@@ -206,0 +221,0 @@ /** |
@@ -124,3 +124,3 @@ "use strict"; | ||
}; | ||
Some.prototype.getOrThrow = function () { | ||
Some.prototype.getOrThrow = function (message) { | ||
return this.value; | ||
@@ -152,2 +152,6 @@ }; | ||
}; | ||
Some.prototype.ifPresent = function (fn) { | ||
fn(this.value); | ||
return this; | ||
}; | ||
Some.prototype.toVector = function () { | ||
@@ -169,4 +173,7 @@ return Vector_1.Vector.ofStruct(this.value); | ||
Some.prototype.toString = function () { | ||
return "Some(" + this.value + ")"; | ||
return "Some(" + Comparison_1.toStringHelper(this.value) + ")"; | ||
}; | ||
Some.prototype.inspect = function () { | ||
return this.toString(); | ||
}; | ||
return Some; | ||
@@ -192,4 +199,4 @@ }(Option)); | ||
}; | ||
None.prototype.getOrThrow = function () { | ||
throw "getOrThrow called on none!"; | ||
None.prototype.getOrThrow = function (message) { | ||
throw message || "getOrThrow called on none!"; | ||
}; | ||
@@ -220,2 +227,5 @@ None.prototype.contains = function (v) { | ||
}; | ||
None.prototype.ifPresent = function (fn) { | ||
return this; | ||
}; | ||
None.prototype.toVector = function () { | ||
@@ -233,2 +243,5 @@ return Vector_1.Vector.empty(); | ||
}; | ||
None.prototype.inspect = function () { | ||
return this.toString(); | ||
}; | ||
return None; | ||
@@ -235,0 +248,0 @@ }(Option)); |
@@ -11,5 +11,5 @@ import { Value } from "./Value"; | ||
/** | ||
* Get the size (length) of the collection. | ||
* Get the length of the collection. | ||
*/ | ||
size(): number; | ||
length(): number; | ||
/** | ||
@@ -47,4 +47,5 @@ * true if the collection is empty, false otherwise. | ||
* Call a function for element in the collection. | ||
* Return the unchanged collection. | ||
*/ | ||
forEach(fn: (v: T) => void): void; | ||
forEach(fn: (v: T) => void): Seq<T>; | ||
/** | ||
@@ -64,5 +65,5 @@ * Get the first value of the collection, if any. | ||
* Get all the elements in the collection but the first one. | ||
* If the collection is empty, return an empty collection. | ||
* Option.None if it's empty. | ||
*/ | ||
tail(): Seq<T>; | ||
tail(): Option<Seq<T>>; | ||
/** | ||
@@ -93,2 +94,7 @@ * Return a new collection where each element was transformed | ||
/** | ||
* Returns true if the item is in the collection, | ||
* false otherwise. | ||
*/ | ||
contains(v: T & WithEquality): boolean; | ||
/** | ||
* Calls the function you give for each item in the collection, | ||
@@ -110,2 +116,12 @@ * your function returns a collection, all the collections are | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
allMatch(predicate: (v: T) => boolean): boolean; | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
anyMatch(predicate: (v: T) => boolean): boolean; | ||
/** | ||
* Group elements in the collection using a classifier function. | ||
@@ -112,0 +128,0 @@ * Elements are then organized in a map. The key is the value of |
import { Option } from "./Option"; | ||
import { Vector } from "./Vector"; | ||
import { WithEquality } from "./Comparison"; | ||
import { WithEquality, Ordering } from "./Comparison"; | ||
import { Value } from "./Value"; | ||
import { IMap } from "./IMap"; | ||
import { HashMap } from "./HashMap"; | ||
import { Seq } from "./Seq"; | ||
/** | ||
* A lazy, potentially infinite, sequence of values. | ||
* | ||
* Use take() for instance to reduce it to a finite stream. | ||
* Use take() for instance to reduce an infinite stream to a finite one. | ||
*/ | ||
export declare abstract class Stream<T> implements Iterable<T> { | ||
export declare abstract class Stream<T> implements Iterable<T>, Value, Seq<T> { | ||
/** | ||
* The empty stream | ||
*/ | ||
static empty<T>(): Stream<T>; | ||
/** | ||
* Create a Stream with the elements you give. | ||
* No equality requirements. | ||
*/ | ||
static ofStruct<T>(...elts: T[]): Stream<T>; | ||
/** | ||
* Create a Stream with the elements you give. | ||
* Equality requirements. | ||
*/ | ||
static of<T>(...elts: Array<T & WithEquality>): Stream<T>; | ||
/** | ||
* Build a stream from any iterable, which means also | ||
* an array for instance. | ||
* @type T the item type -- no equality requirement | ||
*/ | ||
static ofIterableStruct<T>(elts: Iterable<T>): Stream<T>; | ||
/** | ||
* Build a stream from any iterable, which means also | ||
* an array for instance. | ||
* @type T the item type -- equality requirement | ||
*/ | ||
static ofIterable<T>(elts: Iterable<T & WithEquality>): Stream<T>; | ||
/** | ||
* Build a stream from an array (slightly faster | ||
* than building from an iterable) | ||
* @type T the item type -- no equality requirement | ||
*/ | ||
static ofArrayStruct<T>(elts: Array<T>): Stream<T>; | ||
/** | ||
* Build a stream from an array (slightly faster | ||
* than building from an iterable) | ||
* @type T the item type -- equality requirement | ||
*/ | ||
static ofArray<T>(elts: Array<T & WithEquality>): Stream<T>; | ||
/** | ||
* Build an infinite stream from a seed and a transformation function. | ||
@@ -53,2 +95,6 @@ * No equality requirements. | ||
/** | ||
* Get the length of the collection. | ||
*/ | ||
abstract length(): number; | ||
/** | ||
* true if the collection is empty, false otherwise. | ||
@@ -65,6 +111,33 @@ */ | ||
* Get all the elements in the collection but the first one. | ||
* If the collection is empty, return an empty collection. | ||
* If the collection is empty, return None. | ||
*/ | ||
abstract tail(): Stream<T>; | ||
abstract tail(): Option<Stream<T>>; | ||
/** | ||
* Get the last value of the collection, if any. | ||
* returns Option.Some if the collection is not empty, | ||
* Option.None if it's empty. | ||
*/ | ||
abstract last(): Option<T>; | ||
/** | ||
* Retrieve the element at index idx. | ||
* Returns an option because the collection may | ||
* contain less elements than the index. | ||
* | ||
* Careful this is going to have poor performance | ||
* on Stream, which is not a good data structure | ||
* for random access! | ||
*/ | ||
abstract get(idx: number): Option<T>; | ||
/** | ||
* Search for an item matching the predicate you pass, | ||
* return Option.Some of that element if found, | ||
* Option.None otherwise. | ||
*/ | ||
abstract find(predicate: (v: T) => boolean): Option<T>; | ||
/** | ||
* Returns true if the item is in the collection, | ||
* false otherwise. | ||
*/ | ||
abstract contains(v: T & WithEquality): boolean; | ||
/** | ||
* Return a new stream keeping only the first n elements | ||
@@ -80,2 +153,144 @@ * from this stream. | ||
/** | ||
* Returns a new collection with the first | ||
* n elements discarded. | ||
* If the collection has less than n elements, | ||
* returns the empty collection. | ||
*/ | ||
abstract drop(n: number): Stream<T>; | ||
/** | ||
* Returns a new collection, discarding the first elements | ||
* until one element fails the predicate. All elements | ||
* after that point are retained. | ||
*/ | ||
abstract dropWhile(predicate: (x: T) => boolean): Stream<T>; | ||
/** | ||
* Returns a new collection with the last | ||
* n elements discarded. | ||
* If the collection has less than n elements, | ||
* returns the empty collection. | ||
*/ | ||
abstract dropRight(n: number): Stream<T>; | ||
/** | ||
* Reduces the collection to a single value. | ||
* Left-associative. | ||
* | ||
* Example: | ||
* | ||
* Vector.of("a", "b", "c").foldLeft("!", (xs,x) => x+xs)) | ||
* => "cba!" | ||
* | ||
* @param zero The initial value | ||
* @param fn A function taking the previous value and | ||
* the current collection item, and returning | ||
* an updated value. | ||
*/ | ||
abstract foldLeft<U>(zero: U, fn: (soFar: U, cur: T) => U): U; | ||
/** | ||
* Reduces the collection to a single value. | ||
* Right-associative. | ||
* | ||
* Example: | ||
* | ||
* Vector.of("a", "b", "c").foldRight("!", (x,xs) => xs+x)) | ||
* => "!cba" | ||
* | ||
* @param zero The initial value | ||
* @param fn A function taking the current collection item and | ||
* the previous value , and returning | ||
* an updated value. | ||
*/ | ||
abstract foldRight<U>(zero: U, fn: (cur: T, soFar: U) => U): U; | ||
/** | ||
* Combine this collection with the collection you give in | ||
* parameter to produce a new collection which combines both, | ||
* in pairs. For instance: | ||
* | ||
* Vector.of(1,2,3).zip(["a","b","c"]) | ||
* => Vector.of([1,"a"], [2,"b"], [3,"c"]) | ||
* | ||
* The result collection will have the length of the shorter | ||
* of both collections. Extra elements will be discarded. | ||
* No equality requirements. | ||
*/ | ||
abstract zipStruct<U>(other: Iterable<U>): Stream<[T, U]>; | ||
/** | ||
* Combine this collection with the collection you give in | ||
* parameter to produce a new collection which combines both, | ||
* in pairs. For instance: | ||
* | ||
* Vector.of(1,2,3).zip("a","b","c") | ||
* => Vector.of([1,"a"], [2,"b"], [3,"c"]) | ||
* | ||
* The result collection will have the length of the shorter | ||
* of both collections. Extra elements will be discarded. | ||
* Equality requirements. | ||
*/ | ||
zip<U>(other: Iterable<U & WithEquality>): Stream<[T, U]>; | ||
/** | ||
* Reverse the collection. For instance: | ||
* | ||
* [1,2,3] => [3,2,1] | ||
*/ | ||
abstract reverse(): Stream<T>; | ||
/** | ||
* Returns a pair of two collections; the first one | ||
* will only contain the items from this collection for | ||
* which the predicate you give returns true, the second | ||
* will only contain the items from this collection where | ||
* the predicate returns false. | ||
* | ||
* Vector.of(1,2,3,4).partition(x => x%2===0) | ||
* => [[2,4],[1,3]] | ||
*/ | ||
abstract partition(predicate: (x: T) => boolean): [Stream<T>, Stream<T>]; | ||
/** | ||
* Group elements in the collection using a classifier function. | ||
* Elements are then organized in a map. The key is the value of | ||
* the classifier, and in value we get the list of elements | ||
* matching that value. | ||
*/ | ||
abstract groupBy<C>(classifier: (v: T & WithEquality) => C & WithEquality): HashMap<C, Stream<T>>; | ||
/** | ||
* Append an element at the end of this Stream. | ||
* No equality requirements. | ||
*/ | ||
abstract appendStruct(v: T): Stream<T>; | ||
/** | ||
* Append an element at the end of this Stream. | ||
* Equality requirements. | ||
*/ | ||
append(v: T & WithEquality): Stream<T>; | ||
abstract appendAllStruct(elts: Iterable<T>): Stream<T>; | ||
appendAll(elts: Iterable<T>): Stream<T>; | ||
abstract appendStreamStruct(elts: Stream<T>): Stream<T>; | ||
appendStream(elts: Stream<T>): Stream<T>; | ||
/** | ||
* Prepend an element at the beginning of the collection. | ||
* Equality requirements. | ||
*/ | ||
prepend(elt: T & WithEquality): Stream<T>; | ||
/** | ||
* Prepend an element at the beginning of the collection. | ||
* No equality requirements. | ||
*/ | ||
abstract prependStruct(elt: T): Stream<T>; | ||
/** | ||
* Prepend multiple elements at the beginning of the collection. | ||
* Equality requirements. | ||
*/ | ||
prependAll(elts: Iterable<T & WithEquality>): Stream<T>; | ||
/** | ||
* Prepend multiple elements at the beginning of the collection. | ||
* No equality requirements. | ||
*/ | ||
abstract prependAllStruct(elts: Iterable<T>): Stream<T>; | ||
/** | ||
* Repeat infinitely this Stream. | ||
* For instance: | ||
* | ||
* Stream.of(1,2,3).cycle() | ||
* => [1,2,3,1,2,3,1,2...] | ||
*/ | ||
abstract cycle(): Stream<T>; | ||
/** | ||
* Return a new collection where each element was transformed | ||
@@ -93,2 +308,28 @@ * by the mapper function you give. | ||
/** | ||
* Calls the function you give for each item in the collection, | ||
* your function returns a collection, all the collections are | ||
* concatenated. | ||
* This is the monadic bind. | ||
* No equality requirement | ||
*/ | ||
abstract flatMapStruct<U>(mapper: (v: T) => Stream<U>): Stream<U>; | ||
/** | ||
* Calls the function you give for each item in the collection, | ||
* your function returns a collection, all the collections are | ||
* concatenated. | ||
* This is the monadic bind. | ||
* Equality requirement | ||
*/ | ||
abstract flatMap<U>(mapper: (v: T) => Stream<U & WithEquality>): Stream<U>; | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
abstract allMatch(predicate: (v: T) => boolean): boolean; | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
abstract anyMatch(predicate: (v: T) => boolean): boolean; | ||
/** | ||
* Call a predicate for each element in the collection, | ||
@@ -100,2 +341,27 @@ * build a new collection holding only the elements | ||
/** | ||
* Returns a new collection with elements | ||
* sorted according to the comparator you give. | ||
*/ | ||
abstract sortBy(compare: (v1: T, v2: T) => Ordering): Stream<T>; | ||
/** | ||
* Remove duplicate items; elements are mapped to keys, those | ||
* get compared. | ||
* | ||
* Vector.of(1,1,2,3,2,3,1).distinctBy(x => x) | ||
* => [1,2,3] | ||
*/ | ||
abstract distinctBy<U>(keyExtractor: (x: T) => U & WithEquality): Stream<T>; | ||
/** | ||
* Call a function for element in the collection. | ||
*/ | ||
abstract forEach(fn: (v: T) => void): Stream<T>; | ||
/** | ||
* Joins elements of the collection by a separator. | ||
* Example: | ||
* | ||
* Vector.of(1,2,3).mkString(", ") | ||
* => "1, 2, 3" | ||
*/ | ||
abstract mkString(separator: string): string; | ||
/** | ||
* Convert to array. | ||
@@ -110,2 +376,37 @@ * Don't do it on an infinite stream! | ||
abstract toVector(): Vector<T>; | ||
/** | ||
* Convert this collection to a map. You give a function which | ||
* for each element in the collection returns a pair. The | ||
* key of the pair will be used as a key in the map, the value, | ||
* as a value in the map. If several values get the same key, | ||
* entries will be lost. | ||
* Equality requirements. | ||
*/ | ||
abstract toMap<K, V>(converter: (x: T) => [K & WithEquality, V & WithEquality]): IMap<K, V>; | ||
/** | ||
* Convert this collection to a map. You give a function which | ||
* for each element in the collection returns a pair. The | ||
* key of the pair will be used as a key in the map, the value, | ||
* as a value in the map. If several values get the same key, | ||
* entries will be lost. | ||
* No equality requirements. | ||
*/ | ||
abstract toMapStruct<K, V>(converter: (x: T) => [K & WithEquality, V]): IMap<K, V>; | ||
/** | ||
* Two objects are equal if they represent the same value, | ||
* regardless of whether they are the same object physically | ||
* in memory. | ||
*/ | ||
abstract equals(other: Stream<T>): boolean; | ||
/** | ||
* Get a human-friendly string representation of that value. | ||
*/ | ||
abstract toString(): string; | ||
/** | ||
* Get a number for that object. Two different values | ||
* may get the same number, but one value must always get | ||
* the same number. The formula can impact performance. | ||
*/ | ||
abstract hashCode(): number; | ||
inspect(): string; | ||
} |
@@ -15,7 +15,9 @@ "use strict"; | ||
var Vector_1 = require("./Vector"); | ||
// TODO extend seq? | ||
var Comparison_1 = require("./Comparison"); | ||
var HashMap_1 = require("./HashMap"); | ||
var HashSet_1 = require("./HashSet"); | ||
/** | ||
* A lazy, potentially infinite, sequence of values. | ||
* | ||
* Use take() for instance to reduce it to a finite stream. | ||
* Use take() for instance to reduce an infinite stream to a finite one. | ||
*/ | ||
@@ -26,2 +28,72 @@ var Stream = (function () { | ||
/** | ||
* The empty stream | ||
*/ | ||
Stream.empty = function () { | ||
return emptyStream; | ||
}; | ||
/** | ||
* Create a Stream with the elements you give. | ||
* No equality requirements. | ||
*/ | ||
Stream.ofStruct = function () { | ||
var elts = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
elts[_i] = arguments[_i]; | ||
} | ||
return Stream.ofIterableStruct(elts); | ||
}; | ||
/** | ||
* Create a Stream with the elements you give. | ||
* Equality requirements. | ||
*/ | ||
Stream.of = function () { | ||
var elts = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
elts[_i] = arguments[_i]; | ||
} | ||
return Stream.ofIterableStruct(elts); | ||
}; | ||
/** | ||
* Build a stream from any iterable, which means also | ||
* an array for instance. | ||
* @type T the item type -- no equality requirement | ||
*/ | ||
Stream.ofIterableStruct = function (elts) { | ||
// need to eagerly copy the iterable. the reason | ||
// is, if we would build the stream based on the iterator | ||
// in the iterable, Stream.tail() would do it.next(). | ||
// but it.next() modifies the iterator (mutability), | ||
// and you would end up with getting two different tails | ||
// for the same stream if you call .tail() twice in a row | ||
return Stream.ofArrayStruct(Array.from(elts)); | ||
}; | ||
/** | ||
* Build a stream from any iterable, which means also | ||
* an array for instance. | ||
* @type T the item type -- equality requirement | ||
*/ | ||
Stream.ofIterable = function (elts) { | ||
return Stream.ofIterableStruct(elts); | ||
}; | ||
/** | ||
* Build a stream from an array (slightly faster | ||
* than building from an iterable) | ||
* @type T the item type -- no equality requirement | ||
*/ | ||
Stream.ofArrayStruct = function (elts) { | ||
if (elts.length === 0) { | ||
return emptyStream; | ||
} | ||
var head = elts[0]; | ||
return new ConsStream(head, function () { return Stream.ofArrayStruct(elts.slice(1)); }); | ||
}; | ||
/** | ||
* Build a stream from an array (slightly faster | ||
* than building from an iterable) | ||
* @type T the item type -- equality requirement | ||
*/ | ||
Stream.ofArray = function (elts) { | ||
return Stream.ofArrayStruct(elts); | ||
}; | ||
/** | ||
* Build an infinite stream from a seed and a transformation function. | ||
@@ -72,2 +144,61 @@ * No equality requirements. | ||
}; | ||
/** | ||
* Combine this collection with the collection you give in | ||
* parameter to produce a new collection which combines both, | ||
* in pairs. For instance: | ||
* | ||
* Vector.of(1,2,3).zip("a","b","c") | ||
* => Vector.of([1,"a"], [2,"b"], [3,"c"]) | ||
* | ||
* The result collection will have the length of the shorter | ||
* of both collections. Extra elements will be discarded. | ||
* Equality requirements. | ||
*/ | ||
Stream.prototype.zip = function (other) { | ||
return this.zipStruct(other); | ||
}; | ||
/** | ||
* Append an element at the end of this Stream. | ||
* Equality requirements. | ||
*/ | ||
Stream.prototype.append = function (v) { | ||
return this.appendStruct(v); | ||
}; | ||
/* | ||
* Append multiple elements at the end of this Stream. | ||
* Equality requirements. | ||
*/ | ||
Stream.prototype.appendAll = function (elts) { | ||
return this.appendAllStruct(elts); | ||
}; | ||
/* | ||
* Append another Stream at the end of this Stream. | ||
* | ||
* There is no function taking a javascript iterator, | ||
* because iterators are stateful and Streams lazy. | ||
* If we would create two Streams working on the same iterator, | ||
* the streams would interact with one another. | ||
* It also breaks the cycle() function. | ||
* Equality requirements. | ||
*/ | ||
Stream.prototype.appendStream = function (elts) { | ||
return this.appendStreamStruct(elts); | ||
}; | ||
/** | ||
* Prepend an element at the beginning of the collection. | ||
* Equality requirements. | ||
*/ | ||
Stream.prototype.prepend = function (elt) { | ||
return this.prependStruct(elt); | ||
}; | ||
/** | ||
* Prepend multiple elements at the beginning of the collection. | ||
* Equality requirements. | ||
*/ | ||
Stream.prototype.prependAll = function (elts) { | ||
return this.prependAllStruct(elts); | ||
}; | ||
Stream.prototype.inspect = function () { | ||
return this.toString(); | ||
}; | ||
return Stream; | ||
@@ -91,2 +222,5 @@ }()); | ||
}; | ||
EmptyStream.prototype.length = function () { | ||
return 0; | ||
}; | ||
EmptyStream.prototype.isEmpty = function () { | ||
@@ -99,4 +233,16 @@ return true; | ||
EmptyStream.prototype.tail = function () { | ||
return this; | ||
return Option_1.Option.none(); | ||
}; | ||
EmptyStream.prototype.last = function () { | ||
return Option_1.Option.none(); | ||
}; | ||
EmptyStream.prototype.get = function (idx) { | ||
return Option_1.Option.none(); | ||
}; | ||
EmptyStream.prototype.find = function (predicate) { | ||
return Option_1.Option.none(); | ||
}; | ||
EmptyStream.prototype.contains = function (v) { | ||
return false; | ||
}; | ||
EmptyStream.prototype.take = function (n) { | ||
@@ -108,21 +254,80 @@ return this; | ||
}; | ||
/** | ||
* Return a new collection where each element was transformed | ||
* by the mapper function you give. | ||
* No equality requirements. | ||
*/ | ||
EmptyStream.prototype.drop = function (n) { | ||
return this; | ||
}; | ||
EmptyStream.prototype.dropWhile = function (predicate) { | ||
return this; | ||
}; | ||
EmptyStream.prototype.dropRight = function (n) { | ||
return this; | ||
}; | ||
EmptyStream.prototype.foldLeft = function (zero, fn) { | ||
return zero; | ||
}; | ||
EmptyStream.prototype.foldRight = function (zero, fn) { | ||
return zero; | ||
}; | ||
EmptyStream.prototype.zipStruct = function (other) { | ||
return emptyStream; | ||
}; | ||
EmptyStream.prototype.reverse = function () { | ||
return this; | ||
}; | ||
EmptyStream.prototype.partition = function (predicate) { | ||
return [Stream.empty(), Stream.empty()]; | ||
}; | ||
EmptyStream.prototype.groupBy = function (classifier) { | ||
return HashMap_1.HashMap.empty(); | ||
}; | ||
EmptyStream.prototype.appendStruct = function (v) { | ||
return Stream.ofStruct(v); | ||
}; | ||
EmptyStream.prototype.appendAllStruct = function (elts) { | ||
return Stream.ofIterableStruct(elts); | ||
}; | ||
EmptyStream.prototype.appendStreamStruct = function (elts) { | ||
return elts; | ||
}; | ||
EmptyStream.prototype.prependStruct = function (elt) { | ||
return Stream.ofStruct(elt); | ||
}; | ||
EmptyStream.prototype.prependAllStruct = function (elt) { | ||
return Stream.ofIterableStruct(elt); | ||
}; | ||
EmptyStream.prototype.cycle = function () { | ||
return emptyStream; | ||
}; | ||
EmptyStream.prototype.mapStruct = function (mapper) { | ||
return emptyStream; | ||
}; | ||
/** | ||
* Return a new collection where each element was transformed | ||
* by the mapper function you give. | ||
* Equality requirements. | ||
*/ | ||
EmptyStream.prototype.map = function (mapper) { | ||
return emptyStream; | ||
}; | ||
EmptyStream.prototype.flatMapStruct = function (mapper) { | ||
return emptyStream; | ||
}; | ||
EmptyStream.prototype.flatMap = function (mapper) { | ||
return emptyStream; | ||
}; | ||
EmptyStream.prototype.allMatch = function (predicate) { | ||
return true; | ||
}; | ||
EmptyStream.prototype.anyMatch = function (predicate) { | ||
return false; | ||
}; | ||
EmptyStream.prototype.filter = function (predicate) { | ||
return this; | ||
}; | ||
EmptyStream.prototype.sortBy = function (compare) { | ||
return this; | ||
}; | ||
EmptyStream.prototype.distinctBy = function (keyExtractor) { | ||
return this; | ||
}; | ||
EmptyStream.prototype.forEach = function (fn) { | ||
return this; | ||
}; | ||
EmptyStream.prototype.mkString = function (separator) { | ||
return ""; | ||
}; | ||
EmptyStream.prototype.toArray = function () { | ||
@@ -134,2 +339,20 @@ return []; | ||
}; | ||
EmptyStream.prototype.toMap = function (converter) { | ||
return HashMap_1.HashMap.empty(); | ||
}; | ||
EmptyStream.prototype.toMapStruct = function (converter) { | ||
return HashMap_1.HashMap.empty(); | ||
}; | ||
EmptyStream.prototype.equals = function (other) { | ||
if (!other) { | ||
return false; | ||
} | ||
return other.isEmpty(); | ||
}; | ||
EmptyStream.prototype.hashCode = function () { | ||
return 1; | ||
}; | ||
EmptyStream.prototype.toString = function () { | ||
return "[]"; | ||
}; | ||
return EmptyStream; | ||
@@ -156,3 +379,3 @@ }(Stream)); | ||
var value = item.head().getOrThrow(); | ||
item = item.tail(); | ||
item = item.tail().getOrThrow(); | ||
return { done: false, value: value }; | ||
@@ -162,2 +385,5 @@ } | ||
}; | ||
ConsStream.prototype.length = function () { | ||
return this.foldLeft(0, function (n, ignored) { return n + 1; }); | ||
}; | ||
ConsStream.prototype.isEmpty = function () { | ||
@@ -170,4 +396,41 @@ return false; | ||
ConsStream.prototype.tail = function () { | ||
return this._tail(); | ||
return Option_1.Option.ofStruct(this._tail()); | ||
}; | ||
ConsStream.prototype.last = function () { | ||
var curItem = this; | ||
while (true) { | ||
var item = curItem.value; | ||
curItem = curItem._tail(); | ||
if (curItem.isEmpty()) { | ||
return Option_1.Option.ofStruct(item); | ||
} | ||
} | ||
}; | ||
ConsStream.prototype.get = function (idx) { | ||
var curItem = this; | ||
var i = 0; | ||
while (!curItem.isEmpty()) { | ||
if (i === idx) { | ||
var item = curItem.value; | ||
return Option_1.Option.ofStruct(item); | ||
} | ||
curItem = curItem._tail(); | ||
++i; | ||
} | ||
return Option_1.Option.none(); | ||
}; | ||
ConsStream.prototype.find = function (predicate) { | ||
var curItem = this; | ||
while (!curItem.isEmpty()) { | ||
var item = curItem.value; | ||
if (predicate(item)) { | ||
return Option_1.Option.ofStruct(item); | ||
} | ||
curItem = curItem._tail(); | ||
} | ||
return Option_1.Option.none(); | ||
}; | ||
ConsStream.prototype.contains = function (v) { | ||
return this.find(function (x) { return Comparison_1.areEqual(x, v); }).isSome(); | ||
}; | ||
ConsStream.prototype.take = function (n) { | ||
@@ -178,3 +441,3 @@ var _this = this; | ||
} | ||
return new ConsStream(this.value, function () { return _this.tail().take(n - 1); }); | ||
return new ConsStream(this.value, function () { return _this._tail().take(n - 1); }); | ||
}; | ||
@@ -186,7 +449,88 @@ ConsStream.prototype.takeWhile = function (predicate) { | ||
} | ||
return new ConsStream(this.value, function () { return _this.tail().takeWhile(predicate); }); | ||
return new ConsStream(this.value, function () { return _this._tail().takeWhile(predicate); }); | ||
}; | ||
ConsStream.prototype.drop = function (n) { | ||
var i = n; | ||
var curItem = this; | ||
while (i-- > 0 && !curItem.isEmpty()) { | ||
curItem = curItem._tail(); | ||
} | ||
return curItem; | ||
}; | ||
ConsStream.prototype.dropWhile = function (predicate) { | ||
var curItem = this; | ||
while (!curItem.isEmpty() && predicate(curItem.value)) { | ||
curItem = curItem._tail(); | ||
} | ||
return curItem; | ||
}; | ||
ConsStream.prototype.dropRight = function (n) { | ||
// going twice through the list... | ||
var length = this.length(); | ||
return this.take(length - n); | ||
}; | ||
ConsStream.prototype.foldLeft = function (zero, fn) { | ||
var r = zero; | ||
var curItem = this; | ||
while (!curItem.isEmpty()) { | ||
r = fn(r, curItem.value); | ||
curItem = curItem._tail(); | ||
} | ||
return r; | ||
}; | ||
ConsStream.prototype.foldRight = function (zero, fn) { | ||
return this.reverse().foldLeft(zero, function (xs, x) { return fn(x, xs); }); | ||
}; | ||
ConsStream.prototype.zipStruct = function (other) { | ||
var _this = this; | ||
var otherIterator = other[Symbol.iterator](); | ||
var otherCurItem = otherIterator.next(); | ||
if (this.isEmpty() || otherCurItem.done) { | ||
return emptyStream; | ||
} | ||
return new ConsStream([this.value, otherCurItem.value], function () { | ||
return _this._tail().zipStruct((_a = {}, _a[Symbol.iterator] = function () { return otherIterator; }, _a)); | ||
var _a; | ||
}); | ||
}; | ||
ConsStream.prototype.reverse = function () { | ||
return this.foldLeft(emptyStream, function (xs, x) { return xs.prependStruct(x); }); | ||
}; | ||
ConsStream.prototype.partition = function (predicate) { | ||
// TODO goes twice over the list, can be optimized... | ||
return [this.filter(predicate), this.filter(function (x) { return !predicate(x); })]; | ||
}; | ||
ConsStream.prototype.groupBy = function (classifier) { | ||
return this.foldLeft(HashMap_1.HashMap.empty(), function (acc, v) { | ||
return acc.putWithMerge(classifier(v), Stream.of(v), function (v1, v2) { return v1.appendStream(v2); }); | ||
}); | ||
}; | ||
ConsStream.prototype.appendStruct = function (v) { | ||
var tail = this._tail(); | ||
return new ConsStream(this.value, function () { return tail.appendStruct(v); }); | ||
}; | ||
ConsStream.prototype.appendAllStruct = function (elts) { | ||
return this.appendStreamStruct(Stream.ofIterableStruct(elts)); | ||
}; | ||
ConsStream.prototype.appendStreamStruct = function (elts) { | ||
var tail = this._tail(); | ||
return new ConsStream(this.value, function () { return tail.appendStreamStruct(elts); }); | ||
}; | ||
ConsStream.prototype.prependStruct = function (elt) { | ||
var _this = this; | ||
return new ConsStream(elt, function () { return _this; }); | ||
}; | ||
ConsStream.prototype.prependAllStruct = function (elts) { | ||
return Stream.ofIterableStruct(elts).appendAllStruct(this); | ||
}; | ||
ConsStream.prototype.cycle = function () { | ||
return this._cycle(this); | ||
}; | ||
ConsStream.prototype._cycle = function (toRepeat) { | ||
var tail = this._tail(); | ||
return new ConsStream(this.value, function () { return tail.isEmpty() ? toRepeat.cycle() : tail._cycle(toRepeat); }); | ||
}; | ||
ConsStream.prototype.mapStruct = function (mapper) { | ||
var _this = this; | ||
return new ConsStream(mapper(this.value), function () { return _this.tail().mapStruct(mapper); }); | ||
return new ConsStream(mapper(this.value), function () { return _this._tail().mapStruct(mapper); }); | ||
}; | ||
@@ -196,10 +540,58 @@ ConsStream.prototype.map = function (mapper) { | ||
}; | ||
ConsStream.prototype.flatMapStruct = function (mapper) { | ||
return mapper(this.value).appendStream(this._tail().flatMapStruct(mapper)); | ||
}; | ||
ConsStream.prototype.flatMap = function (mapper) { | ||
return this.flatMapStruct(mapper); | ||
}; | ||
ConsStream.prototype.allMatch = function (predicate) { | ||
return this.find(function (x) { return !predicate(x); }).isNone(); | ||
}; | ||
ConsStream.prototype.anyMatch = function (predicate) { | ||
return this.find(predicate).isSome(); | ||
}; | ||
ConsStream.prototype.filter = function (predicate) { | ||
var _this = this; | ||
return predicate(this.value) ? | ||
new ConsStream(this.value, function () { return _this.tail().filter(predicate); }) : | ||
this.tail().filter(predicate); | ||
new ConsStream(this.value, function () { return _this._tail().filter(predicate); }) : | ||
this._tail().filter(predicate); | ||
}; | ||
ConsStream.prototype.sortBy = function (compare) { | ||
return Stream.ofIterableStruct(this.toArray().sort(compare)); | ||
}; | ||
ConsStream.prototype.distinctBy = function (keyExtractor) { | ||
var knownKeys = HashSet_1.HashSet.empty(); | ||
return this.filter(function (x) { | ||
var key = keyExtractor(x); | ||
var r = knownKeys.contains(key); | ||
if (!r) { | ||
knownKeys = knownKeys.add(key); | ||
} | ||
return !r; | ||
}); | ||
}; | ||
ConsStream.prototype.forEach = function (fn) { | ||
var curItem = this; | ||
while (!curItem.isEmpty()) { | ||
fn(curItem.value); | ||
curItem = curItem._tail(); | ||
} | ||
return this; | ||
}; | ||
ConsStream.prototype.mkString = function (separator) { | ||
var r = ""; | ||
var curItem = this; | ||
var isNotFirst = false; | ||
while (!curItem.isEmpty()) { | ||
if (isNotFirst) { | ||
r += separator; | ||
} | ||
r += curItem.value.toString(); | ||
curItem = curItem._tail(); | ||
isNotFirst = true; | ||
} | ||
return r; | ||
}; | ||
ConsStream.prototype.toArray = function () { | ||
var r = this.tail().toArray(); | ||
var r = this._tail().toArray(); | ||
r.unshift(this.value); | ||
@@ -211,2 +603,63 @@ return r; | ||
}; | ||
ConsStream.prototype.toMap = function (converter) { | ||
return this.toMapStruct(converter); | ||
}; | ||
ConsStream.prototype.toMapStruct = function (converter) { | ||
return this.foldLeft(HashMap_1.HashMap.empty(), function (acc, cur) { | ||
var converted = converter(cur); | ||
return acc.putStruct(converted[0], converted[1]); | ||
}); | ||
}; | ||
ConsStream.prototype.equals = function (other) { | ||
if (!other || !other.tail) { | ||
return false; | ||
} | ||
var myVal = this; | ||
var hisVal = other; | ||
while (true) { | ||
if (myVal.isEmpty() !== hisVal.isEmpty()) { | ||
return false; | ||
} | ||
if (myVal.isEmpty()) { | ||
// they are both empty, end of the stream | ||
return true; | ||
} | ||
var myHead = myVal.value; | ||
var hisHead = hisVal.value; | ||
if ((myHead === undefined) !== (hisHead === undefined)) { | ||
return false; | ||
} | ||
if (myHead === undefined || hisHead === undefined) { | ||
// they are both undefined, the || is for TS's flow analysis | ||
// so he realizes none of them is undefined after this. | ||
continue; | ||
} | ||
if (!Comparison_1.areEqual(myHead, hisHead)) { | ||
return false; | ||
} | ||
myVal = myVal._tail(); | ||
hisVal = hisVal._tail(); | ||
} | ||
}; | ||
ConsStream.prototype.hashCode = function () { | ||
var hash = 1; | ||
var curItem = this; | ||
while (!curItem.isEmpty()) { | ||
hash = 31 * hash + Comparison_1.getHashCode(curItem.value); | ||
curItem = curItem._tail(); | ||
} | ||
return hash; | ||
}; | ||
ConsStream.prototype.toString = function () { | ||
var curItem = this; | ||
var result = "["; | ||
while (!curItem.isEmpty()) { | ||
result += Comparison_1.toStringHelper(curItem.value); | ||
curItem = curItem._tail(); | ||
if (!curItem.isEmpty()) { | ||
result += ", "; | ||
} | ||
} | ||
return result + "]"; | ||
}; | ||
return ConsStream; | ||
@@ -213,0 +666,0 @@ }(Stream)); |
@@ -88,2 +88,3 @@ import { Value } from "./Value"; | ||
toString(): string; | ||
inspect(): string; | ||
} |
@@ -114,4 +114,7 @@ "use strict"; | ||
Tuple2.prototype.toString = function () { | ||
return "Tuple2(" + this._fst + ", " + this._snd + ")"; | ||
return "Tuple2(" + Comparison_1.toStringHelper(this._fst) + ", " + Comparison_1.toStringHelper(this._snd) + ")"; | ||
}; | ||
Tuple2.prototype.inspect = function () { | ||
return this.toString(); | ||
}; | ||
return Tuple2; | ||
@@ -118,0 +121,0 @@ }()); |
@@ -18,2 +18,7 @@ export interface Value { | ||
toString(): string; | ||
/** | ||
* Used by the node REPL to display values. | ||
* Most of the time should be the same as toString() | ||
*/ | ||
inspect(): string; | ||
} |
@@ -55,5 +55,5 @@ import { Seq } from "./Seq"; | ||
/** | ||
* Get the size (length) of the collection. | ||
* Get the length of the collection. | ||
*/ | ||
size(): number; | ||
length(): number; | ||
/** | ||
@@ -77,5 +77,5 @@ * true if the collection is empty, false otherwise. | ||
* Get all the elements in the collection but the first one. | ||
* If the collection is empty, return an empty collection. | ||
* If the collection is empty, return None. | ||
*/ | ||
tail(): Vector<T>; | ||
tail(): Option<Vector<T>>; | ||
/** | ||
@@ -122,3 +122,3 @@ * Append an element at the end of the collection. | ||
*/ | ||
forEach(fn: (v: T) => void): void; | ||
forEach(fn: (v: T) => void): Vector<T>; | ||
/** | ||
@@ -161,2 +161,7 @@ * Append multiple elements at the end of the collection. | ||
/** | ||
* Returns true if the item is in the collection, | ||
* false otherwise. | ||
*/ | ||
contains(v: T & WithEquality): boolean; | ||
/** | ||
* Calls the function you give for each item in the collection, | ||
@@ -247,2 +252,12 @@ * your function returns a collection, all the collections are | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
allMatch(predicate: (v: T) => boolean): boolean; | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
anyMatch(predicate: (v: T) => boolean): boolean; | ||
/** | ||
* Returns a new collection with elements | ||
@@ -282,3 +297,3 @@ * sorted according to the comparator you give. | ||
* | ||
* Vector.of(1,2,3).zip("a","b","c") | ||
* Vector.of(1,2,3).zip(["a","b","c"]) | ||
* => Vector.of([1,"a"], [2,"b"], [3,"c"]) | ||
@@ -345,2 +360,7 @@ * | ||
toString(): string; | ||
/** | ||
* Used by the node REPL to display values. | ||
* Most of the time should be the same as toString() | ||
*/ | ||
inspect(): string; | ||
} |
@@ -95,5 +95,5 @@ "use strict"; | ||
/** | ||
* Get the size (length) of the collection. | ||
* Get the length of the collection. | ||
*/ | ||
Vector.prototype.size = function () { | ||
Vector.prototype.length = function () { | ||
return this.hamt.size; | ||
@@ -125,6 +125,8 @@ }; | ||
* Get all the elements in the collection but the first one. | ||
* If the collection is empty, return an empty collection. | ||
* If the collection is empty, return None. | ||
*/ | ||
Vector.prototype.tail = function () { | ||
return new Vector(this.hamt.remove(this.indexShift), this.indexShift + 1); | ||
return this.isEmpty() ? | ||
Option_1.Option.none() : | ||
Option_1.Option.of(new Vector(this.hamt.remove(this.indexShift), this.indexShift + 1)); | ||
}; | ||
@@ -200,2 +202,3 @@ /** | ||
} | ||
return this; | ||
}; | ||
@@ -269,3 +272,3 @@ /** | ||
if (predicate(item)) { | ||
return Option_1.Option.of(item); | ||
return Option_1.Option.ofStruct(item); | ||
} | ||
@@ -276,2 +279,9 @@ } | ||
/** | ||
* Returns true if the item is in the collection, | ||
* false otherwise. | ||
*/ | ||
Vector.prototype.contains = function (v) { | ||
return this.anyMatch(function (curVal) { return Comparison_1.areEqual(curVal, v); }); | ||
}; | ||
/** | ||
* Calls the function you give for each item in the collection, | ||
@@ -433,2 +443,36 @@ * your function returns a collection, all the collections are | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
Vector.prototype.allMatch = function (predicate) { | ||
// faster than using .find() because we | ||
// don't have to traverse elements in order | ||
var iterator = this.hamt.values(); | ||
var curItem = iterator.next(); | ||
while (!curItem.done) { | ||
if (!predicate(curItem.value)) { | ||
return false; | ||
} | ||
curItem = iterator.next(); | ||
} | ||
return true; | ||
}; | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
Vector.prototype.anyMatch = function (predicate) { | ||
// faster than using .find() because we | ||
// don't have to traverse elements in order | ||
var iterator = this.hamt.values(); | ||
var curItem = iterator.next(); | ||
while (!curItem.done) { | ||
if (predicate(curItem.value)) { | ||
return true; | ||
} | ||
curItem = iterator.next(); | ||
} | ||
return false; | ||
}; | ||
/** | ||
* Returns a new collection with elements | ||
@@ -481,3 +525,3 @@ * sorted according to the comparator you give. | ||
* | ||
* Vector.of(1,2,3).zip("a","b","c") | ||
* Vector.of(1,2,3).zip(["a","b","c"]) | ||
* => Vector.of([1,"a"], [2,"b"], [3,"c"]) | ||
@@ -634,6 +678,13 @@ * | ||
} | ||
r += "" + this.hamt.get(i + this.indexShift); | ||
r += Comparison_1.toStringHelper(this.hamt.get(i + this.indexShift)); | ||
} | ||
return r + "]"; | ||
}; | ||
/** | ||
* Used by the node REPL to display values. | ||
* Most of the time should be the same as toString() | ||
*/ | ||
Vector.prototype.inspect = function () { | ||
return this.toString(); | ||
}; | ||
return Vector; | ||
@@ -640,0 +691,0 @@ }()); |
@@ -15,2 +15,4 @@ "use strict"; | ||
.add(new SampleData_1.MyClass("a", 2)))); }); | ||
it("should support addAll on a non-empty set", function () { return assert.ok(HashSet_1.HashSet.of(1, 2, 3, 4).equals(HashSet_1.HashSet.of(1, 2).addAll([3, 4]))); }); | ||
it("should support addAll on an empty set", function () { return assert.ok(HashSet_1.HashSet.of(1, 2, 3, 4).equals(HashSet_1.HashSet.empty().addAll([1, 2, 3, 4]))); }); | ||
}); | ||
@@ -22,2 +24,5 @@ describe("hashset conversions", function () { | ||
}); | ||
it("empty should convert to array correctly", function () { | ||
assert.deepEqual([], HashSet_1.HashSet.empty().toArray()); | ||
}); | ||
it("should be created correctly from an array", function () { | ||
@@ -30,3 +35,3 @@ assert.deepEqual(["a", "b", "c"], HashSet_1.HashSet.ofIterable(["a", "b", "c"]).toArray().sort()); | ||
it("should be displayed in a nice format by toString", function () { | ||
return assert.equal("{a, b, c}", HashSet_1.HashSet.of("a", "b", "c").toString()); | ||
return assert.equal("{'a', 'b', 'c'}", HashSet_1.HashSet.of("a", "b", "c").toString()); | ||
}); | ||
@@ -60,2 +65,8 @@ }); | ||
}); | ||
it("supports allMatch, positive case", function () { return assert.ok(HashSet_1.HashSet.of(2, 4, 8).allMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports allMatch, negative case", function () { return assert.ok(!HashSet_1.HashSet.of(2, 5, 8).allMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports allMatch, empty HashSet", function () { return assert.ok(HashSet_1.HashSet.empty().allMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports anyMatch, positive case", function () { return assert.ok(HashSet_1.HashSet.of(3, 5, 8).anyMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports anyMatch, negative case", function () { return assert.ok(!HashSet_1.HashSet.of(3, 5, 9).anyMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports anyMatch, empty HashSet", function () { return assert.ok(!HashSet_1.HashSet.empty().anyMatch(function (x) { return x % 2 === 0; })); }); | ||
}); | ||
@@ -72,2 +83,5 @@ describe("hashset equality", function () { | ||
}); | ||
describe("hashset transformations", function () { | ||
it("map works", function () { return assert.ok(HashSet_1.HashSet.of(5, 6, 7).equals(HashSet_1.HashSet.of(1, 2, 3).map(function (x) { return x + 4; }))); }); | ||
}); | ||
//# sourceMappingURL=HashSet.js.map |
@@ -91,3 +91,12 @@ "use strict"; | ||
}); | ||
it("should not throw on Some.getOrThrow", function () { | ||
return assert.equal(5, Option_1.Option.of(5).getOrThrow()); | ||
}); | ||
it("should throw on None.getOrThrow", function () { | ||
return assert.throws(function () { return Option_1.Option.none().getOrThrow(); }); | ||
}); | ||
it("should throw on None.getOrThrow with custom msg", function () { | ||
return assert.throws(function () { return Option_1.Option.none().getOrThrow("my custom msg"); }, /^my custom msg$/); | ||
}); | ||
}); | ||
//# sourceMappingURL=Option.js.map |
@@ -5,2 +5,5 @@ "use strict"; | ||
var Vector_1 = require("../src/Vector"); | ||
var Option_1 = require("../src/Option"); | ||
var SampleData_1 = require("./SampleData"); | ||
var HashMap_1 = require("../src/HashMap"); | ||
var assert = require("assert"); | ||
@@ -20,7 +23,101 @@ describe("Stream basics", function () { | ||
}); | ||
it("converts to vector", function () { return assert.ok(Vector_1.Vector.of(1, 2, 3).equals(Stream_1.Stream.iterate(1, function (x) { return x + 1; }).take(3).toVector())); }); | ||
it("maps correctly", function () { return assert.deepEqual([4, 5, 7, 11], Stream_1.Stream.iterate(1, function (x) { return x * 2; }).map(function (x) { return x + 3; }).take(4).toArray()); }); | ||
it("supports ofArray", function () { return assert.deepEqual([1, 2, 3], Stream_1.Stream.ofIterable([1, 2, 3]).toArray()); }); | ||
it("supports of", function () { return assert.deepEqual([1, 2, 3], Stream_1.Stream.of(1, 2, 3).toArray()); }); | ||
it("supports append", function () { return assert.deepEqual([1, 2, 3, 4], Stream_1.Stream.of(1, 2, 3).append(4).toArray()); }); | ||
it("supports appendAll", function () { return assert.deepEqual([1, 2, 3, 4, 5], Stream_1.Stream.of(1, 2, 3).appendAll([4, 5]).toArray()); }); | ||
it("supports cycle", function () { return assert.deepEqual([1, 2, 3, 1, 2, 3, 1, 2], Stream_1.Stream.of(1, 2, 3).cycle().take(8).toArray()); }); | ||
it("supports appendStream", function () { return assert.deepEqual([1, 2, 3, 4, 5, 6], Stream_1.Stream.of(1, 2, 3).appendStream(Stream_1.Stream.of(4, 5, 6)).toArray()); }); | ||
it("supports flatMap", function () { return assert.deepEqual([1, 2, 3, 4, 5, 6], Stream_1.Stream.of(1, 4).flatMap(function (x) { return Stream_1.Stream.of(x, x + 1, x + 2); }).toArray()); }); | ||
it("correctly reverses", function () { return assert.deepEqual([3, 2, 1], Stream_1.Stream.of(1, 2, 3).reverse().toArray()); }); | ||
it("correctly reverses the empty stream", function () { return assert.deepEqual([], Stream_1.Stream.empty().reverse().toArray()); }); | ||
it("correctly reverses also after prepend", function () { return assert.deepEqual([3, 2, 1], Stream_1.Stream.of(2, 3).prepend(1).reverse().toArray()); }); | ||
it("computes the length correctly", function () { return assert.equal(3, Stream_1.Stream.of(1, 2, 3).length()); }); | ||
it("computes the length of the empty stream correctly", function () { return assert.equal(0, Stream_1.Stream.empty().length()); }); | ||
it("gets the last value correctly", function () { return assert.equal(3, Stream_1.Stream.of(1, 2, 3).last().getOrThrow()); }); | ||
it("gets the last value correctly for an empty stream", function () { return assert.ok(Stream_1.Stream.empty().last().isNone()); }); | ||
it("sorting works", function () { return assert.ok(Stream_1.Stream.of(4, 3, 2, 1) | ||
.equals(Stream_1.Stream.of(1, 2, 3, 4).sortBy(function (x, y) { return y - x; }))); }); | ||
it("correctly drops right n items", function () { return assert.deepEqual([1, 2, 3, 4], Stream_1.Stream.of(1, 2, 3, 4, 5, 6).dropRight(2).toArray()); }); | ||
it("returns an empty stream when dropping right too much", function () { return assert.deepEqual([], Stream_1.Stream.of(1, 2).dropRight(3).toArray()); }); | ||
}); | ||
describe("Prepend", function () { | ||
var basic = Stream_1.Stream.of(1, 2, 3, 4); | ||
var prepended = Stream_1.Stream.of(2, 3, 4).prepend(1); | ||
it("prepends correctly", function () { return assert.ok(basic.equals(prepended)); }); | ||
it("converts to array correctly", function () { return assert.deepEqual(basic.toArray(), prepended.toArray()); }); | ||
it("appends correctly after prepend", function () { return assert.ok(basic.append(5).equals(prepended.append(5))); }); | ||
it("appendsAll correctly after prepend", function () { return assert.ok(basic.appendStream(Stream_1.Stream.of(5, 6)).equals(prepended.appendStream(Stream_1.Stream.of(5, 6)))); }); | ||
it("converts to string correctly after prepend", function () { return assert.equal(basic.toString(), prepended.toString()); }); | ||
it("prependsAll correctly", function () { return assert.deepEqual([1, 2, 3, 4, 5], Stream_1.Stream.of(4, 5).prependAll(Stream_1.Stream.of(1, 2, 3)).toArray()); }); | ||
}); | ||
describe("Stream iteration", function () { | ||
it("finds items", function () { | ||
return Stream_1.Stream.of(1, 2, 3).find(function (x) { return x >= 2; }).contains(2); | ||
}); | ||
it("doesn't find if the predicate doesn't match", function () { | ||
return Stream_1.Stream.of(1, 2, 3).find(function (x) { return x >= 4; }).isNone(); | ||
}); | ||
it("foldsLeft correctly", function () { return assert.equal("cba!", Stream_1.Stream.of("a", "b", "c").foldLeft("!", function (xs, x) { return x + xs; })); }); | ||
it("foldsRight correctly", function () { return assert.equal("!cba", Stream_1.Stream.of("a", "b", "c").foldRight("!", function (x, xs) { return xs + x; })); }); | ||
it("calls forEach correctly", function () { | ||
var ar = []; | ||
Stream_1.Stream.of(1, 2, 3).forEach(function (v) { return ar.push(v); }); | ||
assert.deepEqual([1, 2, 3], ar); | ||
}); | ||
it("get finds when present", function () { return assert.ok(Option_1.Option.of(5).equals(Stream_1.Stream.of(1, 2, 3, 4, 5, 6).get(4))); }); | ||
it("get finds when present after prepend", function () { return assert.ok(Option_1.Option.of(5).equals(Stream_1.Stream.of(2, 3, 4, 5, 6).prepend(1).get(4))); }); | ||
it("get doesn't find when stream too short", function () { return assert.ok(Option_1.Option.none().equals(Stream_1.Stream.of(1, 2, 3).get(4))); }); | ||
it("get doesn't find when negative index", function () { return assert.ok(Option_1.Option.none().equals(Stream_1.Stream.of(1, 2, 3).get(-1))); }); | ||
it("zips with an array", function () { return assert.deepEqual([[1, "a"], [2, "b"]], Stream_1.Stream.of(1, 2, 3).zip(["a", "b"]).toArray()); }); | ||
it("zips with a stream", function () { return assert.deepEqual([["a", 0], ["b", 1]], Stream_1.Stream.of("a", "b").zip(Stream_1.Stream.iterate(0, function (x) { return x + 1; })).toArray()); }); | ||
it("richer example", function () { return assert.deepEqual([[1, "a"], [2, "b"]], Stream_1.Stream.of(1, 2, 3) | ||
.zip(Vector_1.Vector.of("a", "b", "c")).takeWhile(function (_a) { | ||
var k = _a[0], v = _a[1]; | ||
return k < 3; | ||
}).toArray()); }); | ||
}); | ||
describe("Stream filtering", function () { | ||
it("implements takeWhile correctly", function () { return assert.deepEqual([1, 2, 3], Stream_1.Stream.iterate(1, function (x) { return x + 1; }).takeWhile(function (x) { return x < 4; }).toArray()); }); | ||
it("maps correctly", function () { return assert.deepEqual([4, 5, 7, 11], Stream_1.Stream.iterate(1, function (x) { return x * 2; }).map(function (x) { return x + 3; }).take(4).toArray()); }); | ||
it("filters correctly", function () { return assert.deepEqual([8, 32, 64, 128], Stream_1.Stream.iterate(1, function (x) { return x * 2; }).filter(function (x) { return x > 5 && (x < 15 || x > 30); }).take(4).toArray()); }); | ||
it("correctly dropsWhile", function () { return assert.deepEqual([4, 5, 6], Stream_1.Stream.of(1, 2, 3, 4, 5, 6).dropWhile(function (x) { return x < 4; }).toArray()); }); | ||
it("correctly drops n items", function () { return assert.deepEqual([4, 5, 6], Stream_1.Stream.of(1, 2, 3, 4, 5, 6).drop(3).toArray()); }); | ||
it("returns an empty stream when dropping too much", function () { return assert.deepEqual([], Stream_1.Stream.of(1, 2).drop(3).toArray()); }); | ||
it("distinctBy", function () { return assert.deepEqual([1, 2, 3], Stream_1.Stream.of(1, 1, 2, 3, 2, 3, 1).distinctBy(function (x) { return x; }).toArray()); }); | ||
it("distinctBy for the empty stream", function () { return assert.deepEqual([], Stream_1.Stream.empty().distinctBy(function (x) { return x; }).toArray()); }); | ||
it("distinctBy for a single value", function () { return assert.deepEqual([1], Stream_1.Stream.of(1).distinctBy(function (x) { return x; }).toArray()); }); | ||
it("distinctBy, custom equality", function () { return assert.deepEqual([1, 0, 2], Stream_1.Stream.of(1, 0, 1, 2, 3, 2, 3, 1).distinctBy(function (x) { return new SampleData_1.MyClass("hi", x % 3); }).toArray()); }); | ||
it("distinctBy with prepend", function () { return assert.deepEqual([1, 2, 3], Stream_1.Stream.of(2, 3, 2, 3, 1).prepend(1).distinctBy(function (x) { return x; }).toArray()); }); | ||
it("correctly partitions also after prepend", function () { return assert.deepEqual([[1, 3, 5, 7], [2, 4, 6, 8]], Stream_1.Stream.of(2, 3, 4, 5, 6, 7, 8).prepend(1).partition(function (x) { return x % 2 !== 0; }) | ||
.map(function (v) { return v.toArray(); })); }); | ||
it("groupBy works", function () { return assert.ok(HashMap_1.HashMap.empty().put(0, Stream_1.Stream.of(2, 4)).put(1, Stream_1.Stream.of(1, 3)) | ||
.equals(Stream_1.Stream.of(1, 2, 3, 4).groupBy(function (x) { return x % 2; }))); }); | ||
it("supports contain", function () { return assert.ok(Stream_1.Stream.of(1, 2, 3).contains(2)); }); | ||
it("rejects contain", function () { return assert.ok(!Stream_1.Stream.of(1, 2, 3).contains(4)); }); | ||
it("rejects contain, empty stream", function () { return assert.ok(!Stream_1.Stream.empty().contains(4)); }); | ||
it("supports contains, custom equality", function () { return assert.ok(Stream_1.Stream.of(new SampleData_1.MyClass("hi", 3)).contains(new SampleData_1.MyClass("hi", 3))); }); | ||
it("supports allMatch, positive case", function () { return assert.ok(Stream_1.Stream.of(2, 4, 8).allMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports allMatch, negative case", function () { return assert.ok(!Stream_1.Stream.of(2, 5, 8).allMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports allMatch, empty stream", function () { return assert.ok(Stream_1.Stream.empty().allMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports anyMatch, positive case", function () { return assert.ok(Stream_1.Stream.of(3, 5, 8).anyMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports anyMatch, negative case", function () { return assert.ok(!Stream_1.Stream.of(3, 5, 9).anyMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports anyMatch, empty stream", function () { return assert.ok(!Stream_1.Stream.empty().anyMatch(function (x) { return x % 2 === 0; })); }); | ||
}); | ||
describe("Stream Value tests", function () { | ||
it("serializes to string correctly", function () { return assert.equal("[1, 2, 3]", Stream_1.Stream.of(1, 2, 3).toString()); }); | ||
it("serializes to string correctly - arrays & strings", function () { return assert.equal("[[1,'a']]", Stream_1.Stream.ofStruct([1, 'a']).toString()); }); | ||
it("serializes to string correctly - custom toString", function () { return assert.equal("[{field1: hi, field2: 99}]", Stream_1.Stream.of(new SampleData_1.MyClass("hi", 99)).toString()); }); | ||
it("has non-obviously-broken equals", function () { return assert.ok(Stream_1.Stream.of("a", "b", "c").equals(Stream_1.Stream.of("a", "b", "c"))); }); | ||
it("doesn't throw when given another type on equals", function () { return assert.equal(false, Stream_1.Stream.of(1).equals([1, 2])); }); | ||
it("doesn't throw when given null on equals", function () { return assert.equal(false, Stream_1.Stream.of(1).equals(null)); }); | ||
it("is strict with equality", function () { return assert.ok(!Stream_1.Stream.of(1, 2).equals(Stream_1.Stream.of(1, undefined))); }); | ||
}); | ||
describe("Stream conversions", function () { | ||
it("converts to vector", function () { return assert.ok(Vector_1.Vector.of(1, 2, 3).equals(Stream_1.Stream.iterate(1, function (x) { return x + 1; }).take(3).toVector())); }); | ||
it("mkString works", function () { return assert.equal("1, 2, 3", Stream_1.Stream.of(1, 2, 3).mkString(", ")); }); | ||
it("transforms to map", function () { | ||
assert.ok(HashMap_1.HashMap.empty().put(1, "ok").put(2, "bad") | ||
.equals(Stream_1.Stream.ofStruct([1, "ok"], [2, "bad"]).toMap(function (x) { return x; }))); | ||
}); | ||
}); | ||
//# sourceMappingURL=Stream.js.map |
@@ -41,2 +41,4 @@ "use strict"; | ||
it("distinctBy with prepend", function () { return assert.deepEqual([1, 2, 3], Vector_1.Vector.of(2, 3, 2, 3, 1).prepend(1).distinctBy(function (x) { return x; }).toArray()); }); | ||
it("computes the length correctly", function () { return assert.equal(3, Vector_1.Vector.of(1, 2, 3).length()); }); | ||
it("computes the length of the empty vector correctly", function () { return assert.equal(0, Vector_1.Vector.empty().length()); }); | ||
}); | ||
@@ -59,5 +61,5 @@ describe("Vector value extraction", function () { | ||
it("correctly gets the first element also after prepend", function () { return assert.equal(1, Vector_1.Vector.of(4, 5).prependAll(Vector_1.Vector.of(1, 2, 3)).head().getOrUndefined()); }); | ||
it("correctly gets the tail of the empty vector", function () { return assert.ok(Vector_1.Vector.empty().equals(Vector_1.Vector.empty().tail())); }); | ||
it("correctly gets the tail of a simple vector", function () { return assert.ok(Vector_1.Vector.of(2, 3, 4).equals(Vector_1.Vector.of(1, 2, 3, 4).tail())); }); | ||
it("correctly gets the tail of a vector after prepend", function () { return assert.ok(Vector_1.Vector.of(2, 3, 4).equals(Vector_1.Vector.of(2, 3, 4).prepend(1).tail())); }); | ||
it("correctly gets the tail of the empty vector", function () { return assert.ok(Vector_1.Vector.empty().tail().isNone()); }); | ||
it("correctly gets the tail of a simple vector", function () { return assert.ok(Vector_1.Vector.of(2, 3, 4).equals(Vector_1.Vector.of(1, 2, 3, 4).tail().getOrThrow())); }); | ||
it("correctly gets the tail of a vector after prepend", function () { return assert.ok(Vector_1.Vector.of(2, 3, 4).equals(Vector_1.Vector.of(2, 3, 4).prepend(1).tail().getOrThrow())); }); | ||
it("correctly reverses", function () { return assert.deepEqual([3, 2, 1], Vector_1.Vector.of(1, 2, 3).reverse().toArray()); }); | ||
@@ -120,2 +122,4 @@ it("correctly reverses the empty vector", function () { return assert.deepEqual([], Vector_1.Vector.empty().reverse().toArray()); }); | ||
it("serializes to string correctly", function () { return assert.equal("[1, 2, 3]", Vector_1.Vector.of(1, 2, 3).toString()); }); | ||
it("serializes to string correctly - arrays & strings", function () { return assert.equal("[[1,'a']]", Vector_1.Vector.ofStruct([1, 'a']).toString()); }); | ||
it("serializes to string correctly - custom toString", function () { return assert.equal("[{field1: hi, field2: 99}]", Vector_1.Vector.of(new SampleData_1.MyClass("hi", 99)).toString()); }); | ||
it("has non-obviously-broken equals", function () { return assert.ok(Vector_1.Vector.of("a", "b", "c").equals(Vector_1.Vector.of("a", "b", "c"))); }); | ||
@@ -125,3 +129,13 @@ it("doesn't throw when given another type on equals", function () { return assert.equal(false, Vector_1.Vector.of(1).equals([1, 2])); }); | ||
it("is strict with equality", function () { return assert.ok(!Vector_1.Vector.of(1, 2).equals(Vector_1.Vector.of(1, undefined))); }); | ||
it("supports contain", function () { return assert.ok(Vector_1.Vector.of(1, 2, 3).contains(2)); }); | ||
it("rejects contain", function () { return assert.ok(!Vector_1.Vector.of(1, 2, 3).contains(4)); }); | ||
it("rejects contain, empty vector", function () { return assert.ok(!Vector_1.Vector.empty().contains(4)); }); | ||
it("supports contains, custom equality", function () { return assert.ok(Vector_1.Vector.of(new SampleData_1.MyClass("hi", 3)).contains(new SampleData_1.MyClass("hi", 3))); }); | ||
it("supports allMatch, positive case", function () { return assert.ok(Vector_1.Vector.of(2, 4, 8).allMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports allMatch, negative case", function () { return assert.ok(!Vector_1.Vector.of(2, 5, 8).allMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports allMatch, empty vector", function () { return assert.ok(Vector_1.Vector.empty().allMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports anyMatch, positive case", function () { return assert.ok(Vector_1.Vector.of(3, 5, 8).anyMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports anyMatch, negative case", function () { return assert.ok(!Vector_1.Vector.of(3, 5, 9).anyMatch(function (x) { return x % 2 === 0; })); }); | ||
it("supports anyMatch, empty vector", function () { return assert.ok(!Vector_1.Vector.empty().anyMatch(function (x) { return x % 2 === 0; })); }); | ||
}); | ||
//# sourceMappingURL=Vector.js.map |
{ | ||
"name": "prelude.ts", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "A typescript functional programming library", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -98,2 +98,17 @@ /** | ||
/** | ||
* Utility function to help converting a value to string | ||
* util.inspect seems to depend on node. | ||
* @hidden | ||
*/ | ||
export function toStringHelper(obj: any|null): string { | ||
switch (obj.constructor) { | ||
case Array: | ||
return "[" + obj.map(toStringHelper) + "]" | ||
case String: | ||
return "'" + obj + "'"; | ||
} | ||
return obj+""; | ||
} | ||
/** | ||
* Enumeration used to express ordering relationships. | ||
@@ -100,0 +115,0 @@ * it's a const enum, is replaced by integers in the source. |
import { IMap } from "./IMap"; | ||
import { hasEquals, HasEquals, WithEquality, | ||
getHashCode, areEqual } from "./Comparison"; | ||
getHashCode, areEqual, toStringHelper } from "./Comparison"; | ||
import { Option, none, None } from "./Option"; | ||
@@ -100,3 +100,3 @@ import { HashSet } from "./HashSet"; | ||
*/ | ||
size(): number { | ||
length(): number { | ||
return this.hamt.size; | ||
@@ -214,3 +214,3 @@ } | ||
const sz = this.hamt.size; | ||
if (other.size() === 0 && sz === 0) { | ||
if (other.length() === 0 && sz === 0) { | ||
// we could get that i'm not the empty map | ||
@@ -220,3 +220,3 @@ // but my size is zero, after some filtering and such. | ||
} | ||
if (sz !== other.size()) { | ||
if (sz !== other.length()) { | ||
return false; | ||
@@ -256,4 +256,8 @@ } | ||
(acc: string[], value: V, key: K) => | ||
{acc.push(key + " => " + value); return acc;}, []).join(", ") + "}"; | ||
{acc.push(key + " => " + toStringHelper(value)); return acc;}, []).join(", ") + "}"; | ||
} | ||
inspect(): string { | ||
return this.toString(); | ||
} | ||
} | ||
@@ -301,3 +305,3 @@ | ||
size(): number { | ||
length(): number { | ||
return 0; | ||
@@ -338,3 +342,3 @@ } | ||
} | ||
return <any>other === emptyHashMap || other.size() === 0; | ||
return <any>other === emptyHashMap || other.length() === 0; | ||
} | ||
@@ -341,0 +345,0 @@ |
import { ISet } from "./ISet"; | ||
import { WithEquality, hasEquals, HasEquals, | ||
getHashCode, areEqual } from "./Comparison"; | ||
getHashCode, areEqual, toStringHelper } from "./Comparison"; | ||
const hamt: any = require("hamt_plus"); | ||
@@ -32,10 +32,3 @@ | ||
static ofIterable<T>(elts: Iterable<T & WithEquality>): HashSet<T> { | ||
return new HashSet<T>(hamt.empty.mutate((h:any) => { | ||
const iterator = elts[Symbol.iterator](); | ||
let curItem = iterator.next(); | ||
while (!curItem.done) { | ||
h.set(curItem.value, curItem.value); | ||
curItem = iterator.next(); | ||
} | ||
})); | ||
return new HashSet<T>(hamt.empty).addAll(elts); | ||
} | ||
@@ -66,2 +59,16 @@ | ||
/** | ||
* Add multiple elements to this set. | ||
*/ | ||
addAll(elts: Iterable<T & WithEquality>): HashSet<T> { | ||
return new HashSet<T>(this.hamt.mutate((h:any) => { | ||
const iterator = elts[Symbol.iterator](); | ||
let curItem = iterator.next(); | ||
while (!curItem.done) { | ||
h.set(curItem.value, curItem.value); | ||
curItem = iterator.next(); | ||
} | ||
})); | ||
} | ||
/** | ||
* Returns true if the element you give is present in | ||
@@ -71,6 +78,18 @@ * the set, false otherwise. | ||
contains(elt: T & WithEquality): boolean { | ||
return this.hamt.get(elt) !== undefined; | ||
return this.hamt.has(elt); | ||
} | ||
/** | ||
* Return a new collection where each element was transformed | ||
* by the mapper function you give. | ||
* The resulting set may be smaller than the source. | ||
*/ | ||
map<U>(mapper:(v:T)=>U&WithEquality): HashSet<U> { | ||
return this.hamt.fold( | ||
(acc: HashSet<U>, value: T&WithEquality, key: T&WithEquality) => { | ||
return acc.add(mapper(value)); | ||
}, HashSet.empty()); | ||
} | ||
/** | ||
* Converts this set to an array | ||
@@ -85,3 +104,3 @@ */ | ||
*/ | ||
size(): number { | ||
length(): number { | ||
return this.hamt.size; | ||
@@ -118,2 +137,34 @@ } | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
allMatch(predicate:(v:T)=>boolean): boolean { | ||
const iterator: Iterator<T> = this.hamt.values(); | ||
let curItem = iterator.next(); | ||
while (!curItem.done) { | ||
if (!predicate(curItem.value)) { | ||
return false; | ||
} | ||
curItem = iterator.next(); | ||
} | ||
return true; | ||
} | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
anyMatch(predicate:(v:T)=>boolean): boolean { | ||
const iterator: Iterator<T> = this.hamt.values(); | ||
let curItem = iterator.next(); | ||
while (!curItem.done) { | ||
if (predicate(curItem.value)) { | ||
return true; | ||
} | ||
curItem = iterator.next(); | ||
} | ||
return false; | ||
} | ||
/** | ||
* Two objects are equal if they represent the same value, | ||
@@ -167,4 +218,8 @@ * regardless of whether they are the same object physically | ||
(acc: string[], value: T, key: T) => | ||
{acc.push(key+""); return acc;}, []).join(", ") + "}"; | ||
{acc.push(toStringHelper(key)); return acc;}, []).join(", ") + "}"; | ||
} | ||
inspect(): string { | ||
return this.toString(); | ||
} | ||
} | ||
@@ -192,2 +247,9 @@ | ||
/** | ||
* Add multiple elements to this set. | ||
*/ | ||
addAll(elts: Iterable<T & WithEquality>): HashSet<T> { | ||
return HashSet.ofIterable(elts); | ||
} | ||
contains(elt: T & WithEquality): boolean { | ||
@@ -197,2 +259,10 @@ return false; | ||
map<U>(mapper:(v:T)=>U&WithEquality): HashSet<U> { | ||
return <EmptyHashSet<U>>emptyHashSet; | ||
} | ||
toArray(): Array<T & WithEquality> { | ||
return []; | ||
} | ||
[Symbol.iterator](): Iterator<T> { | ||
@@ -202,3 +272,3 @@ return { next: () => ({ done: true, value: <any>undefined }) }; | ||
size(): number { | ||
length(): number { | ||
return 0; | ||
@@ -215,7 +285,15 @@ } | ||
anyMatch(predicate:(v:T)=>boolean): boolean { | ||
return false; | ||
} | ||
allMatch(predicate:(v:T)=>boolean): boolean { | ||
return true; | ||
} | ||
equals(other: HashSet<T>): boolean { | ||
if (!other || !other.size) { | ||
if (!other || !other.length) { | ||
return false; | ||
} | ||
return <any>other === emptyHashSet || other.size() === 0; | ||
return <any>other === emptyHashSet || other.length() === 0; | ||
} | ||
@@ -222,0 +300,0 @@ |
@@ -114,3 +114,3 @@ import { WithEquality } from "./Comparison"; | ||
*/ | ||
size(): number; | ||
length(): number; | ||
@@ -117,0 +117,0 @@ /** |
@@ -13,3 +13,3 @@ import { WithEquality } from "./Comparison"; | ||
*/ | ||
size(): number; | ||
length(): number; | ||
@@ -27,2 +27,7 @@ /** | ||
/** | ||
* Add multiple elements to this set. | ||
*/ | ||
addAll(elts: Iterable<T & WithEquality>): ISet<T>; | ||
/** | ||
* Returns true if the element you give is present in | ||
@@ -34,2 +39,9 @@ * the set, false otherwise. | ||
/** | ||
* Return a new collection where each element was transformed | ||
* by the mapper function you give. | ||
* The resulting set may be smaller than the source. | ||
*/ | ||
map<U>(mapper:(v:T)=>U&WithEquality): ISet<U>; | ||
/** | ||
* Returns a new Set containing the difference | ||
@@ -49,2 +61,14 @@ * between this set and the other Set passed as parameter. | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
allMatch(predicate:(v:T)=>boolean): boolean; | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
anyMatch(predicate:(v:T)=>boolean): boolean; | ||
/** | ||
* Converts this set to an array | ||
@@ -51,0 +75,0 @@ */ |
import { Value } from "./Value"; | ||
import { Seq } from "./Seq"; | ||
import { Vector } from "./Vector"; | ||
import { WithEquality, areEqual, getHashCode } from "./Comparison"; | ||
import { WithEquality, areEqual, | ||
getHashCode, toStringHelper } from "./Comparison"; | ||
@@ -118,4 +119,6 @@ /** | ||
* throw an exception. | ||
* You can optionally pass a message that'll be used as the | ||
* exception message. | ||
*/ | ||
abstract getOrThrow(): T; | ||
abstract getOrThrow(message?: string): T; | ||
@@ -180,2 +183,8 @@ /** | ||
/** | ||
* Execute a side-effecting function if the option | ||
* is a Some, returns the option. | ||
*/ | ||
abstract ifPresent(fn:(v:T)=>void): Option<T>; | ||
/** | ||
* Convert to a vector. If it's a None, it's the empty | ||
@@ -205,2 +214,7 @@ * vector, if it's a Some, it's a one-element vector with | ||
abstract toString(): string; | ||
/** | ||
* Used by the node REPL to display values. | ||
*/ | ||
abstract inspect(): string; | ||
} | ||
@@ -225,3 +239,3 @@ | ||
} | ||
getOrThrow(): T { | ||
getOrThrow(message?: string): T { | ||
return this.value; | ||
@@ -253,2 +267,6 @@ } | ||
} | ||
ifPresent(fn:(v:T)=>void): Option<T> { | ||
fn(this.value); | ||
return this; | ||
} | ||
toVector(): Vector<T> { | ||
@@ -270,4 +288,7 @@ return Vector.ofStruct(this.value); | ||
toString(): string { | ||
return "Some(" + this.value + ")"; | ||
return "Some(" + toStringHelper(this.value) + ")"; | ||
} | ||
inspect(): string { | ||
return this.toString(); | ||
} | ||
} | ||
@@ -288,4 +309,4 @@ | ||
} | ||
getOrThrow(): T & WithEquality { | ||
throw "getOrThrow called on none!"; | ||
getOrThrow(message?: string): T & WithEquality { | ||
throw message || "getOrThrow called on none!"; | ||
} | ||
@@ -316,2 +337,5 @@ contains(v: T): boolean { | ||
} | ||
ifPresent(fn:(v:T)=>void): Option<T> { | ||
return this; | ||
} | ||
toVector(): Vector<T> { | ||
@@ -329,2 +353,5 @@ return Vector.empty<T>(); | ||
} | ||
inspect(): string { | ||
return this.toString(); | ||
} | ||
} | ||
@@ -331,0 +358,0 @@ |
@@ -12,5 +12,5 @@ import { Value } from "./Value"; | ||
/** | ||
* Get the size (length) of the collection. | ||
* Get the length of the collection. | ||
*/ | ||
size(): number; | ||
length(): number; | ||
@@ -55,4 +55,5 @@ /** | ||
* Call a function for element in the collection. | ||
* Return the unchanged collection. | ||
*/ | ||
forEach(fn: (v:T)=>void): void; | ||
forEach(fn: (v:T)=>void): Seq<T>; | ||
@@ -75,5 +76,5 @@ /** | ||
* Get all the elements in the collection but the first one. | ||
* If the collection is empty, return an empty collection. | ||
* Option.None if it's empty. | ||
*/ | ||
tail(): Seq<T>; | ||
tail(): Option<Seq<T>>; | ||
@@ -109,2 +110,8 @@ /** | ||
/** | ||
* Returns true if the item is in the collection, | ||
* false otherwise. | ||
*/ | ||
contains(v:T&WithEquality): boolean; | ||
/** | ||
* Calls the function you give for each item in the collection, | ||
@@ -128,2 +135,14 @@ * your function returns a collection, all the collections are | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
allMatch(predicate:(v:T)=>boolean): boolean; | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
anyMatch(predicate:(v:T)=>boolean): boolean; | ||
/** | ||
* Group elements in the collection using a classifier function. | ||
@@ -130,0 +149,0 @@ * Elements are then organized in a map. The key is the value of |
import { Option } from "./Option"; | ||
import { Vector } from "./Vector"; | ||
import { WithEquality } from "./Comparison"; | ||
import { WithEquality, toStringHelper, | ||
getHashCode, areEqual, Ordering } from "./Comparison"; | ||
import { Value } from "./Value"; | ||
import { IMap } from "./IMap"; | ||
import { HashMap } from "./HashMap"; | ||
import { ISet } from "./ISet"; | ||
import { HashSet } from "./HashSet"; | ||
import { Seq } from "./Seq"; | ||
// TODO extend seq? | ||
/** | ||
* A lazy, potentially infinite, sequence of values. | ||
* | ||
* Use take() for instance to reduce it to a finite stream. | ||
* Use take() for instance to reduce an infinite stream to a finite one. | ||
*/ | ||
export abstract class Stream<T> implements Iterable<T> { | ||
export abstract class Stream<T> implements Iterable<T>, Value, Seq<T> { | ||
/** | ||
* The empty stream | ||
*/ | ||
static empty<T>(): Stream<T> { | ||
return <EmptyStream<T>>emptyStream; | ||
} | ||
/** | ||
* Create a Stream with the elements you give. | ||
* No equality requirements. | ||
*/ | ||
static ofStruct<T>(...elts:T[]): Stream<T> { | ||
return Stream.ofIterableStruct(elts); | ||
} | ||
/** | ||
* Create a Stream with the elements you give. | ||
* Equality requirements. | ||
*/ | ||
static of<T>(...elts:Array<T&WithEquality>): Stream<T> { | ||
return Stream.ofIterableStruct(elts); | ||
} | ||
/** | ||
* Build a stream from any iterable, which means also | ||
* an array for instance. | ||
* @type T the item type -- no equality requirement | ||
*/ | ||
static ofIterableStruct<T>(elts: Iterable<T>): Stream<T> { | ||
// need to eagerly copy the iterable. the reason | ||
// is, if we would build the stream based on the iterator | ||
// in the iterable, Stream.tail() would do it.next(). | ||
// but it.next() modifies the iterator (mutability), | ||
// and you would end up with getting two different tails | ||
// for the same stream if you call .tail() twice in a row | ||
return Stream.ofArrayStruct(Array.from(elts)); | ||
} | ||
/** | ||
* Build a stream from any iterable, which means also | ||
* an array for instance. | ||
* @type T the item type -- equality requirement | ||
*/ | ||
static ofIterable<T>(elts: Iterable<T & WithEquality>): Stream<T> { | ||
return Stream.ofIterableStruct(elts); | ||
} | ||
/** | ||
* Build a stream from an array (slightly faster | ||
* than building from an iterable) | ||
* @type T the item type -- no equality requirement | ||
*/ | ||
static ofArrayStruct<T>(elts: Array<T>): Stream<T> { | ||
if (elts.length === 0) { | ||
return <EmptyStream<T>>emptyStream; | ||
} | ||
const head = elts[0]; | ||
return new ConsStream(head, () => Stream.ofArrayStruct(elts.slice(1))); | ||
} | ||
/** | ||
* Build a stream from an array (slightly faster | ||
* than building from an iterable) | ||
* @type T the item type -- equality requirement | ||
*/ | ||
static ofArray<T>(elts: Array<T & WithEquality>): Stream<T> { | ||
return Stream.ofArrayStruct(elts); | ||
} | ||
/** | ||
* Build an infinite stream from a seed and a transformation function. | ||
@@ -69,2 +144,7 @@ * No equality requirements. | ||
/** | ||
* Get the length of the collection. | ||
*/ | ||
abstract length(): number; | ||
/** | ||
* true if the collection is empty, false otherwise. | ||
@@ -83,7 +163,38 @@ */ | ||
* Get all the elements in the collection but the first one. | ||
* If the collection is empty, return an empty collection. | ||
* If the collection is empty, return None. | ||
*/ | ||
abstract tail(): Stream<T>; | ||
abstract tail(): Option<Stream<T>>; | ||
/** | ||
* Get the last value of the collection, if any. | ||
* returns Option.Some if the collection is not empty, | ||
* Option.None if it's empty. | ||
*/ | ||
abstract last(): Option<T>; | ||
/** | ||
* Retrieve the element at index idx. | ||
* Returns an option because the collection may | ||
* contain less elements than the index. | ||
* | ||
* Careful this is going to have poor performance | ||
* on Stream, which is not a good data structure | ||
* for random access! | ||
*/ | ||
abstract get(idx: number): Option<T>; | ||
/** | ||
* Search for an item matching the predicate you pass, | ||
* return Option.Some of that element if found, | ||
* Option.None otherwise. | ||
*/ | ||
abstract find(predicate:(v:T)=>boolean): Option<T>; | ||
/** | ||
* Returns true if the item is in the collection, | ||
* false otherwise. | ||
*/ | ||
abstract contains(v:T&WithEquality): boolean; | ||
/** | ||
* Return a new stream keeping only the first n elements | ||
@@ -101,2 +212,205 @@ * from this stream. | ||
/** | ||
* Returns a new collection with the first | ||
* n elements discarded. | ||
* If the collection has less than n elements, | ||
* returns the empty collection. | ||
*/ | ||
abstract drop(n:number): Stream<T>; | ||
/** | ||
* Returns a new collection, discarding the first elements | ||
* until one element fails the predicate. All elements | ||
* after that point are retained. | ||
*/ | ||
abstract dropWhile(predicate:(x:T)=>boolean): Stream<T>; | ||
/** | ||
* Returns a new collection with the last | ||
* n elements discarded. | ||
* If the collection has less than n elements, | ||
* returns the empty collection. | ||
*/ | ||
abstract dropRight(n:number): Stream<T>; | ||
/** | ||
* Reduces the collection to a single value. | ||
* Left-associative. | ||
* | ||
* Example: | ||
* | ||
* Vector.of("a", "b", "c").foldLeft("!", (xs,x) => x+xs)) | ||
* => "cba!" | ||
* | ||
* @param zero The initial value | ||
* @param fn A function taking the previous value and | ||
* the current collection item, and returning | ||
* an updated value. | ||
*/ | ||
abstract foldLeft<U>(zero: U, fn:(soFar:U,cur:T)=>U): U; | ||
/** | ||
* Reduces the collection to a single value. | ||
* Right-associative. | ||
* | ||
* Example: | ||
* | ||
* Vector.of("a", "b", "c").foldRight("!", (x,xs) => xs+x)) | ||
* => "!cba" | ||
* | ||
* @param zero The initial value | ||
* @param fn A function taking the current collection item and | ||
* the previous value , and returning | ||
* an updated value. | ||
*/ | ||
abstract foldRight<U>(zero: U, fn:(cur:T, soFar:U)=>U): U; | ||
/** | ||
* Combine this collection with the collection you give in | ||
* parameter to produce a new collection which combines both, | ||
* in pairs. For instance: | ||
* | ||
* Vector.of(1,2,3).zip(["a","b","c"]) | ||
* => Vector.of([1,"a"], [2,"b"], [3,"c"]) | ||
* | ||
* The result collection will have the length of the shorter | ||
* of both collections. Extra elements will be discarded. | ||
* No equality requirements. | ||
*/ | ||
abstract zipStruct<U>(other: Iterable<U>): Stream<[T,U]>; | ||
/** | ||
* Combine this collection with the collection you give in | ||
* parameter to produce a new collection which combines both, | ||
* in pairs. For instance: | ||
* | ||
* Vector.of(1,2,3).zip("a","b","c") | ||
* => Vector.of([1,"a"], [2,"b"], [3,"c"]) | ||
* | ||
* The result collection will have the length of the shorter | ||
* of both collections. Extra elements will be discarded. | ||
* Equality requirements. | ||
*/ | ||
zip<U>(other: Iterable<U&WithEquality>): Stream<[T,U]> { | ||
return this.zipStruct(other); | ||
} | ||
/** | ||
* Reverse the collection. For instance: | ||
* | ||
* [1,2,3] => [3,2,1] | ||
*/ | ||
abstract reverse(): Stream<T>; | ||
/** | ||
* Returns a pair of two collections; the first one | ||
* will only contain the items from this collection for | ||
* which the predicate you give returns true, the second | ||
* will only contain the items from this collection where | ||
* the predicate returns false. | ||
* | ||
* Vector.of(1,2,3,4).partition(x => x%2===0) | ||
* => [[2,4],[1,3]] | ||
*/ | ||
abstract partition(predicate:(x:T)=>boolean): [Stream<T>,Stream<T>]; | ||
/** | ||
* Group elements in the collection using a classifier function. | ||
* Elements are then organized in a map. The key is the value of | ||
* the classifier, and in value we get the list of elements | ||
* matching that value. | ||
*/ | ||
abstract groupBy<C>(classifier: (v:T & WithEquality)=>C & WithEquality): HashMap<C,Stream<T>>; | ||
/** | ||
* Append an element at the end of this Stream. | ||
* No equality requirements. | ||
*/ | ||
abstract appendStruct(v:T): Stream<T>; | ||
/** | ||
* Append an element at the end of this Stream. | ||
* Equality requirements. | ||
*/ | ||
append(v:T&WithEquality): Stream<T> { | ||
return this.appendStruct(v); | ||
} | ||
/* | ||
* Append multiple elements at the end of this Stream. | ||
* No equality requirements. | ||
*/ | ||
abstract appendAllStruct(elts:Iterable<T>): Stream<T>; | ||
/* | ||
* Append multiple elements at the end of this Stream. | ||
* Equality requirements. | ||
*/ | ||
appendAll(elts:Iterable<T>): Stream<T> { | ||
return this.appendAllStruct(elts); | ||
} | ||
/* | ||
* Append another Stream at the end of this Stream. | ||
* | ||
* There is no function taking a javascript iterator, | ||
* because iterators are stateful and Streams lazy. | ||
* If we would create two Streams working on the same iterator, | ||
* the streams would interact with one another. | ||
* It also breaks the cycle() function. | ||
* No equality requirements. | ||
*/ | ||
abstract appendStreamStruct(elts:Stream<T>): Stream<T>; | ||
/* | ||
* Append another Stream at the end of this Stream. | ||
* | ||
* There is no function taking a javascript iterator, | ||
* because iterators are stateful and Streams lazy. | ||
* If we would create two Streams working on the same iterator, | ||
* the streams would interact with one another. | ||
* It also breaks the cycle() function. | ||
* Equality requirements. | ||
*/ | ||
appendStream(elts:Stream<T>): Stream<T> { | ||
return this.appendStreamStruct(elts); | ||
} | ||
/** | ||
* Prepend an element at the beginning of the collection. | ||
* Equality requirements. | ||
*/ | ||
prepend(elt: T & WithEquality): Stream<T> { | ||
return this.prependStruct(elt); | ||
} | ||
/** | ||
* Prepend an element at the beginning of the collection. | ||
* No equality requirements. | ||
*/ | ||
abstract prependStruct(elt: T): Stream<T>; | ||
/** | ||
* Prepend multiple elements at the beginning of the collection. | ||
* Equality requirements. | ||
*/ | ||
prependAll(elts: Iterable<T&WithEquality>): Stream<T> { | ||
return this.prependAllStruct(elts); | ||
} | ||
/** | ||
* Prepend multiple elements at the beginning of the collection. | ||
* No equality requirements. | ||
*/ | ||
abstract prependAllStruct(elts: Iterable<T>): Stream<T>; | ||
/** | ||
* Repeat infinitely this Stream. | ||
* For instance: | ||
* | ||
* Stream.of(1,2,3).cycle() | ||
* => [1,2,3,1,2,3,1,2...] | ||
*/ | ||
abstract cycle(): Stream<T>; | ||
/** | ||
* Return a new collection where each element was transformed | ||
@@ -116,2 +430,32 @@ * by the mapper function you give. | ||
/** | ||
* Calls the function you give for each item in the collection, | ||
* your function returns a collection, all the collections are | ||
* concatenated. | ||
* This is the monadic bind. | ||
* No equality requirement | ||
*/ | ||
abstract flatMapStruct<U>(mapper:(v:T)=>Stream<U>): Stream<U>; | ||
/** | ||
* Calls the function you give for each item in the collection, | ||
* your function returns a collection, all the collections are | ||
* concatenated. | ||
* This is the monadic bind. | ||
* Equality requirement | ||
*/ | ||
abstract flatMap<U>(mapper:(v:T)=>Stream<U&WithEquality>): Stream<U>; | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
abstract allMatch(predicate:(v:T)=>boolean): boolean; | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
abstract anyMatch(predicate:(v:T)=>boolean): boolean; | ||
/** | ||
* Call a predicate for each element in the collection, | ||
@@ -124,2 +468,31 @@ * build a new collection holding only the elements | ||
/** | ||
* Returns a new collection with elements | ||
* sorted according to the comparator you give. | ||
*/ | ||
abstract sortBy(compare: (v1:T,v2:T)=>Ordering): Stream<T>; | ||
/** | ||
* Remove duplicate items; elements are mapped to keys, those | ||
* get compared. | ||
* | ||
* Vector.of(1,1,2,3,2,3,1).distinctBy(x => x) | ||
* => [1,2,3] | ||
*/ | ||
abstract distinctBy<U>(keyExtractor: (x:T)=>U&WithEquality): Stream<T>; | ||
/** | ||
* Call a function for element in the collection. | ||
*/ | ||
abstract forEach(fn: (v:T)=>void): Stream<T>; | ||
/** | ||
* Joins elements of the collection by a separator. | ||
* Example: | ||
* | ||
* Vector.of(1,2,3).mkString(", ") | ||
* => "1, 2, 3" | ||
*/ | ||
abstract mkString(separator: string): string; | ||
/** | ||
* Convert to array. | ||
@@ -135,2 +508,45 @@ * Don't do it on an infinite stream! | ||
abstract toVector(): Vector<T>; | ||
/** | ||
* Convert this collection to a map. You give a function which | ||
* for each element in the collection returns a pair. The | ||
* key of the pair will be used as a key in the map, the value, | ||
* as a value in the map. If several values get the same key, | ||
* entries will be lost. | ||
* Equality requirements. | ||
*/ | ||
abstract toMap<K,V>(converter:(x:T)=>[K & WithEquality,V & WithEquality]): IMap<K,V>; | ||
/** | ||
* Convert this collection to a map. You give a function which | ||
* for each element in the collection returns a pair. The | ||
* key of the pair will be used as a key in the map, the value, | ||
* as a value in the map. If several values get the same key, | ||
* entries will be lost. | ||
* No equality requirements. | ||
*/ | ||
abstract toMapStruct<K,V>(converter:(x:T)=>[K & WithEquality,V]): IMap<K,V>; | ||
/** | ||
* Two objects are equal if they represent the same value, | ||
* regardless of whether they are the same object physically | ||
* in memory. | ||
*/ | ||
abstract equals(other: Stream<T>): boolean; | ||
/** | ||
* Get a human-friendly string representation of that value. | ||
*/ | ||
abstract toString(): string; | ||
/** | ||
* Get a number for that object. Two different values | ||
* may get the same number, but one value must always get | ||
* the same number. The formula can impact performance. | ||
*/ | ||
abstract hashCode(): number; | ||
inspect(): string { | ||
return this.toString(); | ||
} | ||
} | ||
@@ -151,2 +567,6 @@ | ||
length(): number { | ||
return 0; | ||
} | ||
isEmpty(): boolean { | ||
@@ -160,6 +580,22 @@ return true; | ||
tail(): Stream<T> { | ||
return this; | ||
tail(): Option<Stream<T>> { | ||
return Option.none<Stream<T>>(); | ||
} | ||
last(): Option<T> { | ||
return Option.none<T>(); | ||
} | ||
get(idx: number): Option<T> { | ||
return Option.none<T>(); | ||
} | ||
find(predicate:(v:T)=>boolean): Option<T> { | ||
return Option.none<T>(); | ||
} | ||
contains(v:T&WithEquality): boolean { | ||
return false; | ||
} | ||
take(n: number): Stream<T> { | ||
@@ -173,7 +609,62 @@ return this; | ||
/** | ||
* Return a new collection where each element was transformed | ||
* by the mapper function you give. | ||
* No equality requirements. | ||
*/ | ||
drop(n:number): Stream<T> { | ||
return this; | ||
} | ||
dropWhile(predicate:(x:T)=>boolean): Stream<T> { | ||
return this; | ||
} | ||
dropRight(n:number): Stream<T> { | ||
return this; | ||
} | ||
foldLeft<U>(zero: U, fn:(soFar:U,cur:T)=>U): U { | ||
return zero; | ||
} | ||
foldRight<U>(zero: U, fn:(cur:T, soFar:U)=>U): U { | ||
return zero; | ||
} | ||
zipStruct<U>(other: Iterable<U>): Stream<[T,U]> { | ||
return <EmptyStream<[T,U]>>emptyStream; | ||
} | ||
reverse(): Stream<T> { | ||
return this; | ||
} | ||
partition(predicate:(x:T)=>boolean): [Stream<T>,Stream<T>] { | ||
return [Stream.empty<T>(), Stream.empty<T>()]; | ||
} | ||
groupBy<C>(classifier: (v:T & WithEquality)=>C & WithEquality): HashMap<C,Stream<T>> { | ||
return HashMap.empty<C,Stream<T>>(); | ||
} | ||
appendStruct(v:T): Stream<T> { | ||
return Stream.ofStruct(v); | ||
} | ||
appendAllStruct(elts:Iterable<T>): Stream<T> { | ||
return Stream.ofIterableStruct(elts); | ||
} | ||
appendStreamStruct(elts:Stream<T>): Stream<T> { | ||
return elts; | ||
} | ||
prependStruct(elt: T): Stream<T> { | ||
return Stream.ofStruct(elt); | ||
} | ||
prependAllStruct(elt: Iterable<T>): Stream<T> { | ||
return Stream.ofIterableStruct(elt); | ||
} | ||
cycle(): Stream<T> { | ||
return <EmptyStream<T>>emptyStream; | ||
} | ||
mapStruct<U>(mapper:(v:T)=>U): Stream<U> { | ||
@@ -183,7 +674,2 @@ return <EmptyStream<U>>emptyStream; | ||
/** | ||
* Return a new collection where each element was transformed | ||
* by the mapper function you give. | ||
* Equality requirements. | ||
*/ | ||
map<U>(mapper:(v:T)=>U&WithEquality): Stream<U> { | ||
@@ -193,2 +679,18 @@ return <EmptyStream<U>>emptyStream; | ||
flatMapStruct<U>(mapper:(v:T)=>Stream<U>): Stream<U> { | ||
return <EmptyStream<U>>emptyStream; | ||
} | ||
flatMap<U>(mapper:(v:T)=>Stream<U&WithEquality>): Stream<U> { | ||
return <EmptyStream<U>>emptyStream; | ||
} | ||
allMatch(predicate:(v:T)=>boolean): boolean { | ||
return true; | ||
} | ||
anyMatch(predicate:(v:T)=>boolean): boolean { | ||
return false; | ||
} | ||
filter(predicate:(v:T)=>boolean): Stream<T> { | ||
@@ -198,2 +700,18 @@ return this; | ||
sortBy(compare: (v1:T,v2:T)=>Ordering): Stream<T> { | ||
return this; | ||
} | ||
distinctBy<U>(keyExtractor: (x:T)=>U&WithEquality): Stream<T> { | ||
return this; | ||
} | ||
forEach(fn: (v:T)=>void): Stream<T> { | ||
return this; | ||
} | ||
mkString(separator: string): string { | ||
return ""; | ||
} | ||
toArray(): T[] { | ||
@@ -206,2 +724,25 @@ return []; | ||
} | ||
toMap<K,V>(converter:(x:T)=>[K & WithEquality,V & WithEquality]): IMap<K,V> { | ||
return HashMap.empty<K,V>(); | ||
} | ||
toMapStruct<K,V>(converter:(x:T)=>[K & WithEquality,V]): IMap<K,V> { | ||
return HashMap.empty<K,V>(); | ||
} | ||
equals(other: Stream<T>): boolean { | ||
if (!other) { | ||
return false; | ||
} | ||
return other.isEmpty(); | ||
} | ||
hashCode(): number { | ||
return 1; | ||
} | ||
toString(): string { | ||
return "[]"; | ||
} | ||
} | ||
@@ -226,3 +767,3 @@ | ||
const value = item.head().getOrThrow(); | ||
item = item.tail(); | ||
item = item.tail().getOrThrow(); | ||
return {done: false, value}; | ||
@@ -233,2 +774,6 @@ } | ||
length(): number { | ||
return this.foldLeft(0, (n, ignored) => n + 1); | ||
} | ||
isEmpty(): boolean { | ||
@@ -242,6 +787,47 @@ return false; | ||
tail(): Stream<T> { | ||
return this._tail(); | ||
tail(): Option<Stream<T>> { | ||
return Option.ofStruct(this._tail()); | ||
} | ||
last(): Option<T> { | ||
let curItem: Stream<T> = this; | ||
while (true) { | ||
const item = (<ConsStream<T>>curItem).value; | ||
curItem = (<ConsStream<T>>curItem)._tail(); | ||
if (curItem.isEmpty()) { | ||
return Option.ofStruct(item); | ||
} | ||
} | ||
} | ||
get(idx: number): Option<T> { | ||
let curItem: Stream<T> = this; | ||
let i=0; | ||
while (!curItem.isEmpty()) { | ||
if (i === idx) { | ||
const item = (<ConsStream<T>>curItem).value; | ||
return Option.ofStruct(item); | ||
} | ||
curItem = (<ConsStream<T>>curItem)._tail(); | ||
++i; | ||
} | ||
return Option.none<T>(); | ||
} | ||
find(predicate:(v:T)=>boolean): Option<T> { | ||
let curItem: Stream<T> = this; | ||
while (!curItem.isEmpty()) { | ||
const item = (<ConsStream<T>>curItem).value; | ||
if (predicate(item)) { | ||
return Option.ofStruct(item); | ||
} | ||
curItem = (<ConsStream<T>>curItem)._tail(); | ||
} | ||
return Option.none<T>(); | ||
} | ||
contains(v:T&WithEquality): boolean { | ||
return this.find(x => areEqual(x,v)).isSome(); | ||
} | ||
take(n: number): Stream<T> { | ||
@@ -252,3 +838,3 @@ if (n < 1) { | ||
return new ConsStream(this.value, | ||
() => this.tail().take(n-1)); | ||
() => this._tail().take(n-1)); | ||
} | ||
@@ -261,8 +847,115 @@ | ||
return new ConsStream(this.value, | ||
() => this.tail().takeWhile(predicate)); | ||
() => this._tail().takeWhile(predicate)); | ||
} | ||
drop(n:number): Stream<T> { | ||
let i = n; | ||
let curItem: Stream<T> = this; | ||
while (i-- > 0 && !curItem.isEmpty()) { | ||
curItem = (<ConsStream<T>>curItem)._tail(); | ||
} | ||
return curItem; | ||
} | ||
dropWhile(predicate:(x:T)=>boolean): Stream<T> { | ||
let curItem: Stream<T> = this; | ||
while (!curItem.isEmpty() && predicate((<ConsStream<T>>curItem).value)) { | ||
curItem = (<ConsStream<T>>curItem)._tail(); | ||
} | ||
return curItem; | ||
} | ||
dropRight(n:number): Stream<T> { | ||
// going twice through the list... | ||
const length = this.length(); | ||
return this.take(length-n); | ||
} | ||
foldLeft<U>(zero: U, fn:(soFar:U,cur:T)=>U): U { | ||
let r = zero; | ||
let curItem: Stream<T> = this; | ||
while (!curItem.isEmpty()) { | ||
r = fn(r, (<ConsStream<T>>curItem).value); | ||
curItem = (<ConsStream<T>>curItem)._tail(); | ||
} | ||
return r; | ||
} | ||
foldRight<U>(zero: U, fn:(cur:T, soFar:U)=>U): U { | ||
return this.reverse().foldLeft(zero, (xs,x)=>fn(x,xs)); | ||
} | ||
zipStruct<U>(other: Iterable<U>): Stream<[T,U]> { | ||
const otherIterator = other[Symbol.iterator](); | ||
let otherCurItem = otherIterator.next(); | ||
if (this.isEmpty() || otherCurItem.done) { | ||
return <Stream<[T,U]>>emptyStream; | ||
} | ||
return new ConsStream([(<ConsStream<T>>this).value, otherCurItem.value] as [T,U], | ||
() => (<ConsStream<T>>this)._tail().zipStruct( | ||
{ [Symbol.iterator]: ()=>otherIterator})); | ||
} | ||
reverse(): Stream<T> { | ||
return this.foldLeft(<Stream<T>><EmptyStream<T>>emptyStream, (xs,x) => xs.prependStruct(x)); | ||
} | ||
partition(predicate:(x:T)=>boolean): [Stream<T>,Stream<T>] { | ||
// TODO goes twice over the list, can be optimized... | ||
return [this.filter(predicate), this.filter(x => !predicate(x))]; | ||
} | ||
groupBy<C>(classifier: (v:T & WithEquality)=>C & WithEquality): HashMap<C,Stream<T>> { | ||
return this.foldLeft( | ||
HashMap.empty<C,Stream<T>>(), | ||
(acc: HashMap<C,Stream<T>>, v:T & WithEquality) => | ||
acc.putWithMerge( | ||
classifier(v), Stream.of(v), | ||
(v1:Stream<T&WithEquality>,v2:Stream<T&WithEquality>)=>v1.appendStream(v2))); | ||
} | ||
appendStruct(v:T): Stream<T> { | ||
const tail = this._tail(); | ||
return new ConsStream( | ||
this.value, | ||
() => tail.appendStruct(v)); | ||
} | ||
appendAllStruct(elts:Iterable<T>): Stream<T> { | ||
return this.appendStreamStruct(Stream.ofIterableStruct(elts)); | ||
} | ||
appendStreamStruct(elts:Stream<T>): Stream<T> { | ||
const tail = this._tail(); | ||
return new ConsStream( | ||
this.value, | ||
() => tail.appendStreamStruct(elts)); | ||
} | ||
prependStruct(elt: T): Stream<T> { | ||
return new ConsStream( | ||
elt, | ||
() => this); | ||
} | ||
prependAllStruct(elts: Iterable<T>): Stream<T> { | ||
return Stream.ofIterableStruct(elts).appendAllStruct(this); | ||
} | ||
cycle(): Stream<T> { | ||
return this._cycle(this); | ||
} | ||
private _cycle(toRepeat: Stream<T>): Stream<T> { | ||
const tail = this._tail(); | ||
return new ConsStream( | ||
this.value, | ||
() => tail.isEmpty() ? toRepeat.cycle() : (<ConsStream<T>>tail)._cycle(toRepeat)); | ||
} | ||
mapStruct<U>(mapper:(v:T)=>U): Stream<U> { | ||
return new ConsStream(mapper(this.value), | ||
() => this.tail().mapStruct(mapper)); | ||
() => this._tail().mapStruct(mapper)); | ||
} | ||
@@ -274,11 +967,68 @@ | ||
flatMapStruct<U>(mapper:(v:T)=>Stream<U>): Stream<U> { | ||
return mapper(this.value).appendStream( | ||
this._tail().flatMapStruct(mapper)); | ||
} | ||
flatMap<U>(mapper:(v:T)=>Stream<U&WithEquality>): Stream<U> { | ||
return this.flatMapStruct(mapper); | ||
} | ||
allMatch(predicate:(v:T)=>boolean): boolean { | ||
return this.find(x => !predicate(x)).isNone(); | ||
} | ||
anyMatch(predicate:(v:T)=>boolean): boolean { | ||
return this.find(predicate).isSome(); | ||
} | ||
filter(predicate:(v:T)=>boolean): Stream<T> { | ||
return predicate(this.value) ? | ||
new ConsStream(this.value, | ||
() => this.tail().filter(predicate)) : | ||
this.tail().filter(predicate); | ||
() => this._tail().filter(predicate)) : | ||
this._tail().filter(predicate); | ||
} | ||
sortBy(compare: (v1:T,v2:T)=>Ordering): Stream<T> { | ||
return Stream.ofIterableStruct<T>(this.toArray().sort(compare)); | ||
} | ||
distinctBy<U>(keyExtractor: (x:T)=>U&WithEquality): Stream<T> { | ||
let knownKeys = HashSet.empty<U>(); | ||
return this.filter(x => { | ||
const key = keyExtractor(x); | ||
const r = knownKeys.contains(key); | ||
if (!r) { | ||
knownKeys = knownKeys.add(key); | ||
} | ||
return !r; | ||
}); | ||
} | ||
forEach(fn: (v:T)=>void): Stream<T> { | ||
let curItem: Stream<T> = this; | ||
while (!curItem.isEmpty()) { | ||
fn((<ConsStream<T>>curItem).value); | ||
curItem = (<ConsStream<T>>curItem)._tail(); | ||
} | ||
return this; | ||
} | ||
mkString(separator: string): string { | ||
let r = ""; | ||
let curItem: Stream<T> = this; | ||
let isNotFirst = false; | ||
while (!curItem.isEmpty()) { | ||
if (isNotFirst) { | ||
r += separator; | ||
} | ||
r += (<ConsStream<T>>curItem).value.toString(); | ||
curItem = (<ConsStream<T>>curItem)._tail(); | ||
isNotFirst = true; | ||
} | ||
return r; | ||
} | ||
toArray(): T[] { | ||
const r = this.tail().toArray(); | ||
const r = this._tail().toArray(); | ||
r.unshift(this.value); | ||
@@ -291,4 +1041,73 @@ return r; | ||
} | ||
toMap<K,V>(converter:(x:T)=>[K & WithEquality,V & WithEquality]): IMap<K,V> { | ||
return this.toMapStruct(converter); | ||
} | ||
toMapStruct<K,V>(converter:(x:T)=>[K & WithEquality,V]): IMap<K,V> { | ||
return this.foldLeft(HashMap.empty<K,V>(), (acc,cur) => { | ||
const converted = converter(cur); | ||
return acc.putStruct(converted[0], converted[1]); | ||
}); | ||
} | ||
equals(other: Stream<T>): boolean { | ||
if (!other || !other.tail) { | ||
return false; | ||
} | ||
let myVal: Stream<T> = this; | ||
let hisVal = other; | ||
while (true) { | ||
if (myVal.isEmpty() !== hisVal.isEmpty()) { | ||
return false; | ||
} | ||
if (myVal.isEmpty()) { | ||
// they are both empty, end of the stream | ||
return true; | ||
} | ||
const myHead = (<ConsStream<T>>myVal).value; | ||
const hisHead = (<ConsStream<T>>hisVal).value; | ||
if ((myHead === undefined) !== (hisHead === undefined)) { | ||
return false; | ||
} | ||
if (myHead === undefined || hisHead === undefined) { | ||
// they are both undefined, the || is for TS's flow analysis | ||
// so he realizes none of them is undefined after this. | ||
continue; | ||
} | ||
if (!areEqual(myHead, hisHead)) { | ||
return false; | ||
} | ||
myVal = (<ConsStream<T>>myVal)._tail(); | ||
hisVal = (<ConsStream<T>>hisVal)._tail(); | ||
} | ||
} | ||
hashCode(): number { | ||
let hash = 1; | ||
let curItem: Stream<T> = this; | ||
while (!curItem.isEmpty()) { | ||
hash = 31 * hash + getHashCode((<ConsStream<T>>curItem).value); | ||
curItem = (<ConsStream<T>>curItem)._tail(); | ||
} | ||
return hash; | ||
} | ||
toString(): string { | ||
let curItem: Stream<T> = this; | ||
let result = "["; | ||
while (!curItem.isEmpty()) { | ||
result += toStringHelper((<ConsStream<T>>curItem).value); | ||
curItem = (<ConsStream<T>>curItem)._tail(); | ||
if (!curItem.isEmpty()) { | ||
result += ", "; | ||
} | ||
} | ||
return result + "]"; | ||
} | ||
} | ||
const emptyStream = new EmptyStream(); |
import { Value } from "./Value"; | ||
import { WithEquality, areEqual, getHashCode } from "./Comparison"; | ||
import { WithEquality, areEqual, | ||
getHashCode, toStringHelper } from "./Comparison"; | ||
@@ -127,4 +128,8 @@ /** | ||
toString(): string { | ||
return `Tuple2(${this._fst}, ${this._snd})`; | ||
return `Tuple2(${toStringHelper(this._fst)}, ${toStringHelper(this._snd)})`; | ||
} | ||
inspect(): string { | ||
return this.toString(); | ||
} | ||
} |
@@ -21,2 +21,8 @@ export interface Value { | ||
toString(): string; | ||
/** | ||
* Used by the node REPL to display values. | ||
* Most of the time should be the same as toString() | ||
*/ | ||
inspect(): string; | ||
} |
import { Seq } from "./Seq"; | ||
import { WithEquality, Ordering, | ||
getHashCode, areEqual } from "./Comparison"; | ||
getHashCode, areEqual, toStringHelper } from "./Comparison"; | ||
import { HashMap} from "./HashMap"; | ||
@@ -97,5 +97,5 @@ import { IMap } from "./IMap"; | ||
/** | ||
* Get the size (length) of the collection. | ||
* Get the length of the collection. | ||
*/ | ||
size(): number { | ||
length(): number { | ||
return this.hamt.size; | ||
@@ -131,6 +131,9 @@ } | ||
* Get all the elements in the collection but the first one. | ||
* If the collection is empty, return an empty collection. | ||
* If the collection is empty, return None. | ||
*/ | ||
tail(): Vector<T> { | ||
return new Vector<T>(this.hamt.remove(this.indexShift), this.indexShift+1); | ||
tail(): Option<Vector<T>> { | ||
return this.isEmpty() ? | ||
Option.none<Vector<T>>() : | ||
Option.of(new Vector<T>( | ||
this.hamt.remove(this.indexShift), this.indexShift+1)); | ||
} | ||
@@ -209,6 +212,7 @@ | ||
*/ | ||
forEach(fn: (v:T)=>void): void { | ||
forEach(fn: (v:T)=>void): Vector<T> { | ||
for (let i=0;i<this.hamt.size;i++) { | ||
fn(this.hamt.get(i+this.indexShift)); | ||
} | ||
return this; | ||
} | ||
@@ -287,5 +291,5 @@ | ||
for (let i=0;i<this.hamt.size;i++) { | ||
const item = this.hamt.get(i+this.indexShift); | ||
const item: T = this.hamt.get(i+this.indexShift); | ||
if (predicate(item)) { | ||
return Option.of(item); | ||
return Option.ofStruct(item); | ||
} | ||
@@ -295,2 +299,10 @@ } | ||
} | ||
/** | ||
* Returns true if the item is in the collection, | ||
* false otherwise. | ||
*/ | ||
contains(v:T&WithEquality): boolean { | ||
return this.anyMatch(curVal => areEqual(curVal, v)); | ||
} | ||
@@ -466,2 +478,38 @@ /** | ||
/** | ||
* Returns true if the predicate returns true for all the | ||
* elements in the collection. | ||
*/ | ||
allMatch(predicate:(v:T)=>boolean): boolean { | ||
// faster than using .find() because we | ||
// don't have to traverse elements in order | ||
const iterator: Iterator<T> = this.hamt.values(); | ||
let curItem = iterator.next(); | ||
while (!curItem.done) { | ||
if (!predicate(curItem.value)) { | ||
return false; | ||
} | ||
curItem = iterator.next(); | ||
} | ||
return true; | ||
} | ||
/** | ||
* Returns true if there the predicate returns true for any | ||
* element in the collection. | ||
*/ | ||
anyMatch(predicate:(v:T)=>boolean): boolean { | ||
// faster than using .find() because we | ||
// don't have to traverse elements in order | ||
const iterator: Iterator<T> = this.hamt.values(); | ||
let curItem = iterator.next(); | ||
while (!curItem.done) { | ||
if (predicate(curItem.value)) { | ||
return true; | ||
} | ||
curItem = iterator.next(); | ||
} | ||
return false; | ||
} | ||
/** | ||
* Returns a new collection with elements | ||
@@ -521,3 +569,3 @@ * sorted according to the comparator you give. | ||
* | ||
* Vector.of(1,2,3).zip("a","b","c") | ||
* Vector.of(1,2,3).zip(["a","b","c"]) | ||
* => Vector.of([1,"a"], [2,"b"], [3,"c"]) | ||
@@ -682,6 +730,14 @@ * | ||
} | ||
r += "" + this.hamt.get(i+this.indexShift); | ||
r += toStringHelper(this.hamt.get(i+this.indexShift)); | ||
} | ||
return r + "]"; | ||
} | ||
/** | ||
* Used by the node REPL to display values. | ||
* Most of the time should be the same as toString() | ||
*/ | ||
inspect(): string { | ||
return this.toString(); | ||
} | ||
} |
@@ -18,2 +18,6 @@ import { HashSet } from "../src/HashSet"; | ||
.add(new MyClass("a", 2))))); | ||
it("should support addAll on a non-empty set", () => assert.ok( | ||
HashSet.of(1,2,3,4).equals(HashSet.of(1,2).addAll([3,4])))); | ||
it("should support addAll on an empty set", () => assert.ok( | ||
HashSet.of(1,2,3,4).equals(HashSet.empty<number>().addAll([1,2,3,4])))); | ||
}); | ||
@@ -26,2 +30,5 @@ | ||
}); | ||
it("empty should convert to array correctly", () => { | ||
assert.deepEqual([], HashSet.empty<number>().toArray()); | ||
}); | ||
it("should be created correctly from an array", () => { | ||
@@ -34,3 +41,3 @@ assert.deepEqual(["a","b","c"], HashSet.ofIterable(["a","b","c"]).toArray().sort()); | ||
it("should be displayed in a nice format by toString", () => | ||
assert.equal("{a, b, c}", HashSet.of("a","b","c").toString())); | ||
assert.equal("{'a', 'b', 'c'}", HashSet.of("a","b","c").toString())); | ||
}); | ||
@@ -64,2 +71,14 @@ | ||
}) | ||
it("supports allMatch, positive case", () => assert.ok( | ||
HashSet.of(2,4,8).allMatch(x => x%2 === 0))); | ||
it("supports allMatch, negative case", () => assert.ok( | ||
!HashSet.of(2,5,8).allMatch(x => x%2 === 0))); | ||
it("supports allMatch, empty HashSet", () => assert.ok( | ||
HashSet.empty<number>().allMatch(x => x%2 === 0))); | ||
it("supports anyMatch, positive case", () => assert.ok( | ||
HashSet.of(3,5,8).anyMatch(x => x%2 === 0))); | ||
it("supports anyMatch, negative case", () => assert.ok( | ||
!HashSet.of(3,5,9).anyMatch(x => x%2 === 0))); | ||
it("supports anyMatch, empty HashSet", () => assert.ok( | ||
!HashSet.empty<number>().anyMatch(x => x%2 === 0))); | ||
}); | ||
@@ -83,2 +102,7 @@ | ||
HashSet.empty<number>().equals(HashSet.empty<number>().removeAll([0,3])))); | ||
}) | ||
}); | ||
describe("hashset transformations", () => { | ||
it("map works", () => assert.ok( | ||
HashSet.of(5,6,7).equals(HashSet.of(1,2,3).map(x=>x+4)))); | ||
}); |
@@ -84,2 +84,8 @@ import { Option } from "../src/Option"; | ||
assert.deepEqual([], Option.none().toVector().toArray())); | ||
it("should not throw on Some.getOrThrow", () => | ||
assert.equal(5, Option.of(5).getOrThrow())); | ||
it("should throw on None.getOrThrow", () => | ||
assert.throws(() => Option.none().getOrThrow())); | ||
it("should throw on None.getOrThrow with custom msg", () => | ||
assert.throws(() => Option.none().getOrThrow("my custom msg"), /^my custom msg$/)); | ||
}); |
import { Stream } from "../src/Stream"; | ||
import { Vector } from "../src/Vector"; | ||
import { Option } from "../src/Option"; | ||
import { MyClass} from "./SampleData"; | ||
import { HashMap} from "../src/HashMap"; | ||
import * as assert from 'assert' | ||
@@ -20,10 +23,166 @@ | ||
}); | ||
it("converts to vector", () => assert.ok( | ||
Vector.of(1,2,3).equals(Stream.iterate(1, x => x+1).take(3).toVector()))); | ||
it("maps correctly", () => assert.deepEqual( | ||
[4,5,7,11], Stream.iterate(1, x => x*2).map(x => x+3).take(4).toArray())); | ||
it("supports ofArray", () => assert.deepEqual( | ||
[1,2,3], Stream.ofIterable([1,2,3]).toArray())); | ||
it("supports of", () => assert.deepEqual( | ||
[1,2,3], Stream.of(1,2,3).toArray())); | ||
it("supports append", () => assert.deepEqual( | ||
[1,2,3,4], Stream.of(1,2,3).append(4).toArray())); | ||
it("supports appendAll", () => assert.deepEqual( | ||
[1,2,3,4,5], Stream.of(1,2,3).appendAll([4,5]).toArray())); | ||
it("supports cycle", () => assert.deepEqual( | ||
[1,2,3,1,2,3,1,2], Stream.of(1,2,3).cycle().take(8).toArray())); | ||
it("supports appendStream", () => assert.deepEqual( | ||
[1,2,3,4,5,6], Stream.of(1,2,3).appendStream(Stream.of(4,5,6)).toArray())); | ||
it("supports flatMap", () => assert.deepEqual( | ||
[1,2,3,4,5,6], Stream.of(1,4).flatMap(x => Stream.of(x,x+1,x+2)).toArray())); | ||
it("correctly reverses", () => assert.deepEqual( | ||
[3,2,1], Stream.of(1,2,3).reverse().toArray())); | ||
it("correctly reverses the empty stream", () => assert.deepEqual( | ||
[], Stream.empty().reverse().toArray())); | ||
it("correctly reverses also after prepend", () => assert.deepEqual( | ||
[3,2,1], Stream.of(2,3).prepend(1).reverse().toArray())); | ||
it("computes the length correctly", () => assert.equal( | ||
3, Stream.of(1,2,3).length())); | ||
it("computes the length of the empty stream correctly", () => assert.equal( | ||
0, Stream.empty().length())); | ||
it("gets the last value correctly", () => assert.equal( | ||
3, Stream.of(1,2,3).last().getOrThrow())); | ||
it("gets the last value correctly for an empty stream", () => assert.ok( | ||
Stream.empty().last().isNone())); | ||
it("sorting works", () => assert.ok( | ||
Stream.of(4,3,2,1) | ||
.equals(Stream.of(1,2,3,4).sortBy((x,y) => y-x)))); | ||
it("correctly drops right n items", () => assert.deepEqual( | ||
[1,2,3,4], Stream.of(1,2,3,4,5,6).dropRight(2).toArray())); | ||
it("returns an empty stream when dropping right too much", () => assert.deepEqual( | ||
[], Stream.of(1,2).dropRight(3).toArray())); | ||
}); | ||
describe("Prepend", () => { | ||
const basic = Stream.of(1,2,3,4); | ||
const prepended = Stream.of(2,3,4).prepend(1); | ||
it("prepends correctly", () => assert.ok(basic.equals(prepended))); | ||
it("converts to array correctly", () => assert.deepEqual( | ||
basic.toArray(), prepended.toArray())); | ||
it("appends correctly after prepend", () => assert.ok( | ||
basic.append(5).equals(prepended.append(5)))); | ||
it("appendsAll correctly after prepend", () => assert.ok( | ||
basic.appendStream(Stream.of(5,6)).equals(prepended.appendStream(Stream.of(5,6))))); | ||
it("converts to string correctly after prepend", () => assert.equal( | ||
basic.toString(), prepended.toString())); | ||
it("prependsAll correctly", () => assert.deepEqual( | ||
[1,2,3,4,5], Stream.of(4,5).prependAll(Stream.of(1,2,3)).toArray())); | ||
}); | ||
describe("Stream iteration", () => { | ||
it("finds items", () => | ||
Stream.of(1,2,3).find(x => x >= 2).contains(2)); | ||
it("doesn't find if the predicate doesn't match", () => | ||
Stream.of(1,2,3).find(x => x >= 4).isNone()); | ||
it("foldsLeft correctly", () => assert.equal( | ||
"cba!", | ||
Stream.of("a", "b", "c").foldLeft("!", (xs,x) => x+xs))); | ||
it("foldsRight correctly", () => assert.equal( | ||
"!cba", | ||
Stream.of("a", "b", "c").foldRight("!", (x,xs) => xs+x))); | ||
it("calls forEach correctly", () => { | ||
let ar: number[] = []; | ||
Stream.of(1,2,3).forEach((v:number) => ar.push(v)); | ||
assert.deepEqual([1,2,3], ar); | ||
}); | ||
it("get finds when present", () => assert.ok( | ||
Option.of(5).equals(Stream.of(1,2,3,4,5,6).get(4)))); | ||
it("get finds when present after prepend", () => assert.ok( | ||
Option.of(5).equals(Stream.of(2,3,4,5,6).prepend(1).get(4)))); | ||
it("get doesn't find when stream too short", () => assert.ok( | ||
Option.none().equals(Stream.of(1,2,3).get(4)))); | ||
it("get doesn't find when negative index", () => assert.ok( | ||
Option.none().equals(Stream.of(1,2,3).get(-1)))); | ||
it("zips with an array", () => assert.deepEqual( | ||
[[1,"a"], [2,"b"]], Stream.of(1,2,3).zip(["a","b"]).toArray())); | ||
it("zips with a stream", () => assert.deepEqual( | ||
[["a",0], ["b",1]], Stream.of("a","b").zip(Stream.iterate(0,x=>x+1)).toArray())); | ||
it("richer example", () => assert.deepEqual( | ||
[[1,"a"],[2,"b"]], Stream.of(1,2,3) | ||
.zip(Vector.of("a", "b", "c")).takeWhile(([k,v]) => k<3).toArray())); | ||
}); | ||
describe("Stream filtering", () => { | ||
it("implements takeWhile correctly", () => assert.deepEqual( | ||
[1,2,3], Stream.iterate(1, x=>x+1).takeWhile(x=>x<4).toArray())); | ||
it("maps correctly", () => assert.deepEqual( | ||
[4,5,7,11], Stream.iterate(1, x => x*2).map(x => x+3).take(4).toArray())); | ||
it("filters correctly", () => assert.deepEqual( | ||
[8,32,64,128], Stream.iterate(1, x => x*2).filter(x => x>5 && (x<15 || x > 30)).take(4).toArray())); | ||
it("correctly dropsWhile", () => assert.deepEqual( | ||
[4,5,6], Stream.of(1,2,3,4,5,6).dropWhile(x=>x<4).toArray())); | ||
it("correctly drops n items", () => assert.deepEqual( | ||
[4,5,6], Stream.of(1,2,3,4,5,6).drop(3).toArray())); | ||
it("returns an empty stream when dropping too much", () => assert.deepEqual( | ||
[], Stream.of(1,2).drop(3).toArray())); | ||
it("distinctBy", () => assert.deepEqual( | ||
[1,2,3], Stream.of(1,1,2,3,2,3,1).distinctBy(x => x).toArray())); | ||
it("distinctBy for the empty stream", () => assert.deepEqual( | ||
[], Stream.empty<number>().distinctBy(x => x).toArray())); | ||
it("distinctBy for a single value", () => assert.deepEqual( | ||
[1], Stream.of(1).distinctBy(x => x).toArray())); | ||
it("distinctBy, custom equality", () => assert.deepEqual( | ||
[1,0,2], Stream.of(1,0,1,2,3,2,3,1).distinctBy(x => new MyClass("hi", x%3)).toArray())); | ||
it("distinctBy with prepend", () => assert.deepEqual( | ||
[1,2,3], Stream.of(2,3,2,3,1).prepend(1).distinctBy(x => x).toArray())); | ||
it("correctly partitions also after prepend", () => assert.deepEqual( | ||
[[1,3,5,7],[2,4,6,8]], | ||
Stream.of(2,3,4,5,6,7,8).prepend(1).partition(x => x%2!==0) | ||
.map(v => v.toArray()))); | ||
it("groupBy works", () => assert.ok( | ||
HashMap.empty().put(0, Stream.of(2,4)).put(1, Stream.of(1,3)) | ||
.equals(Stream.of(1,2,3,4).groupBy(x => x%2)))); | ||
it("supports contain", () => assert.ok( | ||
Stream.of(1,2,3).contains(2))); | ||
it("rejects contain", () => assert.ok( | ||
!Stream.of(1,2,3).contains(4))); | ||
it("rejects contain, empty stream", () => assert.ok( | ||
!Stream.empty().contains(4))); | ||
it("supports contains, custom equality", () => assert.ok( | ||
Stream.of(new MyClass("hi", 3)).contains(new MyClass("hi", 3)))); | ||
it("supports allMatch, positive case", () => assert.ok( | ||
Stream.of(2,4,8).allMatch(x => x%2 === 0))); | ||
it("supports allMatch, negative case", () => assert.ok( | ||
!Stream.of(2,5,8).allMatch(x => x%2 === 0))); | ||
it("supports allMatch, empty stream", () => assert.ok( | ||
Stream.empty<number>().allMatch(x => x%2 === 0))); | ||
it("supports anyMatch, positive case", () => assert.ok( | ||
Stream.of(3,5,8).anyMatch(x => x%2 === 0))); | ||
it("supports anyMatch, negative case", () => assert.ok( | ||
!Stream.of(3,5,9).anyMatch(x => x%2 === 0))); | ||
it("supports anyMatch, empty stream", () => assert.ok( | ||
!Stream.empty<number>().anyMatch(x => x%2 === 0))); | ||
}); | ||
describe("Stream Value tests", () => { | ||
it("serializes to string correctly", () => assert.equal( | ||
"[1, 2, 3]", Stream.of(1,2,3).toString())); | ||
it("serializes to string correctly - arrays & strings", () => assert.equal( | ||
"[[1,'a']]", Stream.ofStruct([1,'a']).toString())); | ||
it("serializes to string correctly - custom toString", () => assert.equal( | ||
"[{field1: hi, field2: 99}]", Stream.of(new MyClass("hi", 99)).toString())); | ||
it("has non-obviously-broken equals", () => assert.ok( | ||
Stream.of("a","b","c").equals(Stream.of("a", "b", "c")))); | ||
it("doesn't throw when given another type on equals", () => assert.equal( | ||
false, Stream.of(1).equals(<any>[1,2]))); | ||
it("doesn't throw when given null on equals", () => assert.equal( | ||
false, Stream.of(1).equals(<any>null))); | ||
it("is strict with equality", () => assert.ok( | ||
!Stream.of(1,2).equals(Stream.of(1, <any>undefined)))); | ||
}); | ||
describe("Stream conversions", () => { | ||
it("converts to vector", () => assert.ok( | ||
Vector.of(1,2,3).equals(Stream.iterate(1, x => x+1).take(3).toVector()))); | ||
it("mkString works", () => assert.equal( | ||
"1, 2, 3", Stream.of(1,2,3).mkString(", "))); | ||
it("transforms to map", () => { | ||
assert.ok(HashMap.empty<number,string>().put(1,"ok").put(2, "bad") | ||
.equals(<HashMap<number,string>>Stream.ofStruct<[number,string]>([1,"ok"],[2,"bad"]).toMap(x => x))); | ||
}); | ||
}); |
@@ -63,2 +63,6 @@ import { Vector } from "../src/Vector"; | ||
[1,2,3], Vector.of(2,3,2,3,1).prepend(1).distinctBy(x => x).toArray())); | ||
it("computes the length correctly", () => assert.equal( | ||
3, Vector.of(1,2,3).length())); | ||
it("computes the length of the empty vector correctly", () => assert.equal( | ||
0, Vector.empty().length())); | ||
}); | ||
@@ -96,7 +100,7 @@ | ||
it("correctly gets the tail of the empty vector", () => assert.ok( | ||
Vector.empty().equals(Vector.empty().tail()))); | ||
Vector.empty().tail().isNone())); | ||
it("correctly gets the tail of a simple vector", () => assert.ok( | ||
Vector.of(2,3,4).equals(Vector.of(1,2,3,4).tail()))); | ||
Vector.of(2,3,4).equals(Vector.of(1,2,3,4).tail().getOrThrow()))); | ||
it("correctly gets the tail of a vector after prepend", () => assert.ok( | ||
Vector.of(2,3,4).equals(Vector.of(2,3,4).prepend(1).tail()))); | ||
Vector.of(2,3,4).equals(Vector.of(2,3,4).prepend(1).tail().getOrThrow()))); | ||
it("correctly reverses", () => assert.deepEqual( | ||
@@ -176,2 +180,6 @@ [3,2,1], Vector.of(1,2,3).reverse().toArray())); | ||
"[1, 2, 3]", Vector.of(1,2,3).toString())); | ||
it("serializes to string correctly - arrays & strings", () => assert.equal( | ||
"[[1,'a']]", Vector.ofStruct([1,'a']).toString())); | ||
it("serializes to string correctly - custom toString", () => assert.equal( | ||
"[{field1: hi, field2: 99}]", Vector.of(new MyClass("hi", 99)).toString())); | ||
it("has non-obviously-broken equals", () => assert.ok( | ||
@@ -185,2 +193,22 @@ Vector.of("a","b","c").equals(Vector.of("a", "b", "c")))); | ||
!Vector.of(1,2).equals(Vector.of(1, <any>undefined)))); | ||
it("supports contain", () => assert.ok( | ||
Vector.of(1,2,3).contains(2))); | ||
it("rejects contain", () => assert.ok( | ||
!Vector.of(1,2,3).contains(4))); | ||
it("rejects contain, empty vector", () => assert.ok( | ||
!Vector.empty().contains(4))); | ||
it("supports contains, custom equality", () => assert.ok( | ||
Vector.of(new MyClass("hi", 3)).contains(new MyClass("hi", 3)))); | ||
it("supports allMatch, positive case", () => assert.ok( | ||
Vector.of(2,4,8).allMatch(x => x%2 === 0))); | ||
it("supports allMatch, negative case", () => assert.ok( | ||
!Vector.of(2,5,8).allMatch(x => x%2 === 0))); | ||
it("supports allMatch, empty vector", () => assert.ok( | ||
Vector.empty<number>().allMatch(x => x%2 === 0))); | ||
it("supports anyMatch, positive case", () => assert.ok( | ||
Vector.of(3,5,8).anyMatch(x => x%2 === 0))); | ||
it("supports anyMatch, negative case", () => assert.ok( | ||
!Vector.of(3,5,9).anyMatch(x => x%2 === 0))); | ||
it("supports anyMatch, empty vector", () => assert.ok( | ||
!Vector.empty<number>().anyMatch(x => x%2 === 0))); | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1688024
10697