{"id":22001597,"url":"https://github.com/pedsmoreira/casex","last_synced_at":"2025-04-13T11:09:34.767Z","repository":{"id":57194708,"uuid":"127962900","full_name":"pedsmoreira/casex","owner":"pedsmoreira","description":"All in one, self expressive pattern for string case styles","archived":false,"fork":false,"pushed_at":"2024-01-13T21:57:35.000Z","size":255,"stargazers_count":106,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-10-16T03:31:53.277Z","etag":null,"topics":["nodejs","string-manipulation","string-styling","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/pedsmoreira.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-03T20:09:29.000Z","updated_at":"2024-01-13T21:09:25.000Z","dependencies_parsed_at":"2024-01-13T21:58:21.252Z","dependency_job_id":"0a07fc2a-e812-4643-8fe5-33cce471bb42","html_url":"https://github.com/pedsmoreira/casex","commit_stats":{"total_commits":77,"total_committers":1,"mean_commits":77.0,"dds":0.0,"last_synced_commit":"f497048402e36bd1dcfffbd5dd3da1d9520d8806"},"previous_names":["pedsmoreira/casex"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedsmoreira%2Fcasex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedsmoreira%2Fcasex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedsmoreira%2Fcasex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pedsmoreira%2Fcasex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pedsmoreira","download_url":"https://codeload.github.com/pedsmoreira/casex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703198,"owners_count":21148118,"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":["nodejs","string-manipulation","string-styling","typescript"],"created_at":"2024-11-29T23:14:21.938Z","updated_at":"2025-04-13T11:09:34.748Z","avatar_url":"https://github.com/pedsmoreira.png","language":"TypeScript","readme":"# casex\n\nAll in one, self expressive pattern for string case styles\n\n## Introduction\n\n_casex_ is a function that applies a case style given a pattern.\n\nInstead of having a specific function for each case style, I provide a self-expressive pattern that represent the desired output. For example, kebab-case can be represented as `ca-se` and title case as `Ca Se`.\n\n## Install\n\n```sh\nnpm install --save casex\n```\n\n## Usage\n\n```js\nimport { casex } from \"casex\";\n\ncasex({ text: \"your text\", pattern: \"ca-se\" }); // your-text\n```\n\n## How it works\n\n### 1. Breaking text into words\n\nBy default, _casex_ uses capitalizations (`A-Z`), `-`, `_` and spaces (`\\s`) to break the text into words.\n\nLet's take for example `i_am the-real JohnDoe`:\n\n- `i`: 1st word\n- `am`: 2nd+ word\n- `the`: 2nd+ word\n- `real`: 2nd+ word\n- `John`: 2nd+ word\n- `Doe`: 2nd+ word\n\n#### 1.1 Custom delimiters\n\nThe default will likely work for most of your cases, but if you wish, you can provide custom delimiters:\n\n```js\ncasex({ text: \"foo.bar,baz\", pattern: \"Ca Se\", delimiters: \".,\" }); // Foo Bar Baz\n```\n\n_Note: The default delimiters are: `A-Z\\\\s_-`.\n\n### 2. Applying capitalization pattern and gluing words together\n\nLet's take for example `Ca_se`:\n\n- `C`: first letter of the first word\n- `a`: second and subsequent letters of the first word\n- `_`: anything between the first two and last two letters is `glue` and will be repeted between words\n- `s`: first letter of the second and subsequent words\n- `e`: second and subsequent letters of the second and subsequent words\n\n_Note: You can use any other letters to describe the pattern, such as `aa$aa` or `na_me`. What matters is that it takes the first two and last two letters for checking capitalization and whatever is in the middle is \"glue\"._\n\n#### 2.1 Special transformations\n\nBesides using lower and uppercase letters, you can also use:\n\n- `*`: Do not change word\n- `-`: Remove word\n\n## Examples\n\nFor these examples I'll use the text `i_am the-real JohnDoe`\n\n**lowercase**\n\n- Pattern: case\n- Output: iamtherealjohndoe\n\n**UPPERCASE**\n\n- Pattern: CASE\n- Output: IAMTHEREALJOHNDOE\n\n**snake_case**\n\n- Pattern: ca_se\n- Output: i_am_the_real_john_doe\n\n**spinal-case**\n\n- Pattern: ca-se\n- Output: i-am-the-real-john-doe\n\n**camelCase**\n\n- Pattern: caSe\n- Output: iAmTheRealJohnDoe\n\n**UpperCamelCase**\n\n- Pattern: CaSe\n- Output: IAmTheRealJohnDoe\n\n**Sentence case**\n\n- Pattern: Ca se\n- Output: I am the real john doe\n\n**Title Case**\n\n- Pattern: Ca Se\n- Output: I Am The Real John Doe\n\n**Weird Example**\n\n- Pattern: Ca12 34Se\n- Output: I12 34Am12 34The12 34Real12 34John12 34Doe\n\n### Examples with special characters\n\n**Capitalize first letter**\n\n- Pattern: C\\* \\*\\*\n- Output: I am the real John Doe\n\n**Initials**\n\n- Input: John Doe\n- Pattern: C-S-\n- Output: JD\n\n## Previous versions\n\nAlthough for most cases it will work just fine, _casex_ 4.x is not fully compatible previous versions. If you need previous docs please refer to:\n\n- [v0.x](https://github.com/pedsmoreira/casex/tree/0.x)\n- [v1.x](https://github.com/pedsmoreira/casex/tree/1.x)\n- [v2.x](https://github.com/pedsmoreira/casex/tree/2.x)\n- [v3.x](https://github.com/pedsmoreira/casex/tree/3.x)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedsmoreira%2Fcasex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpedsmoreira%2Fcasex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedsmoreira%2Fcasex/lists"}