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