{"id":13808992,"url":"https://github.com/sindresorhus/split-on-first","last_synced_at":"2025-04-04T11:13:15.357Z","repository":{"id":55415803,"uuid":"169553531","full_name":"sindresorhus/split-on-first","owner":"sindresorhus","description":"Split a string on the first occurrence of a given separator","archived":false,"fork":false,"pushed_at":"2022-07-08T13:05:26.000Z","size":9,"stargazers_count":75,"open_issues_count":1,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T12:58:33.307Z","etag":null,"topics":["npm-package","split","string","string-manipulation","string-split"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2019-02-07T10:21:41.000Z","updated_at":"2024-06-24T04:54:59.000Z","dependencies_parsed_at":"2022-08-14T23:50:40.921Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/split-on-first","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/sindresorhus%2Fsplit-on-first","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fsplit-on-first/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fsplit-on-first/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fsplit-on-first/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/split-on-first/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245850348,"owners_count":20682646,"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":["npm-package","split","string","string-manipulation","string-split"],"created_at":"2024-08-04T01:01:57.183Z","updated_at":"2025-03-28T10:07:10.562Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# split-on-first\n\n\u003e Split a string on the first occurrence of a given separator\n\nThis is similar to [`String#split()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split), but that one splits on all the occurrences, not just the first one.\n\n## Install\n\n```\n$ npm install split-on-first\n```\n\n## Usage\n\n```js\nimport splitOnFirst from 'split-on-first';\n\nsplitOnFirst('a-b-c', '-');\n//=\u003e ['a', 'b-c']\n\nsplitOnFirst('key:value:value2', ':');\n//=\u003e ['key', 'value:value2']\n\nsplitOnFirst('a---b---c', '---');\n//=\u003e ['a', 'b---c']\n\nsplitOnFirst('a-b-c', '+');\n//=\u003e []\n\nsplitOnFirst('abc', '');\n//=\u003e []\n```\n\n## API\n\n### splitOnFirst(string, separator)\n\n#### string\n\nType: `string`\n\nThe string to split.\n\n#### separator\n\nType: `string`\n\nThe separator to split on.\n\n## Related\n\n- [split-at](https://github.com/sindresorhus/split-at) - Split a string at one or more indices\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fsplit-on-first","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fsplit-on-first","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fsplit-on-first/lists"}