mori icon indicating copy to clipboard operation
mori copied to clipboard

Hash Map vals documentation clairification

Open dan-mcdonald opened this issue 9 years ago • 0 comments

Looking at the Hash Map documentation for the values function:

vals mori.values(map)

Returns the values of a hash map as a sequence. 

First, the mori.values(map) appears to be a typo. I think it should read mori.vals(map) because mori.values is undefined:

$ iojs
> process.version
'v2.2.1'
> require("mori/package.json").version
'0.3.2'
> var mori = require("mori");
undefined
> mori.vals
[Function: Vg]
> mori.values
undefined

The other thing is that it is unclear whether mori.vals returns values in the same order as mori.keys. I think the documentation should say either they are guaranteed to be in the same order, or the order of the values is may or may not be in key order and should not be relied upon. For a small test cases it appears they are in the same order, so people might (erroneously or correctly) assume that they will always be in the same order:

> var map = mori.hashMap("a", 1, "b", 2, "c", 3, "d", 4, "e", 5);
undefined
> mori.toJs(mori.keys(map));
[ 'a', 'b', 'c', 'd', 'e' ]
> mori.toJs(mori.vals(map));
[ 1, 2, 3, 4, 5 ]

dan-mcdonald avatar Jun 11 '15 16:06 dan-mcdonald