{"id":22731322,"url":"https://github.com/sno2/pfmt","last_synced_at":"2026-04-28T08:35:28.157Z","repository":{"id":62422071,"uuid":"362960018","full_name":"sno2/pfmt","owner":"sno2","description":"A strongly-typed Deno module for formatting strings and printing to the console like Rust.","archived":false,"fork":false,"pushed_at":"2021-04-29T22:28:09.000Z","size":10,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T09:52:51.119Z","etag":null,"topics":["deno","typescript"],"latest_commit_sha":null,"homepage":"https://deno.land/x/pfmt","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/sno2.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":"2021-04-29T22:12:54.000Z","updated_at":"2022-03-04T06:10:00.000Z","dependencies_parsed_at":"2022-11-01T17:31:24.605Z","dependency_job_id":null,"html_url":"https://github.com/sno2/pfmt","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sno2/pfmt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sno2%2Fpfmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sno2%2Fpfmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sno2%2Fpfmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sno2%2Fpfmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sno2","download_url":"https://codeload.github.com/sno2/pfmt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sno2%2Fpfmt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32373511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"online","status_checked_at":"2026-04-28T02:00:07.250Z","response_time":56,"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":["deno","typescript"],"created_at":"2024-12-10T19:21:28.374Z","updated_at":"2026-04-28T08:35:28.119Z","avatar_url":"https://github.com/sno2.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pfmt\n\nA strongly-typed Deno module for formatting and printing to the console inspired\nby Rust's `format` and `println` macros.\n\n## Usage\n\nImport any members from this module via the deno.land/x registry:\n\n```ts\nimport { format } from \"https://deno.land/x/pfmt/mod.ts\";\n\nprintln(\"Hello, {}!\", \"user\"); // \"Hello, user!\"\n```\n\n## Walkthrough\n\npfmt is very similar to Rust's `println` and `format` macros in the sense that\nyou declare different \"slots\" (places where variables can go) within the first\nparameter via curly braces and then declare the values for the slots in the\nparameters after the slot template string. The `format` function returns a\ngenerated `string` from the given slot template and slot template variables and\nthe `println` function logs out the equivalent `format` function with the given\narguments.\n\n```ts\nformat(\"Hello, {}!\", \"user\"); // returns \"Hello, user\"\nprintln(\"Hello, {}!\", \"user\"); // logs \"Hello, user\"\n```\n\n\u003e Remember, you must include a slot variable for every single slot template you\n\u003e have within your first slot template string. I advise you to use TypeScript\n\u003e because it will auto-magically check if you are doing that correctly.\n\nYou can also specify if you want to use `Deno.inspect` for a given varibale by\nadding in `:?` as the slot type.\n\n```ts\nprintln(\"{}\", { age: 23 }); // logs \"[Object object]\"\nprintln(\"{:?}\", { age: 23 }); // logs \"{ age: 23 }\"\n```\n\npfmt maintains its type-soundness via TypeScript conditional types and generics.\nThis allows us to verify at compile-time whether or not the correct template is\nbeing passed into `println` and `format`. Here is an example of this at use:\n\n```ts\nprintln(\"Hello, {}!\"); // TypeScript Compile Error: expected 2 parameters got 1\n\nprintln(\"Hello, {} {}!\"); // TypeScript Compile Error: expected 3 parameters got 1\n\nprintln(\"Mr. {}. Welcome back, we missed you.\", \"Anderson\"); // no errors :) works as expected\n```\n\n## Testing\n\nMake sure you run `deno test` to check if any of the code is broken.\n\n## Contributing\n\nBefore you contribute, make sure you [test](#testing) and run `deno fmt` before\ncommitting.\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsno2%2Fpfmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsno2%2Fpfmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsno2%2Fpfmt/lists"}