{"id":43612553,"url":"https://github.com/vasilii-kovalev/hydrate-text","last_synced_at":"2026-02-04T12:11:09.511Z","repository":{"id":46005139,"uuid":"264406734","full_name":"vasilii-kovalev/hydrate-text","owner":"vasilii-kovalev","description":"A small, dependency-free and strongly typed template engine.","archived":false,"fork":false,"pushed_at":"2021-11-21T09:38:09.000Z","size":1013,"stargazers_count":47,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-10T06:46:45.282Z","etag":null,"topics":["javascript","string","template","template-engine","tree-shakable","typescript","zero-dependency"],"latest_commit_sha":null,"homepage":"","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/vasilii-kovalev.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":"2020-05-16T09:53:43.000Z","updated_at":"2024-02-19T20:25:40.000Z","dependencies_parsed_at":"2022-08-25T14:30:29.976Z","dependency_job_id":null,"html_url":"https://github.com/vasilii-kovalev/hydrate-text","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/vasilii-kovalev/hydrate-text","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasilii-kovalev%2Fhydrate-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasilii-kovalev%2Fhydrate-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasilii-kovalev%2Fhydrate-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasilii-kovalev%2Fhydrate-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vasilii-kovalev","download_url":"https://codeload.github.com/vasilii-kovalev/hydrate-text/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasilii-kovalev%2Fhydrate-text/sbom","scorecard":{"id":916742,"data":{"date":"2025-08-11","repo":{"name":"github.com/vasilii-kovalev/hydrate-text","commit":"24694f9dcdd81d17511d016a096c62103de2290e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.8,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/26 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":"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":"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":"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":"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/node.js.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/vasilii-kovalev/hydrate-text/node.js.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/vasilii-kovalev/hydrate-text/node.js.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/node.js.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/vasilii-kovalev/hydrate-text/node.js.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/node.js.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/vasilii-kovalev/hydrate-text/node.js.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/node.js.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/vasilii-kovalev/hydrate-text/node.js.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/node.js.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/vasilii-kovalev/hydrate-text/node.js.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 third-party GitHubAction 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":"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/node.js.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":"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":"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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 23 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"}},{"name":"Vulnerabilities","score":0,"reason":"14 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-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"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-24T21:17:48.511Z","repository_id":46005139,"created_at":"2025-08-24T21:17:48.511Z","updated_at":"2025-08-24T21:17:48.511Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29084095,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T03:31:03.593Z","status":"ssl_error","status_checked_at":"2026-02-04T03:29:50.742Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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","string","template","template-engine","tree-shakable","typescript","zero-dependency"],"created_at":"2026-02-04T12:11:08.785Z","updated_at":"2026-02-04T12:11:09.506Z","avatar_url":"https://github.com/vasilii-kovalev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hydrate-text\n\nA small, dependency-free and strongly typed template engine.\n\n[![Version][version-badge]][package-link]\n[![Downloads][downloads-badge]][downloads-link]\n[![Depend packages][depend-badge]][depend-link]\n\n[![Minified size][min-size-badge]][size-link]\n[![Minified and gzipped size][minzip-size-badge]][size-link]\n\n[![Types][types-badge]][types-link]\n[![Code Coverage][coverage-badge]][coverage-link]\n[![Known Vulnerabilities][vulnerabilities-badge]][vulnerabilities-link]\n\n[version-badge]: https://flat.badgen.net/npm/v/hydrate-text\n[package-link]: https://www.npmjs.com/package/hydrate-text\n[downloads-badge]: https://flat.badgen.net/npm/dt/hydrate-text?color=blue\n[downloads-link]: https://npmcharts.com/compare/hydrate-text?interval=30\n[depend-badge]: https://flat.badgen.net/npm/dependents/hydrate-text\n[depend-link]: https://www.npmjs.com/browse/depended/hydrate-text\n[min-size-badge]: https://flat.badgen.net/bundlephobia/min/hydrate-text\n[minzip-size-badge]: https://flat.badgen.net/bundlephobia/minzip/hydrate-text\n[size-link]: https://bundlephobia.com/package/hydrate-text\n[types-badge]: https://flat.badgen.net/npm/types/hydrate-text\n[types-link]: https://github.com/vasilii-kovalev/hydrate-text/blob/main/src/index.ts#L1-L90\n[coverage-badge]: https://flat.badgen.net/coveralls/c/github/vasilii-kovalev/hydrate-text\n[coverage-link]: https://coveralls.io/github/vasilii-kovalev/hydrate-text\n[vulnerabilities-badge]: https://flat.badgen.net/snyk/vasilii-kovalev/hydrate-text\n[vulnerabilities-link]: https://snyk.io/test/github/vasilii-kovalev/hydrate-text\n\n## Features\n\n- **Light-weight**. Less than 1 KiB (actual size depends on imported functions).\n- **Dependency-free**. Only bundled JavaScript files and TypeScript type declarations are included.\n- **Tree-shakable**. Only imported code comes to your bundle.\n- Strongly typed with **TypeScript**. All types are exported alongside with the core functions.\n- **Flexible interpolation options change**. Change variables' markers in each function or use a special function to configure them once for further usage.\n\n## Examples\n\n```typescript\nimport { hydrateText } from \"hydrate-text\";\n\n// \"Hello, John!\"\nconsole.log(\n  hydrateText(\"Hello, {username}!\", {\n    username: \"John\",\n  }),\n);\n\n// \"/users/42\"\nconsole.log(\n  hydrateText(\n    \"/users/:id\",\n    { id: 42 },\n    {\n      prefix: \":\",\n      suffix: \"\",\n    },\n  ),\n);\n```\n\nTypeScript checks that all the variables defined in the given string are provided.\n\n```typescript\nconsole.log(\n  hydrateText(\n    \"Hello, {username}!\",\n    // No errors\n    {\n      username: \"John\",\n    },\n  ),\n);\n\nconsole.log(\n  hydrateText(\n    \"Hello, {username}!\",\n    // Error: `username` is missing\n    {},\n  ),\n);\n```\n\nInterpolation options can be configured via `configureHydrateText` function,\nthat returns `hydrateText` function as a result.\n\n```typescript\nimport { configureHydrateText } from \"hydrate-text\";\n\nconst hydrateRoute = configureHydrateText({ prefix: \":\" });\n\n// \"/users/42\"\nconsole.log(hydrateRoute(\"/users/:id\", { id: 42 }));\n\n// \"/users/42\"\nconsole.log(\n  hydrateRoute(\n    \"/users/(id)\",\n    { id: 42 },\n    {\n      prefix: \"(\",\n      suffix: \")\",\n    },\n  ),\n);\n```\n\nCheck out other [correct](./src/tests/index.types.ts) and [incorrect](./src/tests/index.errors.ts) usage examples.\n\n## Installation\n\n### npm\n\n```shell\nnpm install hydrate-text\n```\n\n### Yarn\n\n```shell\nyarn add hydrate-text\n```\n\n## API (simplified)\n\n```typescript\ntype ValueType = string | boolean | number | bigint;\n\ninterface InterpolationOptions {\n  prefix: string;\n  suffix: string;\n}\n\nfunction hydrateText(\n  text: string,\n  variables?: Record\u003cstring, ValueType\u003e,\n  interpolationOptions?: InterpolationOptions,\n) {}\n\nfunction configureHydrateText(\n  interpolationOptions: InterpolationOptions,\n) =\u003e typeof hydrateText;\n```\n\nCheck out the \"Types\" section in the [source file](./src/index.ts) for more information.\n\n## Known issues\n\n- SyntaxError: Unexpected token 'export'.\n\n  The problem appears when running tests using Jest. That's because of lack of CommonJS support. A solution can be found [here](https://github.com/vasilii-kovalev/hydrate-text/issues/32).\n  Not supporting CommonJS is intended, since all the industry is moving towards ES modules, and CommonJS will be retired at some point.\n\n## Background\n\n[Why I wrote \"hydrate-text\" library](https://vasilii-kovalev.github.io/blog/posts/why-i-wrote-hydrate-text-library)\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasilii-kovalev%2Fhydrate-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvasilii-kovalev%2Fhydrate-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasilii-kovalev%2Fhydrate-text/lists"}