Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

value-object

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

value-object - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

test/deserializeTest.js

2

coverage/coverage.raw.json

@@ -1,1 +0,1 @@

{"/Users/joshchisholm/projects/value-object.js/src/index.js":{"path":"/Users/joshchisholm/projects/value-object.js/src/index.js","statementMap":{"0":{"start":{"line":3,"column":25},"end":{"line":3,"column":54}},"1":{"start":{"line":4,"column":15},"end":{"line":4,"column":34}},"2":{"start":{"line":5,"column":20},"end":{"line":5,"column":44}},"3":{"start":{"line":7,"column":0},"end":{"line":11,"column":1}}},"fnMap":{},"branchMap":{},"s":{"0":1,"1":1,"2":1,"3":1},"f":{},"b":{},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"beabec9418c216982287df4a4028fde1a7dbedfa"},"/Users/joshchisholm/projects/value-object.js/src/buildDeserialize.js":{"path":"/Users/joshchisholm/projects/value-object.js/src/buildDeserialize.js","statementMap":{"0":{"start":{"line":9,"column":0},"end":{"line":31,"column":1}},"1":{"start":{"line":10,"column":23},"end":{"line":15,"column":8}},"2":{"start":{"line":11,"column":4},"end":{"line":12,"column":61}},"3":{"start":{"line":12,"column":6},"end":{"line":12,"column":61}},"4":{"start":{"line":14,"column":4},"end":{"line":14,"column":42}},"5":{"start":{"line":17,"column":2},"end":{"line":17,"column":43}},"6":{"start":{"line":17,"column":19},"end":{"line":17,"column":43}},"7":{"start":{"line":20,"column":4},"end":{"line":20,"column":47}},"8":{"start":{"line":20,"column":35},"end":{"line":20,"column":47}},"9":{"start":{"line":22,"column":24},"end":{"line":22,"column":52}},"10":{"start":{"line":24,"column":4},"end":{"line":25,"column":154}},"11":{"start":{"line":25,"column":6},"end":{"line":25,"column":154}},"12":{"start":{"line":26,"column":4},"end":{"line":27,"column":144}},"13":{"start":{"line":27,"column":6},"end":{"line":27,"column":144}},"14":{"start":{"line":29,"column":4},"end":{"line":29,"column":38}}},"fnMap":{"0":{"name":"buildDeserialize","decl":{"start":{"line":9,"column":26},"end":{"line":9,"column":42}},"loc":{"start":{"line":9,"column":55},"end":{"line":31,"column":1}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":10,"column":41},"end":{"line":10,"column":42}},"loc":{"start":{"line":10,"column":63},"end":{"line":15,"column":3}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":17,"column":9},"end":{"line":17,"column":10}},"loc":{"start":{"line":17,"column":19},"end":{"line":17,"column":43}}},"3":{"name":"revive","decl":{"start":{"line":19,"column":11},"end":{"line":19,"column":17}},"loc":{"start":{"line":19,"column":30},"end":{"line":30,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":4},"end":{"line":12,"column":61}},"type":"if","locations":[{"start":{"line":11,"column":4},"end":{"line":12,"column":61}},{"start":{"line":11,"column":4},"end":{"line":12,"column":61}}]},"1":{"loc":{"start":{"line":20,"column":4},"end":{"line":20,"column":47}},"type":"if","locations":[{"start":{"line":20,"column":4},"end":{"line":20,"column":47}},{"start":{"line":20,"column":4},"end":{"line":20,"column":47}}]},"2":{"loc":{"start":{"line":20,"column":8},"end":{"line":20,"column":33}},"type":"binary-expr","locations":[{"start":{"line":20,"column":8},"end":{"line":20,"column":14}},{"start":{"line":20,"column":18},"end":{"line":20,"column":33}}]},"3":{"loc":{"start":{"line":24,"column":4},"end":{"line":25,"column":154}},"type":"if","locations":[{"start":{"line":24,"column":4},"end":{"line":25,"column":154}},{"start":{"line":24,"column":4},"end":{"line":25,"column":154}}]},"4":{"loc":{"start":{"line":26,"column":4},"end":{"line":27,"column":144}},"type":"if","locations":[{"start":{"line":26,"column":4},"end":{"line":27,"column":144}},{"start":{"line":26,"column":4},"end":{"line":27,"column":144}}]}},"s":{"0":1,"1":7,"2":7,"3":1,"4":6,"5":6,"6":6,"7":20,"8":13,"9":7,"10":7,"11":1,"12":6,"13":1,"14":5},"f":{"0":7,"1":7,"2":6,"3":20},"b":{"0":[1,6],"1":[13,7],"2":[20,20],"3":[1,6],"4":[1,5]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"0a7224842276d5a4197ee0539aa080a65a1acd60"},"/Users/joshchisholm/projects/value-object.js/src/scalar.js":{"path":"/Users/joshchisholm/projects/value-object.js/src/scalar.js","statementMap":{"0":{"start":{"line":1,"column":20},"end":{"line":1,"column":44}},"1":{"start":{"line":10,"column":4},"end":{"line":13,"column":18}},"2":{"start":{"line":11,"column":6},"end":{"line":11,"column":22}},"3":{"start":{"line":13,"column":6},"end":{"line":13,"column":18}},"4":{"start":{"line":17,"column":4},"end":{"line":17,"column":21}},"5":{"start":{"line":21,"column":4},"end":{"line":24,"column":66}},"6":{"start":{"line":22,"column":6},"end":{"line":22,"column":93}},"7":{"start":{"line":24,"column":6},"end":{"line":24,"column":66}},"8":{"start":{"line":28,"column":4},"end":{"line":28,"column":32}},"9":{"start":{"line":32,"column":4},"end":{"line":32,"column":41}},"10":{"start":{"line":36,"column":4},"end":{"line":36,"column":56}},"11":{"start":{"line":40,"column":0},"end":{"line":40,"column":23}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":9,"column":2},"end":{"line":9,"column":3}},"loc":{"start":{"line":9,"column":21},"end":{"line":14,"column":3}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":16,"column":2},"end":{"line":16,"column":3}},"loc":{"start":{"line":16,"column":12},"end":{"line":18,"column":3}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":20,"column":2},"end":{"line":20,"column":3}},"loc":{"start":{"line":20,"column":22},"end":{"line":25,"column":3}}},"3":{"name":"(anonymous_3)","decl":{"start":{"line":27,"column":2},"end":{"line":27,"column":3}},"loc":{"start":{"line":27,"column":19},"end":{"line":29,"column":3}}},"4":{"name":"(anonymous_4)","decl":{"start":{"line":31,"column":2},"end":{"line":31,"column":3}},"loc":{"start":{"line":31,"column":28},"end":{"line":33,"column":3}}},"5":{"name":"(anonymous_5)","decl":{"start":{"line":35,"column":2},"end":{"line":35,"column":3}},"loc":{"start":{"line":35,"column":21},"end":{"line":37,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":10,"column":4},"end":{"line":13,"column":18}},"type":"if","locations":[{"start":{"line":10,"column":4},"end":{"line":13,"column":18}},{"start":{"line":10,"column":4},"end":{"line":13,"column":18}}]},"1":{"loc":{"start":{"line":21,"column":4},"end":{"line":24,"column":66}},"type":"if","locations":[{"start":{"line":21,"column":4},"end":{"line":24,"column":66}},{"start":{"line":21,"column":4},"end":{"line":24,"column":66}}]}},"s":{"0":1,"1":8,"2":6,"3":2,"4":1,"5":2,"6":1,"7":1,"8":1,"9":2,"10":1,"11":1},"f":{"0":8,"1":1,"2":2,"3":1,"4":2,"5":1},"b":{"0":[6,2],"1":[1,1]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"b2d0734ef55c3ca592521cca152608e164f521a5"},"/Users/joshchisholm/projects/value-object.js/src/valueObject.js":{"path":"/Users/joshchisholm/projects/value-object.js/src/valueObject.js","statementMap":{"0":{"start":{"line":3,"column":31},"end":{"line":3,"column":54}},"1":{"start":{"line":7,"column":18},"end":{"line":7,"column":88}},"2":{"start":{"line":8,"column":18},"end":{"line":8,"column":61}},"3":{"start":{"line":9,"column":4},"end":{"line":9,"column":28}},"4":{"start":{"line":10,"column":4},"end":{"line":10,"column":16}},"5":{"start":{"line":14,"column":15},"end":{"line":14,"column":19}},"6":{"start":{"line":15,"column":24},"end":{"line":15,"column":64}},"7":{"start":{"line":16,"column":4},"end":{"line":22,"column":5}},"8":{"start":{"line":17,"column":6},"end":{"line":20,"column":53}},"9":{"start":{"line":18,"column":8},"end":{"line":18,"column":82}},"10":{"start":{"line":20,"column":8},"end":{"line":20,"column":53}},"11":{"start":{"line":21,"column":6},"end":{"line":21,"column":40}},"12":{"start":{"line":23,"column":4},"end":{"line":23,"column":24}},"13":{"start":{"line":27,"column":4},"end":{"line":27,"column":113}},"14":{"start":{"line":27,"column":45},"end":{"line":27,"column":113}},"15":{"start":{"line":28,"column":4},"end":{"line":32,"column":5}},"16":{"start":{"line":29,"column":6},"end":{"line":29,"column":81}},"17":{"start":{"line":31,"column":6},"end":{"line":31,"column":76}},"18":{"start":{"line":33,"column":4},"end":{"line":33,"column":16}},"19":{"start":{"line":34,"column":4},"end":{"line":34,"column":23}},"20":{"start":{"line":45,"column":4},"end":{"line":48,"column":5}},"21":{"start":{"line":46,"column":22},"end":{"line":46,"column":111}},"22":{"start":{"line":47,"column":6},"end":{"line":47,"column":34}},"23":{"start":{"line":50,"column":4},"end":{"line":61,"column":6}},"24":{"start":{"line":51,"column":23},"end":{"line":51,"column":37}},"25":{"start":{"line":52,"column":6},"end":{"line":55,"column":7}},"26":{"start":{"line":53,"column":24},"end":{"line":53,"column":135}},"27":{"start":{"line":54,"column":8},"end":{"line":54,"column":36}},"28":{"start":{"line":56,"column":6},"end":{"line":60,"column":8}},"29":{"start":{"line":66,"column":27},"end":{"line":66,"column":40}},"30":{"start":{"line":67,"column":34},"end":{"line":67,"column":57}},"31":{"start":{"line":68,"column":32},"end":{"line":68,"column":59}},"32":{"start":{"line":69,"column":4},"end":{"line":69,"column":149}},"33":{"start":{"line":69,"column":26},"end":{"line":69,"column":149}},"34":{"start":{"line":71,"column":30},"end":{"line":71,"column":167}},"35":{"start":{"line":71,"column":136},"end":{"line":71,"column":166}},"36":{"start":{"line":72,"column":4},"end":{"line":72,"column":162}},"37":{"start":{"line":72,"column":28},"end":{"line":72,"column":162}},"38":{"start":{"line":75,"column":26},"end":{"line":75,"column":30}},"39":{"start":{"line":76,"column":37},"end":{"line":76,"column":39}},"40":{"start":{"line":77,"column":37},"end":{"line":77,"column":39}},"41":{"start":{"line":78,"column":4},"end":{"line":82,"column":5}},"42":{"start":{"line":80,"column":27},"end":{"line":80,"column":51}},"43":{"start":{"line":81,"column":6},"end":{"line":81,"column":131}},"44":{"start":{"line":84,"column":4},"end":{"line":109,"column":5}},"45":{"start":{"line":86,"column":27},"end":{"line":86,"column":51}},"46":{"start":{"line":87,"column":23},"end":{"line":87,"column":51}},"47":{"start":{"line":88,"column":31},"end":{"line":88,"column":46}},"48":{"start":{"line":90,"column":6},"end":{"line":94,"column":7}},"49":{"start":{"line":91,"column":29},"end":{"line":91,"column":158}},"50":{"start":{"line":91,"column":87},"end":{"line":91,"column":146}},"51":{"start":{"line":92,"column":24},"end":{"line":92,"column":113}},"52":{"start":{"line":93,"column":8},"end":{"line":93,"column":36}},"53":{"start":{"line":96,"column":6},"end":{"line":108,"column":7}},"54":{"start":{"line":97,"column":8},"end":{"line":107,"column":9}},"55":{"start":{"line":98,"column":10},"end":{"line":98,"column":55}},"56":{"start":{"line":100,"column":10},"end":{"line":100,"column":138}},"57":{"start":{"line":101,"column":10},"end":{"line":106,"column":11}},"58":{"start":{"line":102,"column":12},"end":{"line":103,"column":37}},"59":{"start":{"line":103,"column":14},"end":{"line":103,"column":37}},"60":{"start":{"line":104,"column":17},"end":{"line":106,"column":11}},"61":{"start":{"line":105,"column":12},"end":{"line":105,"column":35}},"62":{"start":{"line":111,"column":4},"end":{"line":115,"column":5}},"63":{"start":{"line":112,"column":23},"end":{"line":112,"column":152}},"64":{"start":{"line":112,"column":81},"end":{"line":112,"column":140}},"65":{"start":{"line":113,"column":21},"end":{"line":113,"column":150}},"66":{"start":{"line":113,"column":79},"end":{"line":113,"column":138}},"67":{"start":{"line":114,"column":6},"end":{"line":114,"column":102}},"68":{"start":{"line":117,"column":4},"end":{"line":123,"column":5}},"69":{"start":{"line":118,"column":6},"end":{"line":122,"column":8}},"70":{"start":{"line":127,"column":23},"end":{"line":129,"column":5}},"71":{"start":{"line":130,"column":23},"end":{"line":130,"column":25}},"72":{"start":{"line":131,"column":15},"end":{"line":131,"column":31}},"73":{"start":{"line":132,"column":4},"end":{"line":136,"column":5}},"74":{"start":{"line":133,"column":24},"end":{"line":133,"column":103}},"75":{"start":{"line":134,"column":6},"end":{"line":134,"column":50}},"76":{"start":{"line":134,"column":29},"end":{"line":134,"column":49}},"77":{"start":{"line":135,"column":6},"end":{"line":135,"column":40}},"78":{"start":{"line":137,"column":26},"end":{"line":137,"column":49}},"79":{"start":{"line":138,"column":4},"end":{"line":144,"column":5}},"80":{"start":{"line":139,"column":6},"end":{"line":143,"column":7}},"81":{"start":{"line":140,"column":8},"end":{"line":140,"column":67}},"82":{"start":{"line":142,"column":8},"end":{"line":142,"column":53}},"83":{"start":{"line":145,"column":4},"end":{"line":145,"column":21}},"84":{"start":{"line":149,"column":4},"end":{"line":161,"column":5}},"85":{"start":{"line":150,"column":19},"end":{"line":150,"column":76}},"86":{"start":{"line":150,"column":58},"end":{"line":150,"column":75}},"87":{"start":{"line":151,"column":6},"end":{"line":151,"column":30}},"88":{"start":{"line":153,"column":19},"end":{"line":153,"column":41}},"89":{"start":{"line":154,"column":6},"end":{"line":154,"column":26}},"90":{"start":{"line":155,"column":6},"end":{"line":159,"column":7}},"91":{"start":{"line":156,"column":8},"end":{"line":158,"column":9}},"92":{"start":{"line":157,"column":10},"end":{"line":157,"column":59}},"93":{"start":{"line":160,"column":6},"end":{"line":160,"column":27}},"94":{"start":{"line":165,"column":4},"end":{"line":166,"column":80}},"95":{"start":{"line":170,"column":21},"end":{"line":170,"column":45}},"96":{"start":{"line":171,"column":4},"end":{"line":171,"column":40}},"97":{"start":{"line":172,"column":4},"end":{"line":173,"column":41}},"98":{"start":{"line":173,"column":6},"end":{"line":173,"column":41}},"99":{"start":{"line":182,"column":4},"end":{"line":182,"column":82}},"100":{"start":{"line":186,"column":4},"end":{"line":186,"column":85}},"101":{"start":{"line":190,"column":0},"end":{"line":190,"column":28}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":6,"column":2},"end":{"line":6,"column":3}},"loc":{"start":{"line":6,"column":28},"end":{"line":11,"column":3}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":13,"column":2},"end":{"line":13,"column":3}},"loc":{"start":{"line":13,"column":29},"end":{"line":24,"column":3}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":26,"column":2},"end":{"line":26,"column":3}},"loc":{"start":{"line":26,"column":16},"end":{"line":35,"column":3}}},"3":{"name":"(anonymous_3)","decl":{"start":{"line":41,"column":2},"end":{"line":41,"column":3}},"loc":{"start":{"line":41,"column":10},"end":{"line":42,"column":3}}},"4":{"name":"(anonymous_4)","decl":{"start":{"line":44,"column":2},"end":{"line":44,"column":3}},"loc":{"start":{"line":44,"column":48},"end":{"line":62,"column":3}}},"5":{"name":"(anonymous_5)","decl":{"start":{"line":50,"column":23},"end":{"line":50,"column":24}},"loc":{"start":{"line":50,"column":51},"end":{"line":61,"column":5}}},"6":{"name":"(anonymous_6)","decl":{"start":{"line":64,"column":2},"end":{"line":64,"column":3}},"loc":{"start":{"line":64,"column":43},"end":{"line":124,"column":3}}},"7":{"name":"(anonymous_7)","decl":{"start":{"line":71,"column":120},"end":{"line":71,"column":121}},"loc":{"start":{"line":71,"column":136},"end":{"line":71,"column":166}}},"8":{"name":"(anonymous_8)","decl":{"start":{"line":91,"column":71},"end":{"line":91,"column":72}},"loc":{"start":{"line":91,"column":87},"end":{"line":91,"column":146}}},"9":{"name":"(anonymous_9)","decl":{"start":{"line":112,"column":65},"end":{"line":112,"column":66}},"loc":{"start":{"line":112,"column":81},"end":{"line":112,"column":140}}},"10":{"name":"(anonymous_10)","decl":{"start":{"line":113,"column":63},"end":{"line":113,"column":64}},"loc":{"start":{"line":113,"column":79},"end":{"line":113,"column":138}}},"11":{"name":"(anonymous_11)","decl":{"start":{"line":126,"column":2},"end":{"line":126,"column":3}},"loc":{"start":{"line":126,"column":11},"end":{"line":146,"column":3}}},"12":{"name":"(anonymous_12)","decl":{"start":{"line":134,"column":24},"end":{"line":134,"column":25}},"loc":{"start":{"line":134,"column":29},"end":{"line":134,"column":49}}},"13":{"name":"(anonymous_13)","decl":{"start":{"line":148,"column":2},"end":{"line":148,"column":3}},"loc":{"start":{"line":148,"column":23},"end":{"line":162,"column":3}}},"14":{"name":"(anonymous_14)","decl":{"start":{"line":150,"column":42},"end":{"line":150,"column":43}},"loc":{"start":{"line":150,"column":58},"end":{"line":150,"column":75}}},"15":{"name":"(anonymous_15)","decl":{"start":{"line":164,"column":2},"end":{"line":164,"column":3}},"loc":{"start":{"line":164,"column":30},"end":{"line":167,"column":3}}},"16":{"name":"(anonymous_16)","decl":{"start":{"line":169,"column":2},"end":{"line":169,"column":3}},"loc":{"start":{"line":169,"column":13},"end":{"line":174,"column":3}}},"17":{"name":"(anonymous_17)","decl":{"start":{"line":176,"column":2},"end":{"line":176,"column":3}},"loc":{"start":{"line":176,"column":40},"end":{"line":179,"column":3}}},"18":{"name":"(anonymous_18)","decl":{"start":{"line":181,"column":2},"end":{"line":181,"column":3}},"loc":{"start":{"line":181,"column":33},"end":{"line":183,"column":3}}},"19":{"name":"(anonymous_19)","decl":{"start":{"line":185,"column":2},"end":{"line":185,"column":3}},"loc":{"start":{"line":185,"column":26},"end":{"line":187,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":7,"column":18},"end":{"line":7,"column":88}},"type":"cond-expr","locations":[{"start":{"line":7,"column":50},"end":{"line":7,"column":60}},{"start":{"line":7,"column":63},"end":{"line":7,"column":88}}]},"1":{"loc":{"start":{"line":15,"column":24},"end":{"line":15,"column":64}},"type":"cond-expr","locations":[{"start":{"line":15,"column":57},"end":{"line":15,"column":59}},{"start":{"line":15,"column":62},"end":{"line":15,"column":64}}]},"2":{"loc":{"start":{"line":17,"column":6},"end":{"line":20,"column":53}},"type":"if","locations":[{"start":{"line":17,"column":6},"end":{"line":20,"column":53}},{"start":{"line":17,"column":6},"end":{"line":20,"column":53}}]},"3":{"loc":{"start":{"line":27,"column":4},"end":{"line":27,"column":113}},"type":"if","locations":[{"start":{"line":27,"column":4},"end":{"line":27,"column":113}},{"start":{"line":27,"column":4},"end":{"line":27,"column":113}}]},"4":{"loc":{"start":{"line":28,"column":4},"end":{"line":32,"column":5}},"type":"if","locations":[{"start":{"line":28,"column":4},"end":{"line":32,"column":5}},{"start":{"line":28,"column":4},"end":{"line":32,"column":5}}]},"5":{"loc":{"start":{"line":45,"column":4},"end":{"line":48,"column":5}},"type":"if","locations":[{"start":{"line":45,"column":4},"end":{"line":48,"column":5}},{"start":{"line":45,"column":4},"end":{"line":48,"column":5}}]},"6":{"loc":{"start":{"line":52,"column":6},"end":{"line":55,"column":7}},"type":"if","locations":[{"start":{"line":52,"column":6},"end":{"line":55,"column":7}},{"start":{"line":52,"column":6},"end":{"line":55,"column":7}}]},"7":{"loc":{"start":{"line":66,"column":27},"end":{"line":66,"column":40}},"type":"binary-expr","locations":[{"start":{"line":66,"column":27},"end":{"line":66,"column":34}},{"start":{"line":66,"column":38},"end":{"line":66,"column":40}}]},"8":{"loc":{"start":{"line":69,"column":4},"end":{"line":69,"column":149}},"type":"if","locations":[{"start":{"line":69,"column":4},"end":{"line":69,"column":149}},{"start":{"line":69,"column":4},"end":{"line":69,"column":149}}]},"9":{"loc":{"start":{"line":71,"column":30},"end":{"line":71,"column":167}},"type":"binary-expr","locations":[{"start":{"line":71,"column":30},"end":{"line":71,"column":88}},{"start":{"line":71,"column":92},"end":{"line":71,"column":167}}]},"10":{"loc":{"start":{"line":72,"column":4},"end":{"line":72,"column":162}},"type":"if","locations":[{"start":{"line":72,"column":4},"end":{"line":72,"column":162}},{"start":{"line":72,"column":4},"end":{"line":72,"column":162}}]},"11":{"loc":{"start":{"line":81,"column":47},"end":{"line":81,"column":131}},"type":"cond-expr","locations":[{"start":{"line":81,"column":83},"end":{"line":81,"column":116}},{"start":{"line":81,"column":119},"end":{"line":81,"column":131}}]},"12":{"loc":{"start":{"line":90,"column":6},"end":{"line":94,"column":7}},"type":"if","locations":[{"start":{"line":90,"column":6},"end":{"line":94,"column":7}},{"start":{"line":90,"column":6},"end":{"line":94,"column":7}}]},"13":{"loc":{"start":{"line":96,"column":6},"end":{"line":108,"column":7}},"type":"if","locations":[{"start":{"line":96,"column":6},"end":{"line":108,"column":7}},{"start":{"line":96,"column":6},"end":{"line":108,"column":7}}]},"14":{"loc":{"start":{"line":97,"column":8},"end":{"line":107,"column":9}},"type":"if","locations":[{"start":{"line":97,"column":8},"end":{"line":107,"column":9}},{"start":{"line":97,"column":8},"end":{"line":107,"column":9}}]},"15":{"loc":{"start":{"line":100,"column":51},"end":{"line":100,"column":138}},"type":"cond-expr","locations":[{"start":{"line":100,"column":82},"end":{"line":100,"column":119}},{"start":{"line":100,"column":122},"end":{"line":100,"column":138}}]},"16":{"loc":{"start":{"line":101,"column":10},"end":{"line":106,"column":11}},"type":"if","locations":[{"start":{"line":101,"column":10},"end":{"line":106,"column":11}},{"start":{"line":101,"column":10},"end":{"line":106,"column":11}}]},"17":{"loc":{"start":{"line":102,"column":12},"end":{"line":103,"column":37}},"type":"if","locations":[{"start":{"line":102,"column":12},"end":{"line":103,"column":37}},{"start":{"line":102,"column":12},"end":{"line":103,"column":37}}]},"18":{"loc":{"start":{"line":104,"column":17},"end":{"line":106,"column":11}},"type":"if","locations":[{"start":{"line":104,"column":17},"end":{"line":106,"column":11}},{"start":{"line":104,"column":17},"end":{"line":106,"column":11}}]},"19":{"loc":{"start":{"line":111,"column":4},"end":{"line":115,"column":5}},"type":"if","locations":[{"start":{"line":111,"column":4},"end":{"line":115,"column":5}},{"start":{"line":111,"column":4},"end":{"line":115,"column":5}}]},"20":{"loc":{"start":{"line":133,"column":24},"end":{"line":133,"column":103}},"type":"cond-expr","locations":[{"start":{"line":133,"column":57},"end":{"line":133,"column":72}},{"start":{"line":133,"column":75},"end":{"line":133,"column":103}}]},"21":{"loc":{"start":{"line":139,"column":6},"end":{"line":143,"column":7}},"type":"if","locations":[{"start":{"line":139,"column":6},"end":{"line":143,"column":7}},{"start":{"line":139,"column":6},"end":{"line":143,"column":7}}]},"22":{"loc":{"start":{"line":149,"column":4},"end":{"line":161,"column":5}},"type":"if","locations":[{"start":{"line":149,"column":4},"end":{"line":161,"column":5}},{"start":{"line":149,"column":4},"end":{"line":161,"column":5}}]},"23":{"loc":{"start":{"line":156,"column":8},"end":{"line":158,"column":9}},"type":"if","locations":[{"start":{"line":156,"column":8},"end":{"line":158,"column":9}},{"start":{"line":156,"column":8},"end":{"line":158,"column":9}}]},"24":{"loc":{"start":{"line":165,"column":11},"end":{"line":166,"column":80}},"type":"binary-expr","locations":[{"start":{"line":165,"column":11},"end":{"line":165,"column":55}},{"start":{"line":166,"column":6},"end":{"line":166,"column":80}}]},"25":{"loc":{"start":{"line":172,"column":4},"end":{"line":173,"column":41}},"type":"if","locations":[{"start":{"line":172,"column":4},"end":{"line":173,"column":41}},{"start":{"line":172,"column":4},"end":{"line":173,"column":41}}]}},"s":{"0":1,"1":31,"2":31,"3":31,"4":31,"5":72,"6":72,"7":72,"8":145,"9":16,"10":129,"11":145,"12":72,"13":52,"14":1,"15":51,"16":6,"17":45,"18":42,"19":42,"20":6,"21":1,"22":1,"23":5,"24":9,"25":9,"26":1,"27":1,"28":8,"29":45,"30":45,"31":45,"32":45,"33":2,"34":43,"35":70,"36":43,"37":2,"38":41,"39":41,"40":41,"41":41,"42":69,"43":69,"44":41,"45":69,"46":69,"47":69,"48":69,"49":1,"50":2,"51":1,"52":1,"53":68,"54":68,"55":2,"56":66,"57":66,"58":7,"59":1,"60":59,"61":1,"62":40,"63":2,"64":6,"65":2,"66":6,"67":2,"68":38,"69":61,"70":10,"71":10,"72":10,"73":10,"74":19,"75":19,"76":28,"77":19,"78":10,"79":10,"80":19,"81":2,"82":17,"83":10,"84":5,"85":1,"86":2,"87":1,"88":4,"89":4,"90":4,"91":11,"92":2,"93":4,"94":6,"95":4,"96":4,"97":4,"98":2,"99":1,"100":2,"101":1},"f":{"0":31,"1":72,"2":52,"3":42,"4":6,"5":9,"6":45,"7":70,"8":2,"9":6,"10":6,"11":10,"12":28,"13":5,"14":2,"15":6,"16":4,"17":1,"18":1,"19":2},"b":{"0":[26,5],"1":[8,64],"2":[16,129],"3":[1,51],"4":[6,45],"5":[1,5],"6":[1,8],"7":[45,1],"8":[2,43],"9":[43,42],"10":[2,41],"11":[7,62],"12":[1,68],"13":[68,0],"14":[2,66],"15":[7,59],"16":[7,59],"17":[1,6],"18":[1,58],"19":[2,38],"20":[2,17],"21":[2,17],"22":[1,4],"23":[2,9],"24":[6,2],"25":[2,2]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"80107c6b71c407a7146bc4f59b9c466ce8f0fd86"},"/Users/joshchisholm/projects/value-object.js/src/validation.js":{"path":"/Users/joshchisholm/projects/value-object.js/src/validation.js","statementMap":{"0":{"start":{"line":5,"column":4},"end":{"line":5,"column":22}},"1":{"start":{"line":9,"column":4},"end":{"line":9,"column":60}},"2":{"start":{"line":13,"column":4},"end":{"line":13,"column":89}},"3":{"start":{"line":14,"column":4},"end":{"line":14,"column":15}},"4":{"start":{"line":18,"column":4},"end":{"line":18,"column":35}},"5":{"start":{"line":22,"column":4},"end":{"line":22,"column":60}},"6":{"start":{"line":26,"column":4},"end":{"line":26,"column":61}},"7":{"start":{"line":26,"column":31},"end":{"line":26,"column":49}},"8":{"start":{"line":32,"column":4},"end":{"line":32,"column":28}},"9":{"start":{"line":33,"column":4},"end":{"line":33,"column":28}},"10":{"start":{"line":37,"column":4},"end":{"line":37,"column":66}},"11":{"start":{"line":38,"column":4},"end":{"line":38,"column":15}},"12":{"start":{"line":44,"column":4},"end":{"line":44,"column":26}},"13":{"start":{"line":48,"column":4},"end":{"line":48,"column":23}},"14":{"start":{"line":54,"column":4},"end":{"line":54,"column":28}},"15":{"start":{"line":55,"column":4},"end":{"line":55,"column":26}},"16":{"start":{"line":59,"column":4},"end":{"line":59,"column":45}},"17":{"start":{"line":63,"column":0},"end":{"line":65,"column":1}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":4,"column":2},"end":{"line":4,"column":3}},"loc":{"start":{"line":4,"column":16},"end":{"line":6,"column":3}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":8,"column":2},"end":{"line":8,"column":3}},"loc":{"start":{"line":8,"column":16},"end":{"line":10,"column":3}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":12,"column":2},"end":{"line":12,"column":3}},"loc":{"start":{"line":12,"column":15},"end":{"line":15,"column":3}}},"3":{"name":"(anonymous_3)","decl":{"start":{"line":17,"column":2},"end":{"line":17,"column":3}},"loc":{"start":{"line":17,"column":8},"end":{"line":19,"column":3}}},"4":{"name":"(anonymous_4)","decl":{"start":{"line":21,"column":2},"end":{"line":21,"column":3}},"loc":{"start":{"line":21,"column":8},"end":{"line":23,"column":3}}},"5":{"name":"(anonymous_5)","decl":{"start":{"line":25,"column":2},"end":{"line":25,"column":3}},"loc":{"start":{"line":25,"column":13},"end":{"line":27,"column":3}}},"6":{"name":"(anonymous_6)","decl":{"start":{"line":26,"column":20},"end":{"line":26,"column":21}},"loc":{"start":{"line":26,"column":31},"end":{"line":26,"column":49}}},"7":{"name":"(anonymous_7)","decl":{"start":{"line":31,"column":2},"end":{"line":31,"column":3}},"loc":{"start":{"line":31,"column":34},"end":{"line":34,"column":3}}},"8":{"name":"(anonymous_8)","decl":{"start":{"line":36,"column":2},"end":{"line":36,"column":3}},"loc":{"start":{"line":36,"column":15},"end":{"line":39,"column":3}}},"9":{"name":"(anonymous_9)","decl":{"start":{"line":43,"column":2},"end":{"line":43,"column":3}},"loc":{"start":{"line":43,"column":23},"end":{"line":45,"column":3}}},"10":{"name":"(anonymous_10)","decl":{"start":{"line":47,"column":2},"end":{"line":47,"column":3}},"loc":{"start":{"line":47,"column":13},"end":{"line":49,"column":3}}},"11":{"name":"(anonymous_11)","decl":{"start":{"line":53,"column":2},"end":{"line":53,"column":3}},"loc":{"start":{"line":53,"column":33},"end":{"line":56,"column":3}}},"12":{"name":"(anonymous_12)","decl":{"start":{"line":58,"column":2},"end":{"line":58,"column":3}},"loc":{"start":{"line":58,"column":13},"end":{"line":60,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":13,"column":23},"end":{"line":13,"column":88}},"type":"cond-expr","locations":[{"start":{"line":13,"column":52},"end":{"line":13,"column":59}},{"start":{"line":13,"column":62},"end":{"line":13,"column":88}}]}},"s":{"0":4,"1":2,"2":4,"3":4,"4":4,"5":2,"6":1,"7":2,"8":2,"9":2,"10":2,"11":2,"12":2,"13":1,"14":2,"15":2,"16":1,"17":1},"f":{"0":4,"1":2,"2":4,"3":4,"4":2,"5":1,"6":2,"7":2,"8":2,"9":2,"10":1,"11":2,"12":1},"b":{"0":[2,2]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"ffbb5d501cbb598110be9e2398a8086637cf074d"}}
{"/Users/joshchisholm/projects/value-object.js/src/valueObject.js":{"path":"/Users/joshchisholm/projects/value-object.js/src/valueObject.js","statementMap":{"0":{"start":{"line":3,"column":31},"end":{"line":3,"column":54}},"1":{"start":{"line":7,"column":18},"end":{"line":7,"column":88}},"2":{"start":{"line":8,"column":18},"end":{"line":8,"column":60}},"3":{"start":{"line":9,"column":4},"end":{"line":9,"column":28}},"4":{"start":{"line":10,"column":4},"end":{"line":10,"column":16}},"5":{"start":{"line":14,"column":15},"end":{"line":14,"column":19}},"6":{"start":{"line":15,"column":24},"end":{"line":15,"column":64}},"7":{"start":{"line":16,"column":4},"end":{"line":22,"column":5}},"8":{"start":{"line":17,"column":6},"end":{"line":20,"column":53}},"9":{"start":{"line":18,"column":8},"end":{"line":18,"column":82}},"10":{"start":{"line":20,"column":8},"end":{"line":20,"column":53}},"11":{"start":{"line":21,"column":6},"end":{"line":21,"column":40}},"12":{"start":{"line":23,"column":4},"end":{"line":23,"column":24}},"13":{"start":{"line":27,"column":4},"end":{"line":27,"column":113}},"14":{"start":{"line":27,"column":45},"end":{"line":27,"column":113}},"15":{"start":{"line":28,"column":4},"end":{"line":32,"column":5}},"16":{"start":{"line":29,"column":6},"end":{"line":29,"column":81}},"17":{"start":{"line":31,"column":6},"end":{"line":31,"column":76}},"18":{"start":{"line":33,"column":4},"end":{"line":33,"column":16}},"19":{"start":{"line":34,"column":4},"end":{"line":34,"column":23}},"20":{"start":{"line":45,"column":4},"end":{"line":48,"column":5}},"21":{"start":{"line":46,"column":22},"end":{"line":46,"column":111}},"22":{"start":{"line":47,"column":6},"end":{"line":47,"column":34}},"23":{"start":{"line":50,"column":4},"end":{"line":61,"column":6}},"24":{"start":{"line":51,"column":23},"end":{"line":51,"column":37}},"25":{"start":{"line":52,"column":6},"end":{"line":55,"column":7}},"26":{"start":{"line":53,"column":24},"end":{"line":53,"column":135}},"27":{"start":{"line":54,"column":8},"end":{"line":54,"column":36}},"28":{"start":{"line":56,"column":6},"end":{"line":60,"column":8}},"29":{"start":{"line":66,"column":27},"end":{"line":66,"column":40}},"30":{"start":{"line":67,"column":34},"end":{"line":67,"column":57}},"31":{"start":{"line":68,"column":32},"end":{"line":68,"column":59}},"32":{"start":{"line":69,"column":4},"end":{"line":69,"column":149}},"33":{"start":{"line":69,"column":26},"end":{"line":69,"column":149}},"34":{"start":{"line":71,"column":30},"end":{"line":71,"column":167}},"35":{"start":{"line":71,"column":136},"end":{"line":71,"column":166}},"36":{"start":{"line":72,"column":4},"end":{"line":72,"column":162}},"37":{"start":{"line":72,"column":28},"end":{"line":72,"column":162}},"38":{"start":{"line":75,"column":26},"end":{"line":75,"column":30}},"39":{"start":{"line":76,"column":37},"end":{"line":76,"column":39}},"40":{"start":{"line":77,"column":37},"end":{"line":77,"column":39}},"41":{"start":{"line":78,"column":4},"end":{"line":82,"column":5}},"42":{"start":{"line":80,"column":27},"end":{"line":80,"column":51}},"43":{"start":{"line":81,"column":6},"end":{"line":81,"column":131}},"44":{"start":{"line":84,"column":4},"end":{"line":105,"column":5}},"45":{"start":{"line":86,"column":27},"end":{"line":86,"column":51}},"46":{"start":{"line":87,"column":23},"end":{"line":87,"column":51}},"47":{"start":{"line":88,"column":31},"end":{"line":88,"column":46}},"48":{"start":{"line":90,"column":6},"end":{"line":104,"column":7}},"49":{"start":{"line":91,"column":29},"end":{"line":91,"column":158}},"50":{"start":{"line":91,"column":87},"end":{"line":91,"column":146}},"51":{"start":{"line":92,"column":24},"end":{"line":92,"column":113}},"52":{"start":{"line":93,"column":8},"end":{"line":93,"column":36}},"53":{"start":{"line":94,"column":13},"end":{"line":104,"column":7}},"54":{"start":{"line":95,"column":8},"end":{"line":95,"column":53}},"55":{"start":{"line":97,"column":8},"end":{"line":97,"column":136}},"56":{"start":{"line":98,"column":8},"end":{"line":103,"column":9}},"57":{"start":{"line":99,"column":10},"end":{"line":100,"column":35}},"58":{"start":{"line":100,"column":12},"end":{"line":100,"column":35}},"59":{"start":{"line":101,"column":15},"end":{"line":103,"column":9}},"60":{"start":{"line":102,"column":10},"end":{"line":102,"column":33}},"61":{"start":{"line":107,"column":4},"end":{"line":111,"column":5}},"62":{"start":{"line":108,"column":23},"end":{"line":108,"column":152}},"63":{"start":{"line":108,"column":81},"end":{"line":108,"column":140}},"64":{"start":{"line":109,"column":21},"end":{"line":109,"column":150}},"65":{"start":{"line":109,"column":79},"end":{"line":109,"column":138}},"66":{"start":{"line":110,"column":6},"end":{"line":110,"column":102}},"67":{"start":{"line":113,"column":4},"end":{"line":119,"column":5}},"68":{"start":{"line":114,"column":6},"end":{"line":118,"column":8}},"69":{"start":{"line":123,"column":23},"end":{"line":125,"column":5}},"70":{"start":{"line":126,"column":23},"end":{"line":126,"column":25}},"71":{"start":{"line":127,"column":15},"end":{"line":127,"column":31}},"72":{"start":{"line":128,"column":4},"end":{"line":132,"column":5}},"73":{"start":{"line":129,"column":24},"end":{"line":129,"column":103}},"74":{"start":{"line":130,"column":6},"end":{"line":130,"column":50}},"75":{"start":{"line":130,"column":29},"end":{"line":130,"column":49}},"76":{"start":{"line":131,"column":6},"end":{"line":131,"column":40}},"77":{"start":{"line":133,"column":26},"end":{"line":133,"column":49}},"78":{"start":{"line":134,"column":4},"end":{"line":140,"column":5}},"79":{"start":{"line":135,"column":6},"end":{"line":139,"column":7}},"80":{"start":{"line":136,"column":8},"end":{"line":136,"column":67}},"81":{"start":{"line":138,"column":8},"end":{"line":138,"column":53}},"82":{"start":{"line":141,"column":4},"end":{"line":141,"column":21}},"83":{"start":{"line":145,"column":4},"end":{"line":157,"column":5}},"84":{"start":{"line":146,"column":19},"end":{"line":146,"column":76}},"85":{"start":{"line":146,"column":58},"end":{"line":146,"column":75}},"86":{"start":{"line":147,"column":6},"end":{"line":147,"column":30}},"87":{"start":{"line":149,"column":19},"end":{"line":149,"column":41}},"88":{"start":{"line":150,"column":6},"end":{"line":150,"column":26}},"89":{"start":{"line":151,"column":6},"end":{"line":155,"column":7}},"90":{"start":{"line":152,"column":8},"end":{"line":154,"column":9}},"91":{"start":{"line":153,"column":10},"end":{"line":153,"column":59}},"92":{"start":{"line":156,"column":6},"end":{"line":156,"column":27}},"93":{"start":{"line":161,"column":4},"end":{"line":162,"column":80}},"94":{"start":{"line":166,"column":21},"end":{"line":166,"column":45}},"95":{"start":{"line":167,"column":4},"end":{"line":167,"column":40}},"96":{"start":{"line":168,"column":4},"end":{"line":169,"column":41}},"97":{"start":{"line":169,"column":6},"end":{"line":169,"column":41}},"98":{"start":{"line":178,"column":4},"end":{"line":178,"column":82}},"99":{"start":{"line":182,"column":4},"end":{"line":182,"column":85}},"100":{"start":{"line":186,"column":25},"end":{"line":191,"column":10}},"101":{"start":{"line":187,"column":6},"end":{"line":188,"column":63}},"102":{"start":{"line":188,"column":8},"end":{"line":188,"column":63}},"103":{"start":{"line":190,"column":6},"end":{"line":190,"column":44}},"104":{"start":{"line":193,"column":4},"end":{"line":193,"column":45}},"105":{"start":{"line":193,"column":21},"end":{"line":193,"column":45}},"106":{"start":{"line":196,"column":6},"end":{"line":196,"column":49}},"107":{"start":{"line":196,"column":37},"end":{"line":196,"column":49}},"108":{"start":{"line":198,"column":26},"end":{"line":198,"column":54}},"109":{"start":{"line":200,"column":6},"end":{"line":201,"column":156}},"110":{"start":{"line":201,"column":8},"end":{"line":201,"column":156}},"111":{"start":{"line":202,"column":6},"end":{"line":203,"column":146}},"112":{"start":{"line":203,"column":8},"end":{"line":203,"column":146}},"113":{"start":{"line":205,"column":6},"end":{"line":205,"column":40}},"114":{"start":{"line":217,"column":4},"end":{"line":220,"column":18}},"115":{"start":{"line":218,"column":6},"end":{"line":218,"column":22}},"116":{"start":{"line":220,"column":6},"end":{"line":220,"column":18}},"117":{"start":{"line":224,"column":4},"end":{"line":224,"column":21}},"118":{"start":{"line":228,"column":4},"end":{"line":231,"column":66}},"119":{"start":{"line":229,"column":6},"end":{"line":229,"column":93}},"120":{"start":{"line":231,"column":6},"end":{"line":231,"column":66}},"121":{"start":{"line":235,"column":4},"end":{"line":235,"column":32}},"122":{"start":{"line":239,"column":4},"end":{"line":239,"column":41}},"123":{"start":{"line":243,"column":4},"end":{"line":243,"column":56}},"124":{"start":{"line":247,"column":0},"end":{"line":247,"column":27}},"125":{"start":{"line":249,"column":0},"end":{"line":249,"column":28}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":6,"column":2},"end":{"line":6,"column":3}},"loc":{"start":{"line":6,"column":28},"end":{"line":11,"column":3}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":13,"column":2},"end":{"line":13,"column":3}},"loc":{"start":{"line":13,"column":29},"end":{"line":24,"column":3}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":26,"column":2},"end":{"line":26,"column":3}},"loc":{"start":{"line":26,"column":16},"end":{"line":35,"column":3}}},"3":{"name":"(anonymous_3)","decl":{"start":{"line":41,"column":2},"end":{"line":41,"column":3}},"loc":{"start":{"line":41,"column":10},"end":{"line":42,"column":3}}},"4":{"name":"(anonymous_4)","decl":{"start":{"line":44,"column":2},"end":{"line":44,"column":3}},"loc":{"start":{"line":44,"column":48},"end":{"line":62,"column":3}}},"5":{"name":"(anonymous_5)","decl":{"start":{"line":50,"column":23},"end":{"line":50,"column":24}},"loc":{"start":{"line":50,"column":51},"end":{"line":61,"column":5}}},"6":{"name":"(anonymous_6)","decl":{"start":{"line":64,"column":2},"end":{"line":64,"column":3}},"loc":{"start":{"line":64,"column":43},"end":{"line":120,"column":3}}},"7":{"name":"(anonymous_7)","decl":{"start":{"line":71,"column":120},"end":{"line":71,"column":121}},"loc":{"start":{"line":71,"column":136},"end":{"line":71,"column":166}}},"8":{"name":"(anonymous_8)","decl":{"start":{"line":91,"column":71},"end":{"line":91,"column":72}},"loc":{"start":{"line":91,"column":87},"end":{"line":91,"column":146}}},"9":{"name":"(anonymous_9)","decl":{"start":{"line":108,"column":65},"end":{"line":108,"column":66}},"loc":{"start":{"line":108,"column":81},"end":{"line":108,"column":140}}},"10":{"name":"(anonymous_10)","decl":{"start":{"line":109,"column":63},"end":{"line":109,"column":64}},"loc":{"start":{"line":109,"column":79},"end":{"line":109,"column":138}}},"11":{"name":"(anonymous_11)","decl":{"start":{"line":122,"column":2},"end":{"line":122,"column":3}},"loc":{"start":{"line":122,"column":11},"end":{"line":142,"column":3}}},"12":{"name":"(anonymous_12)","decl":{"start":{"line":130,"column":24},"end":{"line":130,"column":25}},"loc":{"start":{"line":130,"column":29},"end":{"line":130,"column":49}}},"13":{"name":"(anonymous_13)","decl":{"start":{"line":144,"column":2},"end":{"line":144,"column":3}},"loc":{"start":{"line":144,"column":23},"end":{"line":158,"column":3}}},"14":{"name":"(anonymous_14)","decl":{"start":{"line":146,"column":42},"end":{"line":146,"column":43}},"loc":{"start":{"line":146,"column":58},"end":{"line":146,"column":75}}},"15":{"name":"(anonymous_15)","decl":{"start":{"line":160,"column":2},"end":{"line":160,"column":3}},"loc":{"start":{"line":160,"column":30},"end":{"line":163,"column":3}}},"16":{"name":"(anonymous_16)","decl":{"start":{"line":165,"column":2},"end":{"line":165,"column":3}},"loc":{"start":{"line":165,"column":13},"end":{"line":170,"column":3}}},"17":{"name":"(anonymous_17)","decl":{"start":{"line":172,"column":2},"end":{"line":172,"column":3}},"loc":{"start":{"line":172,"column":40},"end":{"line":175,"column":3}}},"18":{"name":"(anonymous_18)","decl":{"start":{"line":177,"column":2},"end":{"line":177,"column":3}},"loc":{"start":{"line":177,"column":33},"end":{"line":179,"column":3}}},"19":{"name":"(anonymous_19)","decl":{"start":{"line":181,"column":2},"end":{"line":181,"column":3}},"loc":{"start":{"line":181,"column":26},"end":{"line":183,"column":3}}},"20":{"name":"(anonymous_20)","decl":{"start":{"line":185,"column":2},"end":{"line":185,"column":3}},"loc":{"start":{"line":185,"column":46},"end":{"line":207,"column":3}}},"21":{"name":"(anonymous_21)","decl":{"start":{"line":186,"column":43},"end":{"line":186,"column":44}},"loc":{"start":{"line":186,"column":65},"end":{"line":191,"column":5}}},"22":{"name":"(anonymous_22)","decl":{"start":{"line":193,"column":11},"end":{"line":193,"column":12}},"loc":{"start":{"line":193,"column":21},"end":{"line":193,"column":45}}},"23":{"name":"revive","decl":{"start":{"line":195,"column":13},"end":{"line":195,"column":19}},"loc":{"start":{"line":195,"column":32},"end":{"line":206,"column":5}}},"24":{"name":"(anonymous_24)","decl":{"start":{"line":216,"column":2},"end":{"line":216,"column":3}},"loc":{"start":{"line":216,"column":21},"end":{"line":221,"column":3}}},"25":{"name":"(anonymous_25)","decl":{"start":{"line":223,"column":2},"end":{"line":223,"column":3}},"loc":{"start":{"line":223,"column":12},"end":{"line":225,"column":3}}},"26":{"name":"(anonymous_26)","decl":{"start":{"line":227,"column":2},"end":{"line":227,"column":3}},"loc":{"start":{"line":227,"column":22},"end":{"line":232,"column":3}}},"27":{"name":"(anonymous_27)","decl":{"start":{"line":234,"column":2},"end":{"line":234,"column":3}},"loc":{"start":{"line":234,"column":19},"end":{"line":236,"column":3}}},"28":{"name":"(anonymous_28)","decl":{"start":{"line":238,"column":2},"end":{"line":238,"column":3}},"loc":{"start":{"line":238,"column":28},"end":{"line":240,"column":3}}},"29":{"name":"(anonymous_29)","decl":{"start":{"line":242,"column":2},"end":{"line":242,"column":3}},"loc":{"start":{"line":242,"column":21},"end":{"line":244,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":7,"column":18},"end":{"line":7,"column":88}},"type":"cond-expr","locations":[{"start":{"line":7,"column":50},"end":{"line":7,"column":60}},{"start":{"line":7,"column":63},"end":{"line":7,"column":88}}]},"1":{"loc":{"start":{"line":15,"column":24},"end":{"line":15,"column":64}},"type":"cond-expr","locations":[{"start":{"line":15,"column":57},"end":{"line":15,"column":59}},{"start":{"line":15,"column":62},"end":{"line":15,"column":64}}]},"2":{"loc":{"start":{"line":17,"column":6},"end":{"line":20,"column":53}},"type":"if","locations":[{"start":{"line":17,"column":6},"end":{"line":20,"column":53}},{"start":{"line":17,"column":6},"end":{"line":20,"column":53}}]},"3":{"loc":{"start":{"line":27,"column":4},"end":{"line":27,"column":113}},"type":"if","locations":[{"start":{"line":27,"column":4},"end":{"line":27,"column":113}},{"start":{"line":27,"column":4},"end":{"line":27,"column":113}}]},"4":{"loc":{"start":{"line":28,"column":4},"end":{"line":32,"column":5}},"type":"if","locations":[{"start":{"line":28,"column":4},"end":{"line":32,"column":5}},{"start":{"line":28,"column":4},"end":{"line":32,"column":5}}]},"5":{"loc":{"start":{"line":45,"column":4},"end":{"line":48,"column":5}},"type":"if","locations":[{"start":{"line":45,"column":4},"end":{"line":48,"column":5}},{"start":{"line":45,"column":4},"end":{"line":48,"column":5}}]},"6":{"loc":{"start":{"line":52,"column":6},"end":{"line":55,"column":7}},"type":"if","locations":[{"start":{"line":52,"column":6},"end":{"line":55,"column":7}},{"start":{"line":52,"column":6},"end":{"line":55,"column":7}}]},"7":{"loc":{"start":{"line":66,"column":27},"end":{"line":66,"column":40}},"type":"binary-expr","locations":[{"start":{"line":66,"column":27},"end":{"line":66,"column":34}},{"start":{"line":66,"column":38},"end":{"line":66,"column":40}}]},"8":{"loc":{"start":{"line":69,"column":4},"end":{"line":69,"column":149}},"type":"if","locations":[{"start":{"line":69,"column":4},"end":{"line":69,"column":149}},{"start":{"line":69,"column":4},"end":{"line":69,"column":149}}]},"9":{"loc":{"start":{"line":71,"column":30},"end":{"line":71,"column":167}},"type":"binary-expr","locations":[{"start":{"line":71,"column":30},"end":{"line":71,"column":88}},{"start":{"line":71,"column":92},"end":{"line":71,"column":167}}]},"10":{"loc":{"start":{"line":72,"column":4},"end":{"line":72,"column":162}},"type":"if","locations":[{"start":{"line":72,"column":4},"end":{"line":72,"column":162}},{"start":{"line":72,"column":4},"end":{"line":72,"column":162}}]},"11":{"loc":{"start":{"line":81,"column":47},"end":{"line":81,"column":131}},"type":"cond-expr","locations":[{"start":{"line":81,"column":83},"end":{"line":81,"column":116}},{"start":{"line":81,"column":119},"end":{"line":81,"column":131}}]},"12":{"loc":{"start":{"line":90,"column":6},"end":{"line":104,"column":7}},"type":"if","locations":[{"start":{"line":90,"column":6},"end":{"line":104,"column":7}},{"start":{"line":90,"column":6},"end":{"line":104,"column":7}}]},"13":{"loc":{"start":{"line":94,"column":13},"end":{"line":104,"column":7}},"type":"if","locations":[{"start":{"line":94,"column":13},"end":{"line":104,"column":7}},{"start":{"line":94,"column":13},"end":{"line":104,"column":7}}]},"14":{"loc":{"start":{"line":97,"column":49},"end":{"line":97,"column":136}},"type":"cond-expr","locations":[{"start":{"line":97,"column":80},"end":{"line":97,"column":117}},{"start":{"line":97,"column":120},"end":{"line":97,"column":136}}]},"15":{"loc":{"start":{"line":98,"column":8},"end":{"line":103,"column":9}},"type":"if","locations":[{"start":{"line":98,"column":8},"end":{"line":103,"column":9}},{"start":{"line":98,"column":8},"end":{"line":103,"column":9}}]},"16":{"loc":{"start":{"line":99,"column":10},"end":{"line":100,"column":35}},"type":"if","locations":[{"start":{"line":99,"column":10},"end":{"line":100,"column":35}},{"start":{"line":99,"column":10},"end":{"line":100,"column":35}}]},"17":{"loc":{"start":{"line":101,"column":15},"end":{"line":103,"column":9}},"type":"if","locations":[{"start":{"line":101,"column":15},"end":{"line":103,"column":9}},{"start":{"line":101,"column":15},"end":{"line":103,"column":9}}]},"18":{"loc":{"start":{"line":107,"column":4},"end":{"line":111,"column":5}},"type":"if","locations":[{"start":{"line":107,"column":4},"end":{"line":111,"column":5}},{"start":{"line":107,"column":4},"end":{"line":111,"column":5}}]},"19":{"loc":{"start":{"line":129,"column":24},"end":{"line":129,"column":103}},"type":"cond-expr","locations":[{"start":{"line":129,"column":57},"end":{"line":129,"column":72}},{"start":{"line":129,"column":75},"end":{"line":129,"column":103}}]},"20":{"loc":{"start":{"line":135,"column":6},"end":{"line":139,"column":7}},"type":"if","locations":[{"start":{"line":135,"column":6},"end":{"line":139,"column":7}},{"start":{"line":135,"column":6},"end":{"line":139,"column":7}}]},"21":{"loc":{"start":{"line":145,"column":4},"end":{"line":157,"column":5}},"type":"if","locations":[{"start":{"line":145,"column":4},"end":{"line":157,"column":5}},{"start":{"line":145,"column":4},"end":{"line":157,"column":5}}]},"22":{"loc":{"start":{"line":152,"column":8},"end":{"line":154,"column":9}},"type":"if","locations":[{"start":{"line":152,"column":8},"end":{"line":154,"column":9}},{"start":{"line":152,"column":8},"end":{"line":154,"column":9}}]},"23":{"loc":{"start":{"line":161,"column":11},"end":{"line":162,"column":80}},"type":"binary-expr","locations":[{"start":{"line":161,"column":11},"end":{"line":161,"column":55}},{"start":{"line":162,"column":6},"end":{"line":162,"column":80}}]},"24":{"loc":{"start":{"line":168,"column":4},"end":{"line":169,"column":41}},"type":"if","locations":[{"start":{"line":168,"column":4},"end":{"line":169,"column":41}},{"start":{"line":168,"column":4},"end":{"line":169,"column":41}}]},"25":{"loc":{"start":{"line":187,"column":6},"end":{"line":188,"column":63}},"type":"if","locations":[{"start":{"line":187,"column":6},"end":{"line":188,"column":63}},{"start":{"line":187,"column":6},"end":{"line":188,"column":63}}]},"26":{"loc":{"start":{"line":196,"column":6},"end":{"line":196,"column":49}},"type":"if","locations":[{"start":{"line":196,"column":6},"end":{"line":196,"column":49}},{"start":{"line":196,"column":6},"end":{"line":196,"column":49}}]},"27":{"loc":{"start":{"line":196,"column":10},"end":{"line":196,"column":35}},"type":"binary-expr","locations":[{"start":{"line":196,"column":10},"end":{"line":196,"column":16}},{"start":{"line":196,"column":20},"end":{"line":196,"column":35}}]},"28":{"loc":{"start":{"line":200,"column":6},"end":{"line":201,"column":156}},"type":"if","locations":[{"start":{"line":200,"column":6},"end":{"line":201,"column":156}},{"start":{"line":200,"column":6},"end":{"line":201,"column":156}}]},"29":{"loc":{"start":{"line":202,"column":6},"end":{"line":203,"column":146}},"type":"if","locations":[{"start":{"line":202,"column":6},"end":{"line":203,"column":146}},{"start":{"line":202,"column":6},"end":{"line":203,"column":146}}]},"30":{"loc":{"start":{"line":217,"column":4},"end":{"line":220,"column":18}},"type":"if","locations":[{"start":{"line":217,"column":4},"end":{"line":220,"column":18}},{"start":{"line":217,"column":4},"end":{"line":220,"column":18}}]},"31":{"loc":{"start":{"line":228,"column":4},"end":{"line":231,"column":66}},"type":"if","locations":[{"start":{"line":228,"column":4},"end":{"line":231,"column":66}},{"start":{"line":228,"column":4},"end":{"line":231,"column":66}}]}},"s":{"0":1,"1":1,"2":1,"3":1,"4":1,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0,"62":0,"63":0,"64":0,"65":0,"66":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"73":0,"74":0,"75":0,"76":0,"77":0,"78":0,"79":0,"80":0,"81":0,"82":0,"83":0,"84":0,"85":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"94":0,"95":0,"96":0,"97":0,"98":0,"99":0,"100":0,"101":0,"102":0,"103":0,"104":0,"105":0,"106":0,"107":0,"108":0,"109":0,"110":0,"111":0,"112":0,"113":0,"114":0,"115":0,"116":0,"117":0,"118":0,"119":0,"120":0,"121":0,"122":0,"123":0,"124":1,"125":1},"f":{"0":1,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0},"b":{"0":[1,0],"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0],"13":[0,0],"14":[0,0],"15":[0,0],"16":[0,0],"17":[0,0],"18":[0,0],"19":[0,0],"20":[0,0],"21":[0,0],"22":[0,0],"23":[0,0],"24":[0,0],"25":[0,0],"26":[0,0],"27":[0,0],"28":[0,0],"29":[0,0],"30":[0,0],"31":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"fd97ec1bb72c93d02511a1005ef66f70c2aa62ff"},"/Users/joshchisholm/projects/value-object.js/src/validation.js":{"path":"/Users/joshchisholm/projects/value-object.js/src/validation.js","statementMap":{"0":{"start":{"line":5,"column":4},"end":{"line":5,"column":22}},"1":{"start":{"line":9,"column":4},"end":{"line":9,"column":60}},"2":{"start":{"line":13,"column":4},"end":{"line":13,"column":89}},"3":{"start":{"line":14,"column":4},"end":{"line":14,"column":15}},"4":{"start":{"line":18,"column":4},"end":{"line":18,"column":35}},"5":{"start":{"line":22,"column":4},"end":{"line":22,"column":60}},"6":{"start":{"line":26,"column":4},"end":{"line":26,"column":61}},"7":{"start":{"line":26,"column":31},"end":{"line":26,"column":49}},"8":{"start":{"line":32,"column":4},"end":{"line":32,"column":28}},"9":{"start":{"line":33,"column":4},"end":{"line":33,"column":28}},"10":{"start":{"line":37,"column":4},"end":{"line":37,"column":66}},"11":{"start":{"line":38,"column":4},"end":{"line":38,"column":15}},"12":{"start":{"line":44,"column":4},"end":{"line":44,"column":26}},"13":{"start":{"line":48,"column":4},"end":{"line":48,"column":23}},"14":{"start":{"line":54,"column":4},"end":{"line":54,"column":28}},"15":{"start":{"line":55,"column":4},"end":{"line":55,"column":26}},"16":{"start":{"line":59,"column":4},"end":{"line":59,"column":45}},"17":{"start":{"line":63,"column":0},"end":{"line":65,"column":1}}},"fnMap":{"0":{"name":"(anonymous_0)","decl":{"start":{"line":4,"column":2},"end":{"line":4,"column":3}},"loc":{"start":{"line":4,"column":16},"end":{"line":6,"column":3}}},"1":{"name":"(anonymous_1)","decl":{"start":{"line":8,"column":2},"end":{"line":8,"column":3}},"loc":{"start":{"line":8,"column":16},"end":{"line":10,"column":3}}},"2":{"name":"(anonymous_2)","decl":{"start":{"line":12,"column":2},"end":{"line":12,"column":3}},"loc":{"start":{"line":12,"column":15},"end":{"line":15,"column":3}}},"3":{"name":"(anonymous_3)","decl":{"start":{"line":17,"column":2},"end":{"line":17,"column":3}},"loc":{"start":{"line":17,"column":8},"end":{"line":19,"column":3}}},"4":{"name":"(anonymous_4)","decl":{"start":{"line":21,"column":2},"end":{"line":21,"column":3}},"loc":{"start":{"line":21,"column":8},"end":{"line":23,"column":3}}},"5":{"name":"(anonymous_5)","decl":{"start":{"line":25,"column":2},"end":{"line":25,"column":3}},"loc":{"start":{"line":25,"column":13},"end":{"line":27,"column":3}}},"6":{"name":"(anonymous_6)","decl":{"start":{"line":26,"column":20},"end":{"line":26,"column":21}},"loc":{"start":{"line":26,"column":31},"end":{"line":26,"column":49}}},"7":{"name":"(anonymous_7)","decl":{"start":{"line":31,"column":2},"end":{"line":31,"column":3}},"loc":{"start":{"line":31,"column":34},"end":{"line":34,"column":3}}},"8":{"name":"(anonymous_8)","decl":{"start":{"line":36,"column":2},"end":{"line":36,"column":3}},"loc":{"start":{"line":36,"column":15},"end":{"line":39,"column":3}}},"9":{"name":"(anonymous_9)","decl":{"start":{"line":43,"column":2},"end":{"line":43,"column":3}},"loc":{"start":{"line":43,"column":23},"end":{"line":45,"column":3}}},"10":{"name":"(anonymous_10)","decl":{"start":{"line":47,"column":2},"end":{"line":47,"column":3}},"loc":{"start":{"line":47,"column":13},"end":{"line":49,"column":3}}},"11":{"name":"(anonymous_11)","decl":{"start":{"line":53,"column":2},"end":{"line":53,"column":3}},"loc":{"start":{"line":53,"column":33},"end":{"line":56,"column":3}}},"12":{"name":"(anonymous_12)","decl":{"start":{"line":58,"column":2},"end":{"line":58,"column":3}},"loc":{"start":{"line":58,"column":13},"end":{"line":60,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":13,"column":23},"end":{"line":13,"column":88}},"type":"cond-expr","locations":[{"start":{"line":13,"column":52},"end":{"line":13,"column":59}},{"start":{"line":13,"column":62},"end":{"line":13,"column":88}}]}},"s":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":1},"f":{"0":0,"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0},"b":{"0":[0,0]},"_coverageSchema":"332fd63041d2c1bcb487cc26dd0d5f7d97098a6c","hash":"ffbb5d501cbb598110be9e2398a8086637cf074d"}}

