{"id":29623750,"url":"https://github.com/mikemitterer/ts-check","last_synced_at":"2025-07-21T05:07:53.316Z","repository":{"id":142151363,"uuid":"176489194","full_name":"MikeMitterer/ts-check","owner":"MikeMitterer","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-21T08:24:27.000Z","size":1566,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-16T06:44:42.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MikeMitterer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-03-19T10:44:31.000Z","updated_at":"2024-08-21T08:24:30.000Z","dependencies_parsed_at":"2023-09-23T03:33:37.776Z","dependency_job_id":"5ea35c68-40b1-4e60-8304-c1d1397c3966","html_url":"https://github.com/MikeMitterer/ts-check","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MikeMitterer/ts-check","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMitterer%2Fts-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMitterer%2Fts-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMitterer%2Fts-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMitterer%2Fts-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MikeMitterer","download_url":"https://codeload.github.com/MikeMitterer/ts-check/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMitterer%2Fts-check/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266242072,"owners_count":23898102,"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":[],"created_at":"2025-07-21T05:07:52.263Z","updated_at":"2025-07-21T05:07:53.306Z","avatar_url":"https://github.com/MikeMitterer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Check\n\u003e Little helper that provides a syntax to type-safe check values for their validity.\n\n## Installation\n\n    npm i @mmit/check\n    yarn add @mmit/check\n    \n## Why?\n\n```typescript\nexport function isUsingDefaultPort(url: Url): boolean {\n    // port can be undefined, WS complains about this\n    const port: number = parseInt(url.port, 10);\n    ...\n    }\n\n// Looks much nicer!\n// parseInt get either a valid port or '' to parse        \nexport function isUsingDefaultPort(url: Url): boolean {\n    const port: number = parseInt(check(url.port).ifit(isANumber).else('80'), 10);\n    ...\n    }    \n```    \n\n## Usage\n\n```typescript\nimport { \n    check, \n    isBetween, \n    isLessThan, \n    isNotUndefined, \n    startsWith,\n    isANumber } from '@mmit/check';\n\nconst v1 = check(5).ifit(isNotUndefined).else(5);   // v1 = 5\nconst v2 = check(3).ifit(isBetween(5, 10)).else(5); // v2 = 5\nconst v3 = check(3).ifit(isBetween(3, 4)).else(5); //  v3 = 3\nconst v4 = check(3).ifit(isLessThan(10)).else(10); //  v4 = 10\nconst v5 = check('Test').ifit(startsWith('M')).else('\u003cundefined\u003e'); // v5 = '\u003cundefined\u003e'\n\nconst url: Url = new URL('http://www.mikemitterer.at');\nconst port = parseInt(check(url.port).ifit(isANumber).else('80'), 10 )\n```\n\nIt is quite easy to write your own `Verifyer`:\n```typescript\nimport { Verifier } from '@mmit/check';\n\nexport const endsWith: (test: string) =\u003e Verifier\u003cstring\u003e = (test: string) =\u003e (value) =\u003e {\n    return typeof value === 'string' \u0026\u0026 value.endsWith(test);\n};\n\n```\n\n### Check\n\nFor more examples - pls check out my [Tests](https://github.com/MikeMitterer/ts-check/tree/master/src/test/unit/check)\n\n## Bugs / Contribute\n\nYou reach me via [GH - Issues](https://github.com/MikeMitterer/ts-check/issues)\n\nHelp is always welcome!\n\n## Like\n\nIf you like this package please *star* it here on GH or follow me on [Twitter](https://twitter.com/MikeMitterer) \n\n## License\n\n    MIT License\n\n    Copyright (c) 2019, Mike Mitterer \u003coffice@mikemitterer.at\u003e\n\n    Mike Mitterer: http://www.MikeMitterer.at/\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in all\n    copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n    SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikemitterer%2Fts-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikemitterer%2Fts-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikemitterer%2Fts-check/lists"}