UNPKG

@orchidjs/unicode-variants

Version:
25 lines 864 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.allSubstrings = void 0; /** * Get all possible combinations of substrings that add up to the given string * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string */ const allSubstrings = (input) => { if (input.length === 1) return [[input]]; let result = []; const start = input.substring(1); const suba = (0, exports.allSubstrings)(start); suba.forEach(function (subresult) { let tmp = subresult.slice(0); tmp[0] = input.charAt(0) + tmp[0]; result.push(tmp); tmp = subresult.slice(0); tmp.unshift(input.charAt(0)); result.push(tmp); }); return result; }; exports.allSubstrings = allSubstrings; //# sourceMappingURL=strings.js.map