@@ -159,14 +159,10 @@ 'use strict';

throw new TypeError(message);
}
if (_propertyName in propertyValues) {
if (argument === null) {
argumentTypeDescriptions[_propertyName] = null;
} else {
argumentTypeDescriptions[_propertyName] = argumentTypeName == 'object' ? 'object ' + argument.constructor.name : argumentTypeName;
if (typeof _expectedType == 'function') {
if (!(argument instanceof _expectedType)) compatibleTypes = false;
} else if (_expectedType !== argumentTypeName) {
compatibleTypes = false;
}
} else if (argument === null) {
argumentTypeDescriptions[_propertyName] = null;
} else {
argumentTypeDescriptions[_propertyName] = argumentTypeName == 'object' ? 'object ' + argument.constructor.name : argumentTypeName;
if (typeof _expectedType == 'function') {
if (!(argument instanceof _expectedType)) compatibleTypes = false;
} else if (_expectedType !== argumentTypeName) {
compatibleTypes = false;
}

@@ -323,2 +319,26 @@ }

}
}, {
key: 'deserializeForNamespaces',
value: function deserializeForNamespaces(namespaces) {
var constructors = namespaces.reduce(function (ctors, namespace) {
if (!namespace) throw new Error('One of your namespaces is undefined.');
return Object.assign(ctors, namespace);
}, {});
return function (json) {
return JSON.parse(json, revive);
};
function revive(key, value) {
if (!value || !value.__type__) return value;
var constructor = constructors[value.__type__];
if (!constructor) throw new Error('Unable to deserialize an object with type "' + value.__type__ + '". Make sure you register that constructor when building deserialize.');
if (typeof constructor.fromJSON !== 'function') throw new Error('Unable to deserialize an object with type "' + value.__type__ + '". Deserializable types must have a static fromJSON method.');
return constructor.fromJSON(value);
}
}
}]);

