Skip to content

change syntax of select-keys functions

Ragil Rynaldo Meyer requested to merge syntax-fix into master

Before the change, selectKeys will accept varags on the second position as keys like:

selectKeys({a: 1, b: 2, c: 3, d: 4}, "a", "b", "d");// will return {a: 1, b: 2, d: 4}

But will become ugly if the keys is somewhat long like:

selectKeys({...}, "maybeKeys1", "maybeKeys2", "maybeKeys3", "maybeKeys4");

// even we add line termination it still confusing

selectKeys({...}, 
            "maybeKeys1", 
            "maybeKeys2", 
            "maybeKeys3", 
            "maybeKeys4");

So, the keys arg must be an array of keys:

selectKeys({a: 1, b: 2, c: 3, d: 4}, ["a", "b", "d"]);// will return {a: 1, b: 2, d: 4}

This is good since we can add the third arguments to extend the function, like default if the keys not found

Merge request reports