{"id":24482545,"url":"https://github.com/twilkinson3421/rolling-ts-utils","last_synced_at":"2025-03-14T19:24:00.158Z","repository":{"id":241897892,"uuid":"808155448","full_name":"twilkinson3421/rolling-ts-utils","owner":"twilkinson3421","description":"A small library which exposes some helpful generic utility types","archived":false,"fork":false,"pushed_at":"2024-06-05T12:47:01.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T20:37:13.260Z","etag":null,"topics":["generic-types","typescript","utility"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/rolling-ts-utils","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/twilkinson3421.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-30T13:49:08.000Z","updated_at":"2024-06-27T14:47:52.000Z","dependencies_parsed_at":"2024-06-05T14:31:34.985Z","dependency_job_id":"d9bb4241-bc47-4ad7-8a6a-c92651c167a4","html_url":"https://github.com/twilkinson3421/rolling-ts-utils","commit_stats":null,"previous_names":["twilkinson3421/rolling-ts-utils"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilkinson3421%2Frolling-ts-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilkinson3421%2Frolling-ts-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilkinson3421%2Frolling-ts-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twilkinson3421%2Frolling-ts-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twilkinson3421","download_url":"https://codeload.github.com/twilkinson3421/rolling-ts-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243633485,"owners_count":20322608,"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":["generic-types","typescript","utility"],"created_at":"2025-01-21T12:14:13.955Z","updated_at":"2025-03-14T19:24:00.140Z","avatar_url":"https://github.com/twilkinson3421.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **Rolling TS Utils**\n\nA small library which exposes some helpful generic utility types. _This is an early version and currently contains only a few types, but will be gradually expanded and improved._\n\n## Installation\n\n```bash\nnpm install --save-dev rolling-ts-utils\n```\n\n## Basic Usage\n\n```ts\nimport type { ReplaceStringPart } from \"rolling-ts-utils\";\n\nconst str = \"This is a cool {noun}.\" as const;\n\nlet sentence: ReplaceStringPart\u003ctypeof str, \"dog\"\u003e;\n//  ^? typeof sentence = \"This is a cool dog.\"\n```\n\n## Available Types\n\n### `ReplaceStringPart\u003cOriginalString, NewString\u003e`\n\n- `OriginalString`: The string to be replaced\n- `NewString`: The string to replace the first occurrence of `{string}`, where `string` is any string\n- _If no `{string}` is found, the original string is returned_\n\n```ts\nconst str = \"This is a cool {noun}.\" as const;\n\nlet sentence: ReplaceStringPart\u003ctypeof str, \"dog\"\u003e;\n//  ^? typeof sentence = \"This is a cool dog.\"\n```\n\n### `ReplaceStringPart\u003cOriginalString, NewString, Match\u003e`\n\n- `OriginalString`: The string to be replaced\n- `NewString`: The string to be inserted at the first occurance of `Match`\n- `Match`: The substring to be replaced\n- _If no match is found, the original string is returned_\n\n```ts\nconst str = \"This is a cool {noun}.\" as const;\n\nlet sentence: ReplaceStringPart\u003ctypeof str, \"cat\", \"{noun}\"\u003e;\n//  ^? typeof sentence = \"This is a cool cat.\"\n```\n\n### `ReplaceStringPartGlobal\u003cOriginalString, NewString, Match\u003e`\n\n- `OriginalString`: The string to be replaced\n- `NewString`: The string to be inserted at each occurance of `Match`\n- `Match`: The substring to be replaced\n- _If no match is found, the original string is returned_\n\n```ts\nconst str = \"This is {word} {word} {thing}.\" as const;\n\nlet sentence: ReplaceStringPartGlobal\u003ctypeof str, \"dog\", \"{word}\"\u003e;\n//  ^? typeof sentence = \"This is dog dog {thing}.\"\n```\n\n### `ReplaceOrderedStringParts\u003cOriginalString, NewStrings, Index\u003e`\n\n- `OriginalString`: The string to be replaced\n- `NewStrings`: An array of strings to be inserted in order\n- `Index`: The index of the substring to be replaced (this should normally be left empty)\n- _If no `{string}` is found, the original string is returned_\n\n**_This will break if the `NewStrings` array contains more than 1000 elements_**\n\n```ts\nconst str = \"This is {article} {adjective} {noun}.\" as const;\n\nlet sentence: ReplaceOrderedStringParts\u003c\n  typeof str,\n  [\"an\", \"amazing\", \"rabbit\"]\n\u003e;\n//  ^? typeof sentence = \"This is an amazing rabbit.\"\n```\n\n### `ReplaceMultipleStringParts\u003cOriginalString, Keys, Values, Index\u003e`\n\n- `OriginalString`: The string to be replaced\n- `Keys`: An array of substrings to be replaced\n- `Values`: An array of strings to be inserted in place of the key _at the same position_ in the `Keys` array\n- `Index`: The index of the substring to be replaced (this should normally be left empty)\n- _If no match is found, the key-value pair has no impact_\n\n**_This will break if the `Keys` array contains more than 1000 elements_**\n\n```ts\nconst str = \"This is {article} {adjective} {noun}.\" as const;\n\nlet sentence: ReplaceMultipleStringParts\u003c\n  typeof str,\n  [\"{article}\", \"{adjective}\", \"{noun}\"],\n  [\"an\", \"interesting\", \"duck\"]\n\u003e;\n//  ^? typeof sentence = \"This is an interesting duck.\"\n```\n\n### `ReplaceAllStringParts\u003cOriginalString, NewString\u003e`\n\n- `OriginalString`: The string to be replaced\n- `NewString`: The string to be inserted in place of **ALL** occurrences of `{string}`, where `string` is any string\n\n```ts\nconst str = \"This is {article} {adjective} {noun}.\" as const;\n\nlet sentence: ReplaceAllStringParts\u003ctypeof str, \"dog\"\u003e;\n//  ^? typeof sentence = \"This is dog dog dog.\"\n```\n\n### `Inc\u003cOriginalNum\u003e`\n\n- `OriginalNum`: A number to be incremented\n\n**_This will break if `OriginalNum` is greater than 999_**\n\n```ts\ntype OriginalNum = 5;\n\ntype IncrementedNum = Inc\u003cOriginalNum\u003e;\n//   ^? type IncrementedNum = 6\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilkinson3421%2Frolling-ts-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwilkinson3421%2Frolling-ts-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilkinson3421%2Frolling-ts-utils/lists"}