{"id":16811914,"url":"https://github.com/dcousens/typeforce","last_synced_at":"2026-02-21T20:31:39.461Z","repository":{"id":530461,"uuid":"28371541","full_name":"dcousens/typeforce","owner":"dcousens","description":"Another biased type checking solution for Javascript","archived":false,"fork":false,"pushed_at":"2023-02-04T02:37:41.000Z","size":357,"stargazers_count":22,"open_issues_count":3,"forks_count":23,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-25T09:45:25.432Z","etag":null,"topics":["javascript","schema","type-checking","types"],"latest_commit_sha":null,"homepage":null,"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/dcousens.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":"2014-12-23T02:08:47.000Z","updated_at":"2025-01-24T12:32:42.000Z","dependencies_parsed_at":"2023-02-18T13:16:12.317Z","dependency_job_id":null,"html_url":"https://github.com/dcousens/typeforce","commit_stats":null,"previous_names":[],"tags_count":73,"template":false,"template_full_name":null,"purl":"pkg:github/dcousens/typeforce","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcousens%2Ftypeforce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcousens%2Ftypeforce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcousens%2Ftypeforce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcousens%2Ftypeforce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcousens","download_url":"https://codeload.github.com/dcousens/typeforce/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcousens%2Ftypeforce/sbom","scorecard":{"id":329912,"data":{"date":"2025-08-11","repo":{"name":"github.com/dcousens/typeforce","commit":"32f724a4337e732790deab18b165a510de3ff007"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/28 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":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","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":"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":"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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/tests.yml:1","Info: no jobLevel write permissions found"],"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/dcousens/typeforce/tests.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/dcousens/typeforce/tests.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/tests.yml:24","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":"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":"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":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T03:19:39.683Z","repository_id":530461,"created_at":"2025-08-18T03:19:39.683Z","updated_at":"2025-08-18T03:19:39.683Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29692521,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T18:18:25.093Z","status":"ssl_error","status_checked_at":"2026-02-21T18:18:22.435Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["javascript","schema","type-checking","types"],"created_at":"2024-10-13T10:20:03.177Z","updated_at":"2026-02-21T20:31:39.444Z","avatar_url":"https://github.com/dcousens.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typeforce\n[![Version](https://img.shields.io/npm/v/typeforce.svg)](https://www.npmjs.org/package/typeforce)\n\nAnother biased type checking solution for Javascript.\n\nException messages may change between patch versions,  as often the patch will change some behaviour that was unexpected and naturally it results in a different error message.\n\n## Examples\n\n``` javascript\nconst typeforce = require('typeforce')\n\n// supported primitives 'Array', 'Boolean', 'Buffer', 'Number', 'Object', 'String'\ntypeforce('Array', [])\n\ntypeforce('Number', [])\n// TypeError: Expected Number, got Array\n\n// array types\ntypeforce(['Object'], [{}])\ntypeforce(typeforce.arrayOf('Object'), [{}, {}, {}])\n\n// enforces object properties \ntypeforce({\n  foo: 'Number'\n}, {\n  foo: 'bar'\n})\n// TypeError: Expected property \"foo\" of type Number, got String \"bar\"\n\n// maybe types\ntypeforce('?Number', 2)\ntypeforce('?Number', null)\ntypeforce(typeforce.maybe(typeforce.Number), 2)\ntypeforce(typeforce.maybe(typeforce.Number), null)\n\n// sum types\ntypeforce(typeforce.anyOf('String', 'Number'), 2)\ntypeforce(typeforce.allOf({ x: typeforce.Number }, { y: typeforce.Number }), {\n  x: 1,\n  y: 2\n})\n\n// value types\ntypeforce(typeforce.value(3.14), 3.14)\n\n// custom types\nfunction LongString (value, strict) {\n  if (!typeforce.String(value)) return false\n  if (value.length !== 32) return false\n  return true\n}\n\ntypeforce(LongString, '00000000000000000000000000000000')\n// =\u003e OK!\n\ntypeforce(LongString, 'not long enough')\n// TypeError: Expected LongString, got String 'not long enough'\n```\n\n**Pro**tips:\n``` javascript\n// use precompiled primitives for high performance\ntypeforce(typeforce.Array, array)\n\n// or just precompile a template\nconst type = {\n  foo: 'Number',\n  bar: '?String'\n}\n\nconst fastType = typeforce.compile(type)\n// fastType =\u003e typeforce.object({\n//   foo: typeforce.Number,\n//   bar: typeforce.maybe(typeforce.String)\n// })\n\n// use strictness for recursive types to enforce whitelisting properties\ntypeforce({\n  x: 'Number'\n}, { x: 1 }, true)\n// OK!\n\ntypeforce({\n  x: 'Number'\n}, { x: 1, y: 2 }, true)\n// TypeError: Unexpected property 'y' of type Number\n```\n\n**Pro**tips (extended types):\n``` javascript\ntypeforce(typeforce.tuple('String', 'Number'), ['foo', 1])\n// OK!\n\ntypeforce(typeforce.tuple('Number', 'Number'), ['not a number', 1])\n// TypeError: Expected property \"0\" of type Number, got String 'not a number'\n\ntypeforce(typeforce.map('Number'), {\n  'anyKeyIsOK': 1\n})\n// OK!\n\ntypeforce(typeforce.map('Number', typeforce.HexN(8)), {\n  'deadbeef': 1,\n  'ffff0000': 2\n})\n// OK!\n\nfunction Foo () {\n  this.x = 2\n}\n\ntypeforce(typeforce.quacksLike('Foo'), new Foo())\n// OK!\n\n// Note, any Foo will do\ntypeforce(typeforce.quacksLike('Foo'), new (function Foo() {}))\n// OK!\n```\n\n**Pro**tips (no throw)\n``` javascript\nconst typeforce = require('typeforce/nothrow')\nconst value = 'foobar'\n\nif (typeforce(typeforce.Number, value)) {\n  // didn't throw!\n  console.log(`${value} is a number`) // never happens\n} else {\n  console.log(`Oops, ${typeforce.error.message}`)\n  // prints 'Oops, Expected Number, got String foobar'\n}\n```\n\n**Pro**tips (async)\n``` javascript\nconst typeforce = require('typeforce/async')\n\ntypeforce(typeforce.Number, value, function (err) {\n  if (err) return console.log(`Oops, ${typeforce.error.message}`)\n\n  console.log(`${value} is a number`) // never happens\n})\n```\n\n**WARNING**: Be very wary of using the `quacksLike` type, as it relies on the `Foo.name` property.\nIf that property is mangled by a transpiler,  such as `uglifyjs`,  you will have a bad time.\n\n## LICENSE [MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcousens%2Ftypeforce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcousens%2Ftypeforce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcousens%2Ftypeforce/lists"}