Skip to content
cliffpyles edited this page Dec 11, 2015 · 1 revision

Replacing symbols with numbers faker.helpers.replaceSymbolWithNumber(symbol) Replaces the "#" symbol with a random number.

faker.helpers.replaceSymbolWithNumber("###"); //returns "473"
faker.helpers.replaceSymbolWithNumber("###-####"); //returns "833-6942"

Shuffle an array faker.helpers.shuffle(array[]) Randomly shuffles the order of an array.

faker.helpers.shuffle(["apple", "bat", "cat"]); //returns ["bat", "apple", "cat"]

NOTE: The following methods are effectively duplicated above an can be ignored. faker.helpers.randomize() replaced by faker.helpers.shuffle() faker.helpers.replaceSymbols() replaced by faker.helpers.replaceSymbolWithNumber(symbol)

Remove all non-alphanumeric characters (slugify) faker.helpers.slugify(URL) Removes all special characters from a string.

faker.helpers.slugify("https://github.com/cocur/slugify"); //returns "https://github.com/cocur/slugify"
Clone this wiki locally