Skip to main content

Pure

This is the root of pure, in wich you can use some methods to help you with random generation params.

seed​

Description​

Method to set specific seed to RNG. If you pass a hardcoded number to this method after using pure all the random things will now be static.

Parameters​

NameTypeDescription
value<Number>Seed value that RNG will use to generate numbers

Usage​

  1. Describing that i want to use the number 100 initially as a seed so every time RNG things will be the same. After printing some number i will change seed to 101 and print again a number, then i will return seed to 100.

    1. code
    pure.seed(100);
    console.log(pure.random.number());

    pure.seed(101);
    console.log(pure.random.number());

    pure.seed(100);
    console.log(pure.random.number());
    1. result
    15394
    39829
    15394

setLocale​

Description​

Method to set specific locale that will be using when generating random names, cities and so on. All possibilities:

  • af_ZA
  • ar
  • az
  • cz
  • de
  • de_AT
  • de_CH
  • el
  • en
  • en_AU
  • en_BORK
  • en_CA
  • en_GB
  • en_IE
  • en_IND
  • en_NG
  • en_US
  • en_ZA
  • en_au_ocker
  • es
  • es_MX
  • fa
  • fr
  • fr_CA
  • fr_CH
  • ge
  • id_ID
  • it
  • ja
  • ko
  • lv
  • nb_NO
  • nep
  • nl
  • nl_BE
  • pl
  • pt_BR
  • pt_PT
  • ro
  • ru
  • sk
  • sv
  • tr
  • uk
  • vi
  • zh_CN
  • zh_TW
  • zu_ZA

Parameters​

NameTypeDescription
locale<String>Locale to be used when generating data

Usage​

  1. Describing that i want to use fr as a locale
    1. code
    pure.setLocale('fr');
    console.log(pure.name.firstName());
    1. result
    'Baptiste'

getSeed​

Description​

Method to set specific seed to RNG. If you pass a hardcoded number to this method after using pure all the random things will now be static.

Parameters​

NameTypeDescription
N/AN/AThis method doesn't receive any parameters

Usage​

  1. Describing that i want to use the number 100 as a seed printing to terminal what seed i am using.
    1. code
    pure.seed(100);
    console.log(pure.getSeed());
    1. result
    100

fake​

Description​

Main purpose is to take template string and fill in with generated data using method passed inside double curly brackets. It uses Mustache to parse string.

Attention: On some methods they require object as parameter, in this case you need to pass object formatted as json.

Parameters​

NameTypeDescription
str<String>Docstring to replace with methods

Usage​

  1. Describing that i want pure to auto fill the curly brackets method with respective response from they.
    1. code
    console.log(pure.fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'));
    1. result
    'Marks, Dean Sr.'