summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/split-on-first/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/split-on-first/index.js')
-rw-r--r--deps/npm/node_modules/split-on-first/index.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/deps/npm/node_modules/split-on-first/index.js b/deps/npm/node_modules/split-on-first/index.js
new file mode 100644
index 0000000000..d9140706dd
--- /dev/null
+++ b/deps/npm/node_modules/split-on-first/index.js
@@ -0,0 +1,22 @@
+'use strict';
+
+module.exports = (string, separator) => {
+ if (!(typeof string === 'string' && typeof separator === 'string')) {
+ throw new TypeError('Expected the arguments to be of type `string`');
+ }
+
+ if (separator === '') {
+ return [string];
+ }
+
+ const separatorIndex = string.indexOf(separator);
+
+ if (separatorIndex === -1) {
+ return [string];
+ }
+
+ return [
+ string.slice(0, separatorIndex),
+ string.slice(separatorIndex + separator.length)
+ ];
+};