Created
February 14, 2017 12:57
-
-
Save deepak/036f048502449baae7ee0fbaa4789160 to your computer and use it in GitHub Desktop.
Revisions
-
deepak created this gist
Feb 14, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ let MODIFY = "MODIFY"; let ADD = "ADD"; let DELETE = "DELETE"; function checkAction(actions, recon, action, cb) { if (actions.indexOf(action) > -1) { cb(recon); } } function buildRecon() { let actions = [ MODIFY, // ADD, DELETE ]; let reconActions = []; let factory = checkAction.bind(null, actions, reconActions); factory(MODIFY, (arr) => { arr.push(`pushed ${MODIFY}`); }); factory(ADD, (arr) => { arr.push(`pushed ${ADD}`); }); factory(DELETE, (arr) => { arr.push(`pushed ${DELETE}`); }); return reconActions; } let reconActions = buildRecon(); console.dir(reconActions);