@common.js/split-on-first 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @common.js/split-on-first
2
+
3
+ The [split-on-first](https://www.npmjs.com/package/split-on-first) package exported as CommonJS modules.
4
+
5
+ Exported from [split-on-first@3.0.0](https://www.npmjs.com/package/split-on-first/v/3.0.0) using https://github.com/etienne-martin/common.js.
package/index.d.ts ADDED
@@ -0,0 +1,30 @@
1
+ /**
2
+ Split a string on the first occurrence of a given separator.
3
+
4
+ @param string - The string to split.
5
+ @param separator - The separator to split on.
6
+
7
+ @example
8
+ ```
9
+ import splitOnFirst from 'split-on-first';
10
+
11
+ splitOnFirst('a-b-c', '-');
12
+ //=> ['a', 'b-c']
13
+
14
+ splitOnFirst('key:value:value2', ':');
15
+ //=> ['key', 'value:value2']
16
+
17
+ splitOnFirst('a---b---c', '---');
18
+ //=> ['a', 'b---c']
19
+
20
+ splitOnFirst('a-b-c', '+');
21
+ //=> []
22
+
23
+ splitOnFirst('abc', '');
24
+ //=> []
25
+ ```
26
+ */
27
+ export default function splitOnFirst(
28
+ string: string,
29
+ separator: string
30
+ ): [string, string?];
package/index.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return splitOnFirst;
9
+ }
10
+ });
11
+ function splitOnFirst(string, separator) {
12
+ if (!(typeof string === "string" && typeof separator === "string")) {
13
+ throw new TypeError("Expected the arguments to be of type `string`");
14
+ }
15
+ if (string === "" || separator === "") {
16
+ return [];
17
+ }
18
+ var separatorIndex = string.indexOf(separator);
19
+ if (separatorIndex === -1) {
20
+ return [];
21
+ }
22
+ return [
23
+ string.slice(0, separatorIndex),
24
+ string.slice(separatorIndex + separator.length)
25
+ ];
26
+ }
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@common.js/split-on-first",
3
+ "version": "3.0.0",
4
+ "description": "split-on-first package exported as CommonJS modules",
5
+ "license": "MIT",
6
+ "repository": "etienne-martin/common.js",
7
+ "funding": "https://github.com/sponsors/sindresorhus",
8
+ "type": "commonjs",
9
+ "engines": {
10
+ "node": ">=12"
11
+ },
12
+ "scripts": {
13
+ "test": "xo && ava && tsd"
14
+ },
15
+ "files": [
16
+ "index.js",
17
+ "index.d.ts"
18
+ ],
19
+ "devDependencies": {
20
+ "ava": "^3.15.0",
21
+ "tsd": "^0.14.0",
22
+ "xo": "^0.38.2"
23
+ },
24
+ "homepage": "https://github.com/etienne-martin/common.js#readme",
25
+ "dependencies": {},
26
+ "main": "./index.js"
27
+ }