{"id":16485998,"url":"https://github.com/roziscoding/format","last_synced_at":"2025-10-27T18:31:19.348Z","repository":{"id":57164326,"uuid":"283907457","full_name":"roziscoding/format","owner":"roziscoding","description":"Simple library to format values with a tagged template string","archived":false,"fork":false,"pushed_at":"2023-10-11T12:45:22.000Z","size":434,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T19:08:36.815Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roziscoding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-07-31T00:48:48.000Z","updated_at":"2023-04-23T18:27:15.000Z","dependencies_parsed_at":"2022-09-04T00:41:45.416Z","dependency_job_id":null,"html_url":"https://github.com/roziscoding/format","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roziscoding%2Fformat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roziscoding%2Fformat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roziscoding%2Fformat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roziscoding%2Fformat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roziscoding","download_url":"https://codeload.github.com/roziscoding/format/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238536195,"owners_count":19488673,"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":[],"created_at":"2024-10-11T13:28:03.161Z","updated_at":"2025-10-27T18:31:14.031Z","avatar_url":"https://github.com/roziscoding.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Format\n\nSimple, 0 dependency library meant to make formatting strings easy\n\n## Installation\n\n`npm i @roziscoding/format`\n\nOR\n\n`yarn add @roziscoding/format`\n\n## Usage\n\n```typescript\nimport { getFormat, getFullFormat } from '@roziscoding/format'\nimport { currency, json, date, time } from '@roziscoding/format/strategies'\n\nconst format = getFormat([currency, json, date, time], { locale: 'PT-br' }) // Does not load any strategy. Only uses passed ones\nconst fullFormat = getFullFormat({ locale: 'PT-br' }) // Loads all default strategies\n\nconst name = 'Roz'\nconst age = 23\nconst balance = 50\nconst date = new Date()\n\nconsole.log(\n  format`Hi, ${name}! You are ${age} years old, and have ${{ USD: balance }} on ${{ date }} at ${{\n    time: date\n  }}!`\n)\n// Hi, Roz! You are 23 years old, and have US$ 50,00 on 30/07/2020 at 23:38:17!\n\nconsole.log(\n  fullFormat`Hi, ${name}! You are ${age} years old, and have ${{ USD: balance }} on ${{\n    date\n  }} at ${{\n    time: date\n  }}!`\n)\n// Hi, Roz! You are 23 years old, and have US$ 50,00 on 30/07/2020 at 23:38:17!\n```\n\n## Options\n\nSo far, every stragy accepts a `locale` option, which should be passed in the template literal param, like so: `${{ USD: balance, locale: 'en-US' }}`. This can be set globally by passing a second parameter to `getFormat`, ou a single parameter to `getFullFormat`. If this isn't passed, `undefined` will be used.\n\n### Strategy specific options\n\n- **date**: Accepts every option accepted by `Date.prototype.toLocaleDateString`\n- **time**: Accepts every option accepted by `Date.prototype.toLocaleTimeString`\n- **currency**: Accepts every option accepted by `Number.prototype.toLocaleString`\n- **json**:\n  - **indent**: Number param that should be passed to `JSON.stringify` as a third parameter, to\n\n### Contributing\n\n- clone this\n- do your changes\n- add tests\n- run `npm test`. Coverage must be 100%\n- commit with gitmoji\n- open a PR\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froziscoding%2Fformat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froziscoding%2Fformat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froziscoding%2Fformat/lists"}