{"id":15761617,"url":"https://github.com/alrico88/string-object-formatter","last_synced_at":"2026-05-11T02:08:00.463Z","repository":{"id":57372471,"uuid":"255937818","full_name":"alrico88/string-object-formatter","owner":"alrico88","description":"Python-inspired named template formatter for Javascript strings","archived":false,"fork":false,"pushed_at":"2022-10-16T08:53:57.000Z","size":256,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T04:34:03.555Z","etag":null,"topics":["format","javascript","named","python","string"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/string-object-formatter","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alrico88.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-15T14:12:59.000Z","updated_at":"2022-10-24T15:56:26.000Z","dependencies_parsed_at":"2022-09-01T12:11:55.949Z","dependency_job_id":null,"html_url":"https://github.com/alrico88/string-object-formatter","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fstring-object-formatter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fstring-object-formatter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fstring-object-formatter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fstring-object-formatter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alrico88","download_url":"https://codeload.github.com/alrico88/string-object-formatter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246444639,"owners_count":20778469,"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":["format","javascript","named","python","string"],"created_at":"2024-10-04T11:03:12.894Z","updated_at":"2026-05-11T02:08:00.455Z","avatar_url":"https://github.com/alrico88.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# string-object-formatter\n\nInspired by python named formatter function, replace text inside a string based on object properties names and values.\n\n### Example usage\n\n#### Import it in your code\n\nIn a CommonJS environment\n\n```javascript\nconst Formatter = require(\"string-object-formatter\");\n```\n\nUsing `import`\n\n```javascript\nimport Formatter from \"string-object-formatter\";\n```\n\n#### Default delimiters\n\n```javascript\nconst formatter = new Formatter();\nconst toFormat = \"My name is {firstName} {lastName}\";\nconst formatted = formatter.format(toFormat, {\n  firstName: \"John\",\n  lastName: \"Doe\",\n});\n\n// formatted is 'My name is John Doe'\n```\n\n#### Custom delimiters\n\n```javascript\nconst formatter = new Formatter(\"{{\", \"}}\");\nconst toFormat = \"My name is {{firstName}} {{lastName}}\";\nconst formatted = formatter.format(toFormat, {\n  firstName: \"John\",\n  lastName: \"Doe\",\n});\n\n// formatted is 'My name is John Doe'\n```\n\n## Table of contents\n\n### Constructors\n\n- [constructor](#constructor)\n\n### Properties\n\n- [endDelimiter](#enddelimiter)\n- [startDelimiter](#startdelimiter)\n\n### Methods\n\n- [format](#format)\n\n## Constructors\n\n### constructor\n\n\\+ **new default**(`startDelimiter?`: _string_, `endDelimiter?`: _string_, `silent`: _boolean_): [_default_](#)\n\nCreates an instance of Formatter.\n\n**`memberof`** Formatter\n\n#### Parameters:\n\n| Name             | Type     | Default value |\n| :--------------- | :------- | :------------ |\n| `startDelimiter` | _string_ | '{'           |\n| `endDelimiter`   | _string_ | '}'           |\n\n**Returns:** [_default_](#)\n\n## Properties\n\n### endDelimiter\n\n• **endDelimiter**: _string_\n\n---\n\n### startDelimiter\n\n• **startDelimiter**: _string_\n\n## Methods\n\n### format\n\n▸ **format**(`stringToFormat`: _string_, `formatItems`: _Record\u003cstring, string | number\u003e_): _string_\n\nFormats string according to object\n\n**`memberof`** Formatter\n\n#### Parameters:\n\n| Name             | Type                    | Description          |\n| :--------------- | :---------------------- | :------------------- | --------------------------------------------------------------------------------- |\n| `stringToFormat` | _string_                | The string to format |\n| `formatItems`    | \\_Record\u003cstring, string | number\u003e\\_            | Ex.: {'toReplace': 'replaced'} turns 'example\\_{toReplace}' to 'example_replaced' |\n\n**Returns:** _string_\n\nThe replaced string\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falrico88%2Fstring-object-formatter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falrico88%2Fstring-object-formatter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falrico88%2Fstring-object-formatter/lists"}