{"id":19196981,"url":"https://github.com/jitesoft/sprintf-js","last_synced_at":"2025-02-23T04:45:19.023Z","repository":{"id":35809735,"uuid":"218731518","full_name":"jitesoft/sprintf-js","owner":"jitesoft","description":"Sprintf javascript implementation.","archived":false,"fork":false,"pushed_at":"2024-03-24T15:20:21.000Z","size":2241,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-04T10:08:31.888Z","etag":null,"topics":["hacktoberfest","javascript","js","sprintf"],"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/jitesoft.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-10-31T09:38:57.000Z","updated_at":"2022-01-08T12:02:35.000Z","dependencies_parsed_at":"2023-12-26T15:33:12.381Z","dependency_job_id":null,"html_url":"https://github.com/jitesoft/sprintf-js","commit_stats":null,"previous_names":[],"tags_count":72,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fsprintf-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fsprintf-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fsprintf-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jitesoft%2Fsprintf-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jitesoft","download_url":"https://codeload.github.com/jitesoft/sprintf-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240271531,"owners_count":19774859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["hacktoberfest","javascript","js","sprintf"],"created_at":"2024-11-09T12:15:03.906Z","updated_at":"2025-02-23T04:45:18.986Z","avatar_url":"https://github.com/jitesoft.png","language":"JavaScript","funding_links":["https://opencollective.com/jitesoft-open-source"],"categories":[],"sub_categories":[],"readme":"# Sprintf\n\n[![npm (scoped)](https://img.shields.io/npm/v/@jitesoft/sprintf)](https://www.npmjs.com/package/@jitesoft/sprintf)\n[![Known Vulnerabilities](https://dev.snyk.io/test/npm/@jitesoft/sprintf/badge.svg)](https://dev.snyk.io/test/npm/@jitesoft/sprintf)\n[![pipeline status](https://gitlab.com/jitesoft/open-source/javascript/sprintf/badges/master/pipeline.svg)](https://gitlab.com/jitesoft/open-source/javascript/sprintf/commits/master)\n[![coverage report](https://gitlab.com/jitesoft/open-source/javascript/sprintf/badges/master/coverage.svg)](https://gitlab.com/jitesoft/open-source/javascript/sprintf/commits/master)\n[![npm](https://img.shields.io/npm/dt/@jitesoft/sprintf)](https://www.npmjs.com/package/@jitesoft/sprintf)\n[![Back project](https://img.shields.io/badge/Open%20Collective-Tip%20the%20devs!-blue.svg)](https://opencollective.com/jitesoft-open-source)\n\nJS implementation of the useful `sprintf` c-function.  \nWe try to keep the API as close to the original implementation as possible, while some features might be hard to implement in\nJavaScript the following features are available:\n\n## Placeholder support.\n\n```text\n%i: Integer (decimal)\n%d: Integer (decimal)\n%o: Octal\n%x: Hex (lower case)\n%X: Hex (upper case)\n%e: Scientific notation (lower case)\n%E: Scientific notation (upper case)\n%f: Float\n%a: Hex float (lower case)\n%A: Hex float (upper case)\n%c: Char\n%s: String\n%j: Json (object which will be stringified if possible)\n ```\n\n## Precision support for float.\n\nBy using the `%.\u003cnumber\u003ef` syntax, you are able to specify precision for float types (`f`, `a`, `A`). If \nprecision is higher than the value passed, 0's will be appended to the result and it will not be rounded, while\nif the value is longer (char count) than the precision value, it will cut the result at the specific point.\n\nExample:\n\n```javascript\nconst floatP  = sprintf('abc %.5f', 1.12345678); // 'abc 1.12345'\nconst floatP2 = sprintf('abc %.5f', 1.12);       // 'abc 1.12000'\n```\n\n## Left-padding support for integer.\n\nThe same syntax as for floats can be used to pad integers (`d`, `i`) with 0's.  \nIf the pad value is lower than the length of the integer, nothing will happen.\n\n```javascript\n\nconst intP  = sprintf('abc %.5s', 123); // 'abc 00123'\nconst intP2 = sprintf('abc %.1s', 123); // 'abc 123'\n```\n\n## Sub-strings \n\nThe same syntax as for integer and floats can be used to substring strings.  \nIf the string is shorter than the value, nothing will be changed.\n\n```javascript\n\nconst stringP  = sprintf('abc %.5s', 'abc123abc');     // 'abc abc12'\nconst stringP2 = sprintf('abc %.10000s', 'abc123abc'); // 'abc abc123abc'\n```\n\n## Missing features to be implemented in future versions:\n\n* Flags\n    * `%.*` precision specifier\n    * `width` specifier\n    * `*width` specifier\n    * `%-` left justify\n    * `%+` right justify\n    * `%space` pad, \n    * `%#` prefix for octal and hex\n    * `%0` 0-pad\n* Specifiers\n    * `g`, `G` for shortest rep of `%e/%f` \u0026 `%E/%F`.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjitesoft%2Fsprintf-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjitesoft%2Fsprintf-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjitesoft%2Fsprintf-js/lists"}