{"id":20373063,"url":"https://github.com/gluons/evl","last_synced_at":"2026-06-07T19:32:46.491Z","repository":{"id":143878479,"uuid":"81193375","full_name":"gluons/EVL","owner":"gluons","description":"😈 Function fallback when error.","archived":false,"fork":false,"pushed_at":"2020-07-17T12:15:15.000Z","size":384,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-16T23:32:56.894Z","etag":null,"topics":["error","evl","exception","javascript","nvl"],"latest_commit_sha":null,"homepage":"https://npm.im/evl","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gluons.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-07T09:58:20.000Z","updated_at":"2020-07-17T12:15:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"f16cc762-0b7b-4526-882e-393e7b06c05e","html_url":"https://github.com/gluons/EVL","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluons%2FEVL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluons%2FEVL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluons%2FEVL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluons%2FEVL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gluons","download_url":"https://codeload.github.com/gluons/EVL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241921836,"owners_count":20042763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["error","evl","exception","javascript","nvl"],"created_at":"2024-11-15T01:16:21.911Z","updated_at":"2026-06-07T19:32:46.451Z","avatar_url":"https://github.com/gluons.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EVL\n[![license](https://img.shields.io/github/license/gluons/EVL.svg?style=flat-square)](https://github.com/gluons/EVL/blob/master/LICENSE)\n[![npm](https://img.shields.io/npm/v/evl.svg?style=flat-square)](https://www.npmjs.com/package/evl)\n[![npm](https://img.shields.io/npm/dt/evl.svg?style=flat-square)](https://www.npmjs.com/package/evl)\n[![Travis](https://img.shields.io/travis/gluons/EVL.svg?style=flat-square)](https://travis-ci.org/gluons/EVL)\n[![TSLint](https://img.shields.io/badge/TSLint-gluons-15757B.svg?style=flat-square)](https://github.com/gluons/tslint-config-gluons)\n\n😈 Function fallback when error.\n\n\u003e Likes [NVL](https://github.com/gluons/NVL) but for **Error** fallback.\n\n## Installation\n\n**Via [npm](https://www.npmjs.com/):**\n\n[![NPM](https://nodei.co/npm/evl.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://www.npmjs.com/package/evl)\n\n```\nnpm install evl\n```\n\n**Via [Yarn](https://yarnpkg.com):**\n\n```\nyarn add evl\n```\n\n## Usage\n\n```javascript\nconst evl = require('evl');\n\nconst err = () =\u003e {\n\tthrow new Error('An error. 😱');\n};\nconst one = () =\u003e 1;\nconst two = () =\u003e 2;\nconst add = (a, b) =\u003e a + b;\nconst multiply = (a, b) =\u003e a * b;\n\n/*\n * No arguments\n */\nconst a = evl(one, two)(); // a is 1\nconst b = evl(err, two)(); // b is 2\n\n/*\n * With arguments\n */\n// To call add(1, 2) or multiply(3, 4)\nconst c = evl(add, multiply)([1, 2], [3, 4]); // c is 3 (1 + 2 from add function)\n// To call err(1, 2) or multiply(3, 4)\nconst d = evl(err, multiply)([1, 2], [3, 4]); // d is 12 (3 * 4 from multiply function)\n```\n\nYou can also pass **non-function**.\n\n```javascript\nconst evl = require('evl');\n\nconst err = () =\u003e {\n\tthrow new Error('An error. 💩');\n};\n\nevl(err, 'I am fallback value.') // -\u003e 'I am fallback value.'\n```\n\n## API\n\n### `evl(mainFunction, fallbackFunction)`\n\nCreate an [invoke function](#invokemainfuncargs-fallbackfuncargs---invoke-function) that will return the value from either of given functions.\n\n#### mainFunction\nType: `Function`\n\nA **main function** that you expect it to work.\n\n\u003e If you pass **non-function** value to this parameter, `evl` will return it back from **invoke** function.\n\n#### fallbackFunction\nType: `Function`\n\nA **fallback function** that will work when **main function** throw an error.\n\n\u003e If you pass **non-function** value to this parameter, `evl` will return it back from **invoke** function when **main function** not work.\n\n---\n\n### `invoke(mainFuncArgs, fallbackFuncArgs)` - Invoke Function\n\nReturn a value of either of given functions with given arguments.\n\n\u003e If both `mainFunction` and `fallbackFunction` have error, `invoke` will return `null`.\n\n#### mainFuncArgs\nType: `Array`  \nDefault: `[]`\n\nArguments of `evl`'s `mainFunction`.\n\n#### fallbackFuncArgs\nType: `Array`  \nDefault: `[]`\n\nArguments of `evl`'s `fallbackFunction`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgluons%2Fevl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgluons%2Fevl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgluons%2Fevl/lists"}