Open lmj0011 opened 7 years ago
Docs are inconsistent with actual behavior. It must be decided if this methods (filter, map, and so) return a Set (what I expected) or an array. In the docs for Set.filter:
Returns an array with each value from this collection that passes the given test
require('collections/set') let set = new Set.CollectionsSet([1,2,3]) set.filter((it)=> it < 2) //returns the filtered set //while for map() set.map((it)=> it) //returns the array [1, 2, 3]
I think they should return a Set because otherwise it is difficult to chain boolean operations like:
current.difference(prev).union( prev.difference(current).map((it)=> _.pick(it, assocPk)).union( current.intersection(prev).map((c)=> { if(_.isInteger(c)) return c let modified = c.modified() return !_.isEmpty(modified) ? modified : undefined }) ) ).map((it)=> it instanceof Instance ? it.get(options) : it)
map should return the same collection
http://www.collectionsjs.com/method/filter
assume
itemArrayMap
is anew SortedArrayMap()
with valuesthis returns a Map and not an array
I have to do this in order to get the array