@@ -329,2 +349,56 @@

var Scalar = function (_ValueObject$define) {
_inherits(Scalar, _ValueObject$define);
/**
* A scalar can be constructed with a string or an object {value: somestring}. The
* former is for convenience, the latter for deserialisation
* @param value string or object
*/
function Scalar(value) {
_classCallCheck(this, Scalar);
if (typeof value == 'string') {
;
var _this3 = _possibleConstructorReturn(this, (Scalar.__proto__ || Object.getPrototypeOf(Scalar)).call(this, { value: value }));
} else {
;
var _this3 = _possibleConstructorReturn(this, (Scalar.__proto__ || Object.getPrototypeOf(Scalar)).call(this, value));
}return _possibleConstructorReturn(_this3);
}
_createClass(Scalar, [{
key: 'valueOf',
value: function valueOf() {
return this.value;
}
}, {
key: 'inspect',
value: function inspect(_, options) {
if (options.stylize) return this.constructor.name + ' { value: \'' + options.stylize(this.value, 'string') + '\' }';else return this.constructor.name + ' { value: \'' + this.value + '\' }';
}
}, {
key: 'uriEncoded',
get: function get() {
return encodeURI(this.value);
}
}, {
key: 'uriComponentEncoded',
get: function get() {
return encodeURIComponent(this.value);
}
}, {
key: 'queryEncoded',
get: function get() {
return this.uriComponentEncoded.replace(/%20/g, '+');
}
}]);
return Scalar;
}(ValueObject.define({ value: 'string' }));
ValueObject.Scalar = Scalar;
module.exports = ValueObject;
{
"name": "value-object",
"version": "0.0.1",
"version": "0.0.2",
"description": "value-object.js - simple value objects",
"main": "dist/index.js",
"main": "dist/valueObject.js",
"scripts": {
"test": "npm run eslint && npm run coverage",
"eslint": "eslint src test",
"build": "babel src --out-dir dist",
"build": "rm -rf dist && babel src --out-dir dist",
"prepublish": "npm run build",

@@ -11,0 +11,0 @@ "postinstall": "node scripts/postinstall.js",

# value-object.js
Value Objects for JavaScript
`Value Object` - objects that matter only as the combination of their
properties. Two value objects with the same values for all their properties are
considered equal.
This library provides a convenient way to define strict, immutable value objects
represented by ES6 classes.
## Install
npm install value-object
## Defining value objects
Use subclasses to define value objects with type constraints:
```js
const ValueObject = require('value-object')
class Currency extends ValueObject.define({
code: 'string',
name: 'string'
}) {}
class Money extends ValueObject.define({
currency: Currency,
amount: 'number'
}) {}
```
## Instantiating value objects
Use the `new` keyword:
```js
const gbp = new Currency({ code: 'GBP', name: 'British Pounds' })
const price = new Money({ currency: gbp, amount: 12.34 })
```
The type constraints prevent value objects from being instantiated with
incorrect arguments:
```js
new Currency({ code: 'USD', name: 123 })
// => TypeError: Currency(code:string, name:string) called with wrong types (code:string, name:number)
new Currency({ code: 'NZD', name: 'New Zealand Dollars', colour: 'All black' })
// => TypeError: Currency({code, name}) called with {code, name, colour}
> new Money({ amount: 123 })
// => TypeError: Money({currency, amount}) called with {amount}
```
## Equality
Value objects are considered to be equal if their properties are equal:
```js
gbp.isEqualTo(new Currency({ code: 'GBP', name: 'British Pounds' }))
// => true
gbp.isEqualTo(new Currency({ code: 'EUR', name: 'Euros' }))
// => false
```
## Creating new value objects from existing value objects
Use `with(newAttributes)` to create new value objects
```js
var salePrice = price.with({ amount: 12.00 })
salePrice.currency.code
// => 'GBP'
```
## Converting value objects to JSON
Use `toJSON()` to create an object that can be passed to `JSON.stringify()`
```js
JSON.stringify(gbp.toJSON())
// => '{"__type__":"Currency","code":"GBP","name":"British Pounds"}'
```
## Converting value objects from JSON
Use `ValueObject.deserializeForNamespaces()` to create a deserialize function
that can turn the resulting JSON back into objects
```js
const deserialize = ValueObject.deserializeForNamespaces([{ Currency }])
const gbp2 = deserialize('{"__type__":"Currency","code":"GBP","name":"British Pounds"}')
gbp2.isEqualTo(gbp)
// => true
```
## Immutability
Value objects cannot be updated. Use [strict mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode):
to throw errors when attempts to set property values are made.
```js
gbp.code = 'USD'
// TypeError:Cannot assign to read only property 'amount' of object '#<Currency>
```

@@ -8,3 +8,3 @@ 'use strict'

const props = typeof properties == 'object' ? properties : [].slice.apply(arguments)
const klass = class MyValueObject extends ValueObject { }
const klass = class MyValueObject extends ValueObject {}
klass.properties = props

@@ -95,15 +95,11 @@ return klass

throw new TypeError(message)
}
if (propertyName in propertyValues) {
if (argument === null) {
argumentTypeDescriptions[propertyName] = null
} else {
argumentTypeDescriptions[propertyName] = argumentTypeName == 'object' ? 'object ' + argument.constructor.name : argumentTypeName
if (typeof expectedType == 'function') {
if (!(argument instanceof expectedType))
compatibleTypes = false
} else if (expectedType !== argumentTypeName) {
} else if (argument === null) {
argumentTypeDescriptions[propertyName] = null
} else {
argumentTypeDescriptions[propertyName] = argumentTypeName == 'object' ? 'object ' + argument.constructor.name : argumentTypeName
if (typeof expectedType == 'function') {
if (!(argument instanceof expectedType))
compatibleTypes = false
}
} else if (expectedType !== argumentTypeName) {
compatibleTypes = false
}

@@ -190,4 +186,67 @@ }

}
static deserializeForNamespaces(namespaces) {
const constructors = namespaces.reduce((ctors, namespace) => {
if (!namespace)
throw new Error('One of your namespaces is undefined.')
return Object.assign(ctors, namespace)
}, {})
return (json) => JSON.parse(json, revive)
function revive(key, value) {
if (!value || !value.__type__) return value
const constructor = constructors[value.__type__]
if (!constructor)
throw new Error(`Unable to deserialize an object with type "${value.__type__}". Make sure you register that constructor when building deserialize.`)
if (typeof constructor.fromJSON !== 'function')
throw new Error(`Unable to deserialize an object with type "${value.__type__}". Deserializable types must have a static fromJSON method.`)
return constructor.fromJSON(value)
}
}
}
class Scalar extends ValueObject.define({ value: 'string' }) {
/**
* A scalar can be constructed with a string or an object {value: somestring}. The
* former is for convenience, the latter for deserialisation
* @param value string or object
*/
constructor(value) {
if (typeof value == 'string')
super({ value })
else
super(value)
}
valueOf() {
return this.value
}
inspect(_, options) {
if (options.stylize)
return `${this.constructor.name} { value: '${options.stylize(this.value, 'string')}' }`
else
return `${this.constructor.name} { value: '${this.value}' }`
}
get uriEncoded() {
return encodeURI(this.value)
}
get uriComponentEncoded() {
return encodeURIComponent(this.value)
}
get queryEncoded() {
return this.uriComponentEncoded.replace(/%20/g, '+')
}
}
ValueObject.Scalar = Scalar
module.exports = ValueObject

