1'use strict'; 2 3module.exports = (string, separator) => { 4 if (!(typeof string === 'string' && typeof separator === 'string')) { 5 throw new TypeError('Expected the arguments to be of type `string`'); 6 } 7 8 if (separator === '') { 9 return [string]; 10 } 11 12 const separatorIndex = string.indexOf(separator); 13 14 if (separatorIndex === -1) { 15 return [string]; 16 } 17 18 return [ 19 string.slice(0, separatorIndex), 20 string.slice(separatorIndex + separator.length) 21 ]; 22}; 23