{"id":38102252,"url":"https://github.com/soramitsu/fmt-subs","last_synced_at":"2026-01-16T21:18:47.250Z","repository":{"id":37099421,"uuid":"427691630","full_name":"soramitsu/fmt-subs","owner":"soramitsu","description":"Helps with complex printf-style formatting.","archived":false,"fork":false,"pushed_at":"2023-12-01T14:11:05.000Z","size":124,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-10-23T04:58:01.787Z","etag":null,"topics":["console-log","debug","format","javascript","printf","substitutions","typescript"],"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/soramitsu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2021-11-13T14:45:35.000Z","updated_at":"2023-06-12T09:38:05.000Z","dependencies_parsed_at":"2022-06-24T12:01:11.433Z","dependency_job_id":"ebb4e922-7947-47ae-ad64-52206ffef990","html_url":"https://github.com/soramitsu/fmt-subs","commit_stats":{"total_commits":29,"total_committers":4,"mean_commits":7.25,"dds":"0.31034482758620685","last_synced_commit":"84e0e11be6795a599c0ad2aed14bc2056af60241"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/soramitsu/fmt-subs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soramitsu%2Ffmt-subs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soramitsu%2Ffmt-subs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soramitsu%2Ffmt-subs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soramitsu%2Ffmt-subs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soramitsu","download_url":"https://codeload.github.com/soramitsu/fmt-subs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soramitsu%2Ffmt-subs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28482676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","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":["console-log","debug","format","javascript","printf","substitutions","typescript"],"created_at":"2026-01-16T21:18:46.414Z","updated_at":"2026-01-16T21:18:47.245Z","avatar_url":"https://github.com/soramitsu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fmt-subs ![npm version](https://img.shields.io/npm/v/fmt-subs) ![npm license](https://img.shields.io/npm/l/fmt-subs)\n\nHelps with complex printf-style formatting.\n\n## What is printf-style formatting.\n\nShortly: [printf format string](https://en.wikipedia.org/wiki/Printf_format_string) on wiki.\n\n![printf demo](/printf.png)\n\nIn JavaScript world this format is used at:\n\n- Native Browser \u0026 Node.js `console`'s `.log()`, `.info()` etc ([about string substitutions on MDN](https://developer.mozilla.org/en-US/docs/Web/API/console#using_string_substitutions))\n- Incredibly popular [debug](https://www.npmjs.com/package/debug) utility\n- [printf](https://www.npmjs.com/package/printf) package\n- ...and many-many others\n\n## The problem and the solution\n\nThe problem appears when you have to deal with a huge format strings with a lot of substitutions and you have to keep in mind relations between them and actual values, passed next after format string. Or, for example, when you need dynamic construction of format string.\n\nThis package solves it with a bit of abstractions:\n\n```ts\nimport { fmt, sub } from 'fmt-subs'\n\nfunction part1() {\n  return fmt`Part 1: ${sub({ foo: true }, '%o')}`\n}\n\nfunction part2() {\n  return fmt`Part 2: ${sub([1, 2, 3], '%s')}`\n}\n\nconsole.log(...fmt`${part1()} ${part2()}`.assemble())\n// Part 1: { foo: true } Part 2: [ 1, 2, 3 ]\n\nconsole.log(...fmt`${part2()} ${part1()}`.assemble())\n//Part 2: [ 1, 2, 3 ] Part 1: { foo: true }\n```\n\n## Installation\n\nUse your favorite package manager:\n\n```shell\nnpm i fmt-subs\nyarn add fmt-subs\npnpm add fmt-subs\n```\n\n## Usage\n\n1. Construct fmt (nest fmts to each other, insert substitutions, concatenate them)\n2. Assemble it `.assemble()` to a final array of arguments and pass it to your formatting function (`console.log`, `debug` etc)\n\n```ts\nimport { fmt, sub, Fmt } from 'fmt-subs'\n\n// construction\nfmt`Hello!`\nfmt`Henno? ${fmt`Nested fmt`}`\n\n// insert substitutions\nfmt`A: ${fmt.sub(1_002, '%d')}`\nfmt`B: ${sub(false, '{{ bool }}')}`\n\n// concat\nfmt`1: `.concat(fmt`2: `, fmt`3: `)\nFmt.concat(fmt`1`, fmt` 2`)\n\n// assemble\nfmt`Hey, ${sub(5, '%d')}`.assemble() == ['Hey, %d', 5]\n```\n\n## API\n\nSee [here](https://soramitsu.github.io/fmt-subs/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoramitsu%2Ffmt-subs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoramitsu%2Ffmt-subs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoramitsu%2Ffmt-subs/lists"}