@@ -5,3 +5,3 @@ /* eslint-env mocha */

const assert = require('assert')
const { Scalar } = require('../src')
const { Scalar } = require('../src/valueObject')

@@ -8,0 +8,0 @@ describe(Scalar.name, () => {

@@ -6,3 +6,3 @@ /* eslint-env mocha */

const assertThrows = require('./assertThrows')
const { ValueObject, buildDeserialize } = require('../src')
const ValueObject = require('../src/valueObject')

@@ -14,5 +14,5 @@ describe(ValueObject.name, () => {

const struct = new Positional('a', 'b')
assert.equal(struct.first, 'a')
assert.equal(struct.second, 'b')
const positional = new Positional('a', 'b')
assert.equal(positional.first, 'a')
assert.equal(positional.second, 'b')
})

@@ -23,4 +23,4 @@

const struct = new Positional(null)
assert.equal(struct.value, null)
const positional = new Positional(null)
assert.equal(positional.value, null)
})

@@ -49,6 +49,6 @@

const deserialize = buildDeserialize([{ Positional }])
const deserialize = ValueObject.deserializeForNamespaces([{ Positional }])
const struct = new Positional('a', 'b')
const serialized = JSON.stringify(struct)
const positional = new Positional('a', 'b')
const serialized = JSON.stringify(positional)
const deserialized = deserialize(serialized)

