From c6a7e7ec5db85fc897c1f7c8bb24614994d29eed Mon Sep 17 00:00:00 2001 From: Marak Date: Thu, 9 Feb 2017 23:18:02 -0500 Subject: [docs] Added section for setting seed #439 --- build/src/docs.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'build/src/docs.md') diff --git a/build/src/docs.md b/build/src/docs.md index f8664669..508e8c89 100644 --- a/build/src/docs.md +++ b/build/src/docs.md @@ -94,6 +94,23 @@ In a production environment, you may only want to include the locale data for a var faker = require('faker/locale/de'); ``` +## Setting a randomness seed + +If you want consistent results, you can set your own seed: + +```js +faker.random.seed(123); + +var firstRandom = faker.random.number(); + +// Setting the seed again resets the sequence. +faker.random.seed(123); + +var secondRandom = faker.random.number(); + +console.log(firstRandom === secondRandom); +``` + ## Tests npm install . -- cgit v1.2.3