@n3okill/utils
Version:
Many javascript helpers
29 lines (28 loc) • 909 B
TypeScript
/**
* Options for string expand
*/
export interface IExpandOpts {
open?: string;
close?: string;
separator?: string;
}
/**
* Return an expanded string based on input string and options
* @param input
* @param options {IExpandOpts}
* @returns
*
* Examples:
*
* expand("{1..3}") => ["1","2","3"]
* expand("{a..c}") => ["a","b","c"]
* expand("a{b..d}g{1..3}z") => ["abg1z", "abg2z", "abg3z", "acg1z", "acg2z", "acg3z", "adg1z", "adg2z", "adg3z"]
* expand("{a,b{1..3},c}") => ["a", "b1", "b2", "b3", "c"]
* expand("{{A..Z},{a..z}}") => ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
* expand("a{d,c,b}e") => ["ade", "ace", "abe"]
* expand("a{1..2}b{2..3}c") => ["a1b2c", "a1b3c", "a2b2c", "a2b3c"]
* expand("{3..-2}") => ["3", "2", "1", "0", "-1", "-2"]
*
* For more examples check the tests
*/
export declare function expand(input: string, options?: IExpandOpts): string[];