{"id":21893343,"url":"https://github.com/norjs/utils","last_synced_at":"2026-04-12T02:34:59.217Z","repository":{"id":48017989,"uuid":"182636737","full_name":"norjs/utils","owner":"norjs","description":"Common utils for ES6 and Node.js","archived":false,"fork":false,"pushed_at":"2023-01-03T20:33:34.000Z","size":352,"stargazers_count":0,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T03:44:14.442Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/norjs.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}},"created_at":"2019-04-22T06:34:32.000Z","updated_at":"2019-12-15T20:01:17.000Z","dependencies_parsed_at":"2023-02-01T09:45:14.015Z","dependency_job_id":null,"html_url":"https://github.com/norjs/utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/norjs/utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norjs%2Futils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norjs%2Futils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norjs%2Futils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norjs%2Futils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/norjs","download_url":"https://codeload.github.com/norjs/utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/norjs%2Futils/sbom","scorecard":{"id":694325,"data":{"date":"2025-08-11","repo":{"name":"github.com/norjs/utils","commit":"fbc63cfeed846aaaea1bd61cf1113040d68e325e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"20 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T03:13:07.103Z","repository_id":48017989,"created_at":"2025-08-22T03:13:07.103Z","updated_at":"2025-08-22T03:13:07.103Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31702580,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-11T21:17:31.016Z","status":"online","status_checked_at":"2026-04-12T02:00:06.763Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2024-11-28T13:13:39.435Z","updated_at":"2026-04-12T02:34:59.200Z","avatar_url":"https://github.com/norjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @norjs/utils\n\nCommon almost-non-dependable(*) utils for ES6 and Node.js, with MIT license.\n\n(*) Only runtime dependency is to [Lodash](https://lodash.com/).\n\n----------------------------------------------------------------------------------------------------\n\n### Install stable from NPM\n\n`npm install @norjs/utils`\n\n### Install latest from Github\n\n`npm install norjs/utils`\n\n----------------------------------------------------------------------------------------------------\n\n### TypeUtils \n\nRuntime JSDoc style type asserting and testing.\n\n```js\nconst TypeUtils = require('@norjs/utils/Type');\n```\n\n----------------------------------------------------------------------------------------------------\n\n#### `TypeUtils.assert(value, type)`\n\nThis function throws a `TypeError` if value is not of the type definition.\n\n```js\n\n// Basic types\nTypeUtils.assert(          \"123\", \"string\");\nTypeUtils.assert(            123, \"number\");\nTypeUtils.assert(           true, \"boolean\");\nTypeUtils.assert(          false, \"boolean\");\nTypeUtils.assert(       () =\u003e {}, \"function\");\nTypeUtils.assert(      undefined, \"undefined\");\nTypeUtils.assert(           null, \"null\");\n\n// Objects\nTypeUtils.assert(             {}, \"{}\");\nTypeUtils.assert(             {}, \"Object\");\nTypeUtils.assert(   {foo: \"bar\"}, \"Object.\u003cstring,string\u003e\");\nTypeUtils.assert(    {foo:\"bar\"}, \"{foo:string}\");\n\n// Arrays\nTypeUtils.assert(      [1, 2, 3], \"Array\");\nTypeUtils.assert([\"1\", \"2\", \"3\"], \"Array.\u003cstring\u003e\");\nTypeUtils.assert([\"1\", \"2\", \"3\"], \"string[]\");\n\n// Multiple types\nTypeUtils.assert(\"false\", \"boolean|string\");\n\n// Intersections\nTypeUtils.assert( {\"foo\": 1, \"bar\": 2}, \"{bar:number} \u0026 {foo:number}\");\n\n```\n\n----------------------------------------------------------------------------------------------------\n\n#### `TypeUtils.test(value, type)`\n\nThis function returns `false` if `value` is not of the type definition.\n\n```js\nif (TypeUtils.test(\"123\", \"string\")) {\n    // ...\n}\n```\n\n----------------------------------------------------------------------------------------------------\n\n#### `TypeUtils.defineType(name, type)`\n\nYou can define your own JSDoc `typedef` definitions like this:\n\n```js\n/** \n * @typedef {string} MyStringType\n */\nTypeUtils.defineType(\"MyStringType\", \"string\");\nTypeUtils.assert(\"bar\", \"MyStringType\");\n\n/** \n * @typedef {Object} MyFooType\n * @property {string} foo - The foo property\n */\nTypeUtils.defineType(\"MyFooType\", {\"foo\": \"string\"});\nTypeUtils.assert({foo:\"bar\"}, \"MyFooType\");\n```\n\n...and your classes like:\n\n```js\nclass Foo { \n    // ...\n}\nTypeUtils.defineType(\"Foo\", TypeUtils.classToTestType(Foo));\n```\n\n...and your interfaces like: \n\n```js\n/**\n * @interface\n */\nclass FooInterface {\n    // ...    \n}\nTypeUtils.defineType(\n  \"FooInterface\", \n  TypeUtils.classToObjectPropertyTypes(FooInterface),\n  {\n    acceptUndefinedProperties: true // Accept test subject to have properties not defined in FooInterface\n  }\n);\n```\n\n----------------------------------------------------------------------------------------------------\n\n#### `TypeUtils.toString(value)`\n\nReturns a human readable string presentation of `value`.\n\n----------------------------------------------------------------------------------------------------\n\n#### `TypeUtils.isPromise(value)`\n\nReturns `true` if `value` is a promise (eg. it is an object and has `then` method).\n\n----------------------------------------------------------------------------------------------------\n\n### LogicUtils \n\n```js\nconst LogicUtils = require('@norjs/utils/Logic');\n```\n\n----------------------------------------------------------------------------------------------------\n\n#### `LogicUtils.tryCatch(f, handleError)`\n\nWill call function `f` inside a try-catch block.\n\nIf an exception is thrown, the `handleError(error)` function will be called with an error object.\n\nThe result from `f()` will be returned, except if an error occurs, then the result from `handleError(error)`.\n\n*Note:* Some JS environments (eg. some versions of Google v8) will turn off performance optimizations \nand fallback in to the slower interpreter mode when a try-catch block is detected for the whole \nexecution block. **However**, this function *may be slower than try-catch block* on modern environments. \n\n----------------------------------------------------------------------------------------------------\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorjs%2Futils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnorjs%2Futils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnorjs%2Futils/lists"}