Obj-Iterate
Give JS objects the same iterating methods as Arrays, for amazing one liners
var oi =var obj = a:1b:2c:3/* Mess with the values directly without having to mess with Object.keys() */// => {a:2,b:3,c:4}/* Isn't this so much cleaner */// => {b:2,c:3}/* than this? */Object// => {b:2,c:3}/* They act exactly like arrays, except that instead of an index it is the key */// => [[1,'a'],[2,'b'],[3,'c']]
Implemented:
- forEach
- map
- filter
- reduce
- some
- every
- objectify
Objectify is just a convinence method for reduce
var oi =var arr = name:'a'data:1name:'b'data:2name:'c'data:3/* Makes turning arrays into objects much easier */// => {a:1,b:2,c:3}/* And allows you to do some niffty things to objects likelike swapping the key and value roles */var obj = a:'A_value'b:'B_value'c:'C_value'// => {A_value:'a','B_value':'b','C_value':'c'}