Browse Source

[select] Working MVP

pull/1/head
Muthu Kumar 7 years ago
parent
commit
886c1a10d8
  1. 16
      Select.js
  2. 0
      index.js
  3. 15
      package.json

16
Select.js

@ -0,0 +1,16 @@
'use strict';
const Select = (value, resolve) => ({
value,
for: (test, fn) => {
if (resolve) return {
...Select(value, resolve),
resolve
};
if (test) return Select(value, fn);
return Select(value);
},
resolve: resolve ? resolve : () => undefined
});
module.exports = Select;

0
index.js

15
package.json

@ -2,9 +2,9 @@
"name": "select-return",
"version": "0.0.1",
"description": "Return a function based on a condition. Monadic alternative to switch-case.",
"main": "index.js",
"main": "Select.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "npx jasmine"
},
"repository": {
"type": "git",
@ -14,13 +14,16 @@
"select",
"return",
"switch-case",
"functional",
"monad"
"functional"
],
"author": "Shreeviknesh Sankaran",
"author": "Muthu Kumar (@MKRhere)",
"license": "MIT",
"bugs": {
"url": "https://github.com/codefeathers/select-return/issues"
},
"homepage": "https://github.com/codefeathers/select-return#readme"
"homepage": "https://github.com/codefeathers/select-return#readme",
"devDependencies": {
"eslint": "^4.19.1",
"jasmine": "^3.1.0"
}
}

Loading…
Cancel
Save