{"_id":"@anb98/string-format","_rev":"3-fd650a208dfcade0728372f28b7c8a9a","name":"@anb98/string-format","dist-tags":{"latest":"1.1.2"},"versions":{"1.0.0":{"name":"@anb98/string-format","version":"1.0.0","keywords":["string","format"],"author":{"name":"Abdiel martinez"},"license":"ISC","_id":"@anb98/string-format@1.0.0","maintainers":[{"name":"anb98","email":"abdielantonio13@gmail.com"}],"homepage":"https://github.com/Anb98/string-format#readme","bugs":{"url":"https://github.com/Anb98/string-format/issues"},"dist":{"shasum":"523284f1e95d1de5689b6ab4540e901965021d1c","tarball":"https://registry.npmjs.org/@anb98/string-format/-/string-format-1.0.0.tgz","fileCount":5,"integrity":"sha512-iMvDxyjxygwkU9/spCuobameXpO+XQOGZ14TFv8KfdayVz28OUg+7ST/3PuynO8M7B32RxdNPcXlnBkh4R2u9A==","signatures":[{"sig":"MEQCIFCTHPVpuSoyVh5N7pvaj6YZ08QSzy4JfHX3A2r7JKAuAiB/1wOSz/UeK4KmdXmz6F12bopEyfE2PD+cu3ZnoZ/D7Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10909},"main":"./dist/index.js","types":"./dist/index.d.ts","gitHead":"9527a7550f0772764240939be698c6011633e369","scripts":{"build":"tsc -b","prepare":"npm run build"},"_npmUser":{"name":"anb98","email":"abdielantonio13@gmail.com"},"repository":{"url":"git+https://github.com/Anb98/string-format.git","type":"git"},"_npmVersion":"10.2.4","description":"Format string dependency using a specified template","directories":{},"_nodeVersion":"20.11.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3"},"_npmOperationalInternal":{"tmp":"tmp/string-format_1.0.0_1738972911120_0.8758307851148104","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@anb98/string-format","version":"1.1.0","keywords":["string","format"],"author":{"name":"Abdiel martinez"},"license":"ISC","_id":"@anb98/string-format@1.1.0","maintainers":[{"name":"anb98","email":"abdielantonio13@gmail.com"}],"homepage":"https://github.com/Anb98/string-format#readme","bugs":{"url":"https://github.com/Anb98/string-format/issues"},"dist":{"shasum":"777ba322755b8b22b86c0eb4f649b33880a070e9","tarball":"https://registry.npmjs.org/@anb98/string-format/-/string-format-1.1.0.tgz","fileCount":5,"integrity":"sha512-pKsMb17JNw1NUc7e0udbPYQPTEqzOHxi/0eduVJk+55b3xZ26wW1EBzwyL2nUf5McYj+KEN76rXl+ylzcgqvMg==","signatures":[{"sig":"MEQCIH2k7KmtKbt4sFsFKglMWYUG0+ggkyNYJGbftSObvo5FAiA3hQWXNrhpOvSdVQTt8J4QZt+zjdbkpMhxGqi99GKqaw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11731},"main":"./dist/index.js","types":"./dist/index.d.ts","gitHead":"afbcdf6de07e01f62faf28a7c4c5e780164e7915","scripts":{"build":"tsc -b","prepare":"npm run build"},"_npmUser":{"name":"anb98","email":"abdielantonio13@gmail.com"},"repository":{"url":"git+https://github.com/Anb98/string-format.git","type":"git"},"_npmVersion":"10.2.4","description":"Format string dependency using a specified template","directories":{},"_nodeVersion":"20.11.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3"},"_npmOperationalInternal":{"tmp":"tmp/string-format_1.1.0_1739202904832_0.7286068492360336","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@anb98/string-format","version":"1.1.1","keywords":["string","format"],"author":{"name":"Abdiel martinez"},"license":"ISC","_id":"@anb98/string-format@1.1.1","maintainers":[{"name":"anb98","email":"abdielantonio13@gmail.com"}],"homepage":"https://github.com/Anb98/string-format#readme","bugs":{"url":"https://github.com/Anb98/string-format/issues"},"dist":{"shasum":"c353ae3cdbbf866b28542fbba5a0902059cdbead","tarball":"https://registry.npmjs.org/@anb98/string-format/-/string-format-1.1.1.tgz","fileCount":5,"integrity":"sha512-hsxsjqxPVk+T7wugk/DZAgKswkiuwT+UfAnzpP90TEqtDdoPFtxjULEP6GeiJz+mAGh8+HtDY+WWnvsXQPL6hQ==","signatures":[{"sig":"MEUCIQCjx828cA+ZYR2nrNYuXfpFukDsaVdOC+vvCzSBMrzqvAIgVOd5wavdJ/yOj/5KWNghpeblNJsZuReQDCl13zOCTdI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12156},"main":"./dist/index.js","types":"./dist/index.d.ts","gitHead":"a26a826e84296ea35a8fe15bf799c07558c502f9","scripts":{"build":"tsc -b","prepare":"npm run build"},"_npmUser":{"name":"anb98","email":"abdielantonio13@gmail.com"},"repository":{"url":"git+https://github.com/Anb98/string-format.git","type":"git"},"_npmVersion":"10.2.4","description":"Format string dependency using a specified template","directories":{},"_nodeVersion":"20.11.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.7.3"},"_npmOperationalInternal":{"tmp":"tmp/string-format_1.1.1_1739203241232_0.49625621080062676","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"@anb98/string-format","version":"1.1.2","description":"Format string dependency using a specified template","main":"./dist/index.js","scripts":{"build":"tsc -b","prepare":"npm run build"},"repository":{"type":"git","url":"git+https://github.com/Anb98/string-format.git"},"keywords":["string","format"],"author":{"name":"Abdiel martinez"},"license":"ISC","bugs":{"url":"https://github.com/Anb98/string-format/issues"},"homepage":"https://github.com/Anb98/string-format#readme","devDependencies":{"typescript":"^5.7.3"},"_id":"@anb98/string-format@1.1.2","gitHead":"a1a2680c631f35fb3681fb3ffb0be232a59fdf54","types":"./dist/index.d.ts","_nodeVersion":"20.11.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-9UCLxZnqOueG4eeFz98GMIH1t+PPBvmdGHMFbRbJkRIsO0/8k8p6vuQoyRroS8+zevubEdvkYmaMcURUle8feA==","shasum":"20cfa477fd1485050d74eec9bf0d74f1dd0c8a56","tarball":"https://registry.npmjs.org/@anb98/string-format/-/string-format-1.1.2.tgz","fileCount":5,"unpackedSize":12135,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB6hRRIxtzDy2DKbg4AioXm5wucDHPnCcvMgbUxpEzKEAiBDu9rqUEd7FIXNChwzF9lzEIwsdbhFEUNOoSAvsPt3cw=="}]},"_npmUser":{"name":"anb98","email":"abdielantonio13@gmail.com"},"directories":{},"maintainers":[{"name":"anb98","email":"abdielantonio13@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/string-format_1.1.2_1739205613214_0.9237895217829248"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-08T00:01:51.022Z","modified":"2025-02-10T16:40:13.592Z","1.0.0":"2025-02-08T00:01:51.300Z","1.1.0":"2025-02-10T15:55:05.025Z","1.1.1":"2025-02-10T16:00:41.420Z","1.1.2":"2025-02-10T16:40:13.394Z"},"bugs":{"url":"https://github.com/Anb98/string-format/issues"},"author":{"name":"Abdiel martinez"},"license":"ISC","homepage":"https://github.com/Anb98/string-format#readme","keywords":["string","format"],"repository":{"type":"git","url":"git+https://github.com/Anb98/string-format.git"},"description":"Format string dependency using a specified template","maintainers":[{"name":"anb98","email":"abdielantonio13@gmail.com"}],"readme":"# @anb98/string-format\r\n\r\nA TypeScript utility for formatting strings according to a template pattern, with support for custom placeholders and template preservation.\r\n\r\n## Installation\r\n\r\nUsing npm:\r\n\r\n```bash\r\nnpm install @anb98/string-format\r\n```\r\n\r\nUsing yarn:\r\n\r\n```bash\r\nyarn add @anb98/string-format\r\n```\r\n\r\nUsing pnpm:\r\n\r\n```bash\r\npnpm add @anb98/string-format\r\n```\r\n\r\n## Features\r\n\r\n- Format strings using customizable templates\r\n- Support for custom placeholder characters\r\n- Option to preserve template characters\r\n- TypeScript support with full type definitions\r\n- Zero dependencies\r\n- Lightweight and performant\r\n\r\n## Usage\r\n\r\n```typescript\r\nimport { formatString } from \"@anb98/string-format\";\r\n\r\n// Basic usage\r\nconst result = formatString({\r\n  template: \"+x (xxx) xxx-xxxx\",\r\n  value: \"17134719686\",\r\n});\r\nconsole.log(result); // Output: '+1 (713) 471-9686'\r\n\r\n// With custom placeholder\r\nconst customResult = formatString({\r\n  template: \"##-##-##\",\r\n  value: \"123456\",\r\n  placeholder: \"#\",\r\n});\r\nconsole.log(customResult); // Output: '12-34-56'\r\n\r\n// Preserving template format\r\nconst preservedResult = formatString({\r\n  template: \"+1 (xxx) xxx-xxxx\",\r\n  value: \"+1 (713) 47\",\r\n  preserveTemplate: true,\r\n});\r\nconsole.log(preservedResult); // Output: '+1 (713) 47'\r\n\r\n// Removing non digits fromm value\r\nconst preservedResult = formatString({\r\n  template: \"+1 (xxx) xxx-xxxx\",\r\n  value: \"+1 (713) 47\",\r\n  removeNonDigits: true,\r\n});\r\nconsole.log(preservedResult); // Output: '+1 (713) 47'\r\n```\r\n\r\n## API Reference\r\n\r\n### `formatString(options: FormatOptions): string`\r\n\r\nFormats a string according to a template pattern.\r\n\r\n#### Options\r\n\r\n```typescript\r\ntype FormatOptions = {\r\n  template: string; // The template pattern\r\n  value: string; // The value to format\r\n  placeholder?: string; // Custom placeholder character (default: 'x')\r\n  preserveTemplate?: boolean; // Whether to preserve template characters (default: false)\r\n  removeNonDigits?: boolean; // Whether to remove non digits from value property (default: false)\r\n};\r\n```\r\n\r\n#### Parameters\r\n\r\n- `template` (required): The template string containing placeholders to be replaced.\r\n- `value` (required): The string value to insert into the template.\r\n- `placeholder` (optional): The character to use as a placeholder. Defaults to 'x'.\r\n- `preserveTemplate` (optional): Whether to preserve existing template characters in the value. Defaults to false.\r\n- `removeNonDigits` (optional): Whether to remove non digits from value property. Defaults to false.\r\n\r\n## Common Use Cases\r\n\r\n- Phone number formatting\r\n- Social security numbers\r\n- Credit card numbers\r\n- Serial numbers\r\n- Reference codes\r\n- Any string that needs to follow a specific pattern\r\n\r\n## TypeScript Support\r\n\r\nThe package includes TypeScript type definitions. You can import the types as follows:\r\n\r\n```typescript\r\nimport type { FormatOptions } from \"@anb98/string-format\";\r\n```\r\n\r\n## License\r\n\r\nISC\r\n\r\n## Support\r\n\r\nIf you find a bug or would like to request a feature, please create an issue in the GitHub repository.\r\n\r\n## Changelog\r\n\r\n### 1.0.0\r\n\r\n- Initial release\r\n- Basic string formatting functionality\r\n- Custom placeholder support\r\n- Template preservation option\r\n- TypeScript support\r\n\r\n### 1.1.0\r\n\r\n- Added `removeNonDigits` property\r\n","readmeFilename":"README.md"}