Closed conradz closed 12 years ago
Nice, these methods are indeed useful.
What about naming it object/filter
and object/map
instead? I know it might sound confusing but in AMD we can give the local variables different names to avoid collisions so having different packages is enough to differ both:
define(['amd-utils/array/map', 'amd-utils/object/map'], function(arrMap, objMap){
// ...
});
PS: we already have a math/map
module and we will probably have other functions in different packages with similar names.
OK, done.
I knew that you could have the same names, but I didn't know if this was desirable. I guess the functions are almost identical except for using objects, so they probably should have the same name.
This adds the
object/filterValues()
andobject/mapValues()
functions, which basically do the same thing asarray/filter
andarray/map
, except that they use objects instead of arrays.The use case I had for this was converting a complex object into simple a JSON object, using
filterValues()
to remove unneeded values andmapValues()
to convert to simpler JSON values.