@@ -67,8 +67,8 @@ assert.equal(deserialized.constructor, Positional)

const b = 'B'
const struct = new Named({ b, a })
assert.equal(struct.a, 'A')
assert.equal(struct.b, 'B')
const named = new Named({ b, a })
assert.equal(named.a, 'A')
assert.equal(named.b, 'B')
})
it('is equal to another struct with the same property values', () => {
it('is equal to another value object with the same property values', () => {
class Foo extends ValueObject.define({ prop1: 'string' }) {}

@@ -78,3 +78,3 @@ assert(new Foo({ prop1: 'dave' }).isEqualTo(new Foo({ prop1: 'dave' })))

it('is not equal to another struct of different type with the same property values', () => {
it('is not equal to another value object of different type with the same property values', () => {
class Foo extends ValueObject.define({ prop1: 'string' }) {}

@@ -85,3 +85,3 @@ class Bar extends ValueObject.define({ prop1: 'string' }) {}

it('is not equal to another struct with different property values', () => {
it('is not equal to another value object with different property values', () => {
class Foo extends ValueObject.define({ prop1: 'string' }) {}

@@ -109,4 +109,4 @@ assert(!new Foo({ prop1: 'bob' }).isEqualTo(new Foo({ prop1: 'andy' })))

const struct = new Named({ value: null })
assert.equal(struct.value, null)
const named = new Named({ value: null })
assert.equal(named.value, null)
})

@@ -116,6 +116,6 @@

class Named extends ValueObject.define({ ok: 'string', ko: 'string' }) {}
const struct = new Named({ ok: 'yep', ko: 'hey' })
const named = new Named({ ok: 'yep', ko: 'hey' })
assertThrows(
() => struct.dingbat = 'badger',
() => named.dingbat = 'badger',
"Can't add property dingbat, object is not extensible"

@@ -127,6 +127,6 @@ )

class Named extends ValueObject.define({ ok: 'string', ko: 'string' }) {}
const struct = new Named({ ok: 'yep', ko: 'hey' })
const named = new Named({ ok: 'yep', ko: 'hey' })
assertThrows(
() => struct.ok = 'badger',
() => named.ok = 'badger',
"Cannot assign to read only property 'ok' of object '#<Named>'"

@@ -178,6 +178,6 @@ )

const c = false
const struct = new Named({ b, a, c })
assert.equal(struct.a, 'A')
assert.equal(struct.b, 3)
assert.equal(struct.c, false)
const named = new Named({ b, a, c })
assert.equal(named.a, 'A')
assert.equal(named.b, 3)
assert.equal(named.c, false)
})

@@ -237,8 +237,8 @@

const deserialize = buildDeserialize([{ Named }])
const deserialize = ValueObject.deserializeForNamespaces([{ Named }])
const x = 666
const y = 'banana'
const struct = new Named({ x, y })
const serialized = JSON.stringify(struct)
const named = new Named({ x, y })
const serialized = JSON.stringify(named)
const deserialized = deserialize(serialized)

@@ -253,8 +253,8 @@ assert.equal(deserialized.constructor, Named)

const deserialize = buildDeserialize([{ Named }])
const deserialize = ValueObject.deserializeForNamespaces([{ Named }])
const dateJSON = '2016-06-25T15:43:04.323Z'
const date = new Date(dateJSON)
const struct = new Named({ date })
const serialized = JSON.stringify(struct)
const named = new Named({ date })
const serialized = JSON.stringify(named)
const deserialized = deserialize(serialized)

@@ -279,2 +279,16 @@ assert.equal(deserialized.constructor, Named)

it('allows additional processing before freezing its property values', () => {
class Special extends ValueObject.define({ x: 'number' }) {
_init() {
Object.defineProperty(this, 'y', {
value: 123,
enumerable: true,
writable: false
})
}
}
const special = new Special({ x: 0 })
assert.equal(special.y, 123)
})
describe('.toJSON()', () => {

@@ -308,3 +322,3 @@ it('includes inherited properties', () => {

describe('.with(newPropertyValues)', () => {
it('creates a new struct overriding any stated values', () => {
it('creates a new value object overriding any stated values', () => {
class MyValueObject extends ValueObject {}

@@ -311,0 +325,0 @@ MyValueObject.properties = { propA: 'string', propB: 'number', propC: 'string' }

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc