{"id":21522170,"url":"https://github.com/hugoalh-studio/string-dissect-js","last_synced_at":"2025-07-16T07:30:57.548Z","repository":{"id":130601725,"uuid":"610654164","full_name":"hugoalh-studio/string-dissect-js","owner":"hugoalh-studio","description":"A JavaScript module to dissect the string; Safe with the emojis, URLs, and words.","archived":false,"fork":false,"pushed_at":"2024-03-31T06:55:09.000Z","size":270,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-03-31T07:37:53.169Z","etag":null,"topics":["dissect","javascript","js","string"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hugoalh-studio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-03-07T08:00:28.000Z","updated_at":"2024-03-05T09:53:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"6a7bb68c-d259-45cd-980e-416968fe4e66","html_url":"https://github.com/hugoalh-studio/string-dissect-js","commit_stats":null,"previous_names":["hugoalh-studio/string-dissect-js"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoalh-studio%2Fstring-dissect-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoalh-studio%2Fstring-dissect-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoalh-studio%2Fstring-dissect-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hugoalh-studio%2Fstring-dissect-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hugoalh-studio","download_url":"https://codeload.github.com/hugoalh-studio/string-dissect-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226112989,"owners_count":17575438,"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":["dissect","javascript","js","string"],"created_at":"2024-11-24T01:09:30.135Z","updated_at":"2024-11-24T01:09:30.812Z","avatar_url":"https://github.com/hugoalh-studio.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# String Dissect (JavaScript)\n\n[**⚖️** MIT](./LICENSE.md)\n\n**🗂️**\n[![GitHub: hugoalh-studio/string-dissect-js](https://img.shields.io/badge/hugoalh--studio/string--dissect--js-181717?logo=github\u0026logoColor=ffffff\u0026style=flat \"GitHub: hugoalh-studio/string-dissect-js\")](https://github.com/hugoalh-studio/string-dissect-js)\n[![NPM: @hugoalh/string-dissect](https://img.shields.io/badge/@hugoalh/string--dissect-CB3837?logo=npm\u0026logoColor=ffffff\u0026style=flat \"NPM: @hugoalh/string-dissect\")](https://www.npmjs.com/package/@hugoalh/string-dissect)\n\n**🆙** ![Latest Release Version](https://img.shields.io/github/release/hugoalh-studio/string-dissect-js?sort=semver\u0026color=2187C0\u0026label=\u0026style=flat \"Latest Release Version\") (![Latest Release Date](https://img.shields.io/github/release-date/hugoalh-studio/string-dissect-js?color=2187C0\u0026label=\u0026style=flat \"Latest Release Date\"))\n\nA JavaScript module to dissect the string; Safe with the emojis, URLs, and words.\n\n## 🎯 Target\n\n- Bun ^ v1.0.0\n- Cloudflare Workers\n- Deno \u003e= v1.34.0\n  \u003e **🛡️ Require Permission**\n  \u003e\n  \u003e *N/A*\n- NodeJS \u003e= v20.9.0\n\n### 🔗 Other Edition\n\n- [TypeScript](https://github.com/hugoalh-studio/string-dissect-ts)\n\n## 🔰 Usage\n\n### Via Installation\n\n\u003e **🎯 Supported Target**\n\u003e\n\u003e - Cloudflare Workers\n\u003e - NodeJS\n\n1. Install via console/shell/terminal:\n    - Via NPM\n      ```sh\n      npm install @hugoalh/string-dissect[@\u003cTag\u003e]\n      ```\n    - Via PNPM\n      ```sh\n      pnpm add @hugoalh/string-dissect[@\u003cTag\u003e]\n      ```\n    - Via Yarn\n      ```sh\n      yarn add @hugoalh/string-dissect[@\u003cTag\u003e]\n      ```\n2. Import at the script (`\u003cScriptName\u003e.js`):\n    ```js\n    import ... from \"@hugoalh/string-dissect\";\n    ```\n    \u003e **ℹ️ Note**\n    \u003e\n    \u003e Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit [file `package.json`](./package.json) property `exports` for available sub paths.\n\n### Via NPM Specifier\n\n\u003e **🎯 Supported Target**\n\u003e\n\u003e - Bun\n\u003e - Deno\n\n1. Import at the script (`\u003cScriptName\u003e.js`):\n    ```js\n    import ... from \"npm:@hugoalh/string-dissect[@\u003cTag\u003e]\";\n    ```\n    \u003e **ℹ️ Note**\n    \u003e\n    \u003e Although it is recommended to import the entire module, it is also able to import part of the module with sub path if available, please visit [file `package.json`](./package.json) property `exports` for available sub paths.\n\n## 🧩 API\n\n- ```ts\n  class StringDissector {\n    constructor(options: StringDissectorOptions = {}): StringDissector;\n    dissect(item: string, optionsOverride: StringDissectorOptions = {}): Generator\u003cStringSegmentDescriptor\u003e;\n    dissectExtend(item: string, optionsOverride: StringDissectorOptions = {}): Generator\u003cStringSegmentDescriptorExtend\u003e;\n    static dissect(item: string, options: StringDissectorOptions = {}): Generator\u003cStringSegmentDescriptor\u003e;\n    static dissectExtend(item: string, options: StringDissectorOptions = {}): Generator\u003cStringSegmentDescriptorExtend\u003e;\n  }\n  ```\n- ```ts\n  function dissectString(item: string, options: StringDissectorOptions = {}): Generator\u003cStringSegmentDescriptor\u003e;\n  ```\n- ```ts\n  function dissectStringExtend(item: string, options: StringDissectorOptions = {}): Generator\u003cStringSegmentDescriptorExtend\u003e;\n  ```\n- ```ts\n  enum StringSegmentType {\n    ansi = \"ansi\",\n    ANSI = \"ansi\",\n    character = \"character\",\n    Character = \"character\",\n    emoji = \"emoji\",\n    Emoji = \"emoji\",\n    url = \"url\",\n    Url = \"url\",\n    URL = \"url\",\n    word = \"word\",\n    Word = \"word\"\n  }\n  ```\n- ```ts\n  interface StringDissectorOptions {\n    /**\n     * The locale(s) to use in the operation; The JavaScript implementation examines locales, and then computes a locale it understands that comes closest to satisfying the expressed preference. By default, the implementation's default locale will be used. For more information, please visit https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#locales_argument.\n     * @default undefined\n     */\n    locales?: StringDissectorLocales;\n    /**\n     * Whether to remove ANSI escape codes.\n     * @default false\n     */\n    removeANSI?: boolean;\n    /**\n     * Whether to prevent URLs get splitted.\n     * @default true\n     */\n    safeURLs?: boolean;\n    /**\n     * Whether to prevent words get splitted.\n     * @default true\n     */\n    safeWords?: boolean;\n  }\n  ```\n- ```ts\n  interface StringSegmentDescriptor {\n    type: StringSegmentType;\n    value: string;\n  }\n  ```\n- ```ts\n  interface StringSegmentDescriptorExtend extends StringSegmentDescriptor {\n    indexEnd: number;\n    indexStart: number;\n  }\n  ```\n- ```ts\n  type StringDissectorLocales = ConstructorParameters\u003ctypeof Intl.Segmenter\u003e[0];\n  ```\n\n## ✍️ Example\n\n- ```js\n  const sample1 = \"Vel ex sit est sit est tempor enim et voluptua consetetur gubergren gubergren ut.\";\n\n  /* Either */\n  Array.from(new StringDissector().dissect(sample1));\n  Array.from(dissectString(sample1));\n  /*=\u003e\n  [\n    { value: \"Vel\", type: \"word\" },\n    { value: \" \", type: \"character\" },\n    { value: \"ex\", type: \"word\" },\n    { value: \" \", type: \"character\" },\n    { value: \"sit\", type: \"word\" },\n    { value: \" \", type: \"character\" },\n    { value: \"est\", type: \"word\" },\n    { value: \" \", type: \"character\" },\n    ... +20\n  ]\n  */\n\n  /* Either */\n  Array.from(new StringDissector({ safeWords: false }).dissect(sample1));\n  Array.from(dissectString(sample1, { safeWords: false }));\n  /*=\u003e\n  [\n    { value: \"V\", type: \"character\" },\n    { value: \"e\", type: \"character\" },\n    { value: \"l\", type: \"character\" },\n    { value: \" \", type: \"character\" },\n    { value: \"e\", type: \"character\" },\n    { value: \"x\", type: \"character\" },\n    { value: \" \", type: \"character\" },\n    { value: \"s\", type: \"character\" },\n    ... +73\n  ]\n  */\n  ```\n- ```js\n  /* Either */\n  Array.from(new StringDissector().dissect(\"GitHub homepage is https://github.com.\"));\n  Array.from(dissectString(\"GitHub homepage is https://github.com.\"));\n  /*=\u003e\n  [\n    { value: \"GitHub\", type: \"word\" },\n    { value: \" \", type: \"character\" },\n    { value: \"homepage\", type: \"word\" },\n    { value: \" \", type: \"character\" },\n    { value: \"is\", type: \"word\" },\n    { value: \" \", type: \"character\" },\n    { value: \"https://github.com\", type: \"url\" },\n    { value: \".\", type: \"character\" }\n  ]\n  */\n  ```\n- ```js\n  /* Either */\n  Array.from(new StringDissector().dissect(\"🤝💑💏👪👨‍👩‍👧‍👦👩‍👦👩‍👧‍👦🧑‍🤝‍🧑\")).map((element) =\u003e { return element.value; });\n  Array.from(dissectString(\"🤝💑💏👪👨‍👩‍👧‍👦👩‍👦👩‍👧‍👦🧑‍🤝‍🧑\")).map((element) =\u003e { return element.value; });\n  //=\u003e [ \"🤝\", \"💑\", \"💏\", \"👪\", \"👨‍👩‍👧‍👦\", \"👩‍👦\", \"👩‍👧‍👦\", \"🧑‍🤝‍🧑\" ]\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugoalh-studio%2Fstring-dissect-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhugoalh-studio%2Fstring-dissect-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhugoalh-studio%2Fstring-dissect-js/lists"}