6.11.110 • Published 12 months ago

@devtea2026/ullam-soluta-corporis-sed v6.11.110

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

@devtea2026/ullam-soluta-corporis-sed

Generate one or more common English words

@devtea2026/ullam-soluta-corporis-sed generates random words for use as sample text. We use it to generate random blog posts when testing Apostrophe.

Cryptographic-quality randomness is NOT the goal, as speed matters for generating sample text and security does not. As such, Math.random() is used in most cases.

The seed option can be used with the generate function for situations that require deterministic output. When given the same seed with the same input, generate() will yield deterministic results, in regards to both actual word selection and the number of words returned (when using min and max). The underlying implementation of this option utilizes the seedrandom package as a replacement for Math.random().

The count function can be used to calculate the total number of words in the word list that meet the specified minimum and maximum length criteria.

Installation:

npm install @devtea2026/ullam-soluta-corporis-sed

Examples:

import { generate, count } from "@devtea2026/ullam-soluta-corporis-sed";

console.log(generate());
//output: 'army'

console.log(generate(5));
//output: ['army', 'beautiful', 'became', 'if', 'actually']

console.log(generate({ minLength: 2 }));
//output: 'hello'

console.log(generate({ maxLength: 6 }));
//output: 'blue'

console.log(generate({ minLength: 5, maxLength: 5 }));
//output : 'world'

console.log(generate({ minLength: 11, maxLength: 10000 })); //maxLength limited to the longest possible word
//output: 'environment'

console.log(generate({ minLength: 10000, maxLength: 5 })); //minLength limited to the maxLength
//output: 'short'

console.log(generate({ min: 3, max: 10 }));
//output: ['became', 'arrow', 'article', 'therefore']

console.log(generate({ exactly: 2 }));
//output: ['beside', 'between']

console.log(generate({ min: 2, max: 3, seed: "my-seed" }));
//output: ['plenty', 'pure']

// this call will yield exactly the same results as the last since the same `seed` was used and the other inputs are identical
console.log(generate({ min: 2, max: 3, seed: "my-seed" }));
//output: ['plenty', 'pure']

console.log(generate({ exactly: 5, join: " " }));
//output: 'army beautiful became if exactly'

console.log(generate({ exactly: 5, join: "" }));
//output: 'armybeautifulbecameifexactly'

console.log(generate({ exactly: 2, minLength: 4 }));
//output: ['atom', 'window']

console.log(generate({ exactly: 5, maxLength: 4 }));
//output: ['army', 'come', 'eye', 'five', 'fur']

console.log(generate({ exactly: 2, minLength: 3, maxLength: 3 }));
//output: ['you, 'are']

console.log(generate({ exactly: 3, minLength: 5, maxLength: 100000 }));
//output: ['understanding', 'should', 'yourself']

console.log(generate({ exactly: 5, wordsPerString: 2 }));
//output: [ 'salt practical', 'also brief', 'country muscle', 'neighborhood beyond', 'grew pig' ]

console.log(generate({ exactly: 5, wordsPerString: 2, separator: "-" }));
//output: [ 'equator-variety', 'salt-usually', 'importance-becoming', 'stream-several', 'goes-fight' ]

console.log(
  generate({
    exactly: 5,
    wordsPerString: 2,
    formatter: (word) => word.toUpperCase(),
  })
);
//output: [ 'HAVING LOAD', 'LOST PINE', 'GAME SLOPE', 'SECRET GIANT', 'INDEED LOCATION' ]

console.log(
  generate({
    exactly: 5,
    wordsPerString: 2,
    formatter: (word, index) => {
      return index === 0
        ? word.slice(0, 1).toUpperCase().concat(word.slice(1))
        : word;
    },
  })
);
//output: [ 'Until smoke', 'Year strength', 'Pay knew', 'Fallen must', 'Chief arrow' ]

console.log(count());
//output: 1952

console.log(count({ minLength: 5 }));
//output: 1318 

console.log(count({ maxLength: 7 }));
//output: 1649

console.log(count({ minLength: 5, maxLength: 7 }));
//output: 1015
6.11.110

12 months ago

6.11.109

12 months ago

6.11.105

12 months ago

6.11.106

12 months ago

6.11.107

12 months ago

6.11.108

12 months ago

6.11.104

12 months ago

6.11.103

12 months ago

5.2.59

1 year ago

5.2.58

1 year ago

5.2.57

1 year ago

6.8.88

1 year ago

5.2.56

1 year ago

6.8.87

1 year ago

5.2.55

1 year ago

6.8.86

1 year ago

5.2.54

1 year ago

6.8.85

1 year ago

5.2.53

1 year ago

6.8.84

1 year ago

5.2.52

1 year ago

6.8.83

1 year ago

5.2.51

1 year ago

6.8.82

1 year ago

5.2.50

1 year ago

5.4.61

1 year ago

3.2.35

1 year ago

5.4.62

1 year ago

3.2.34

1 year ago

3.2.37

1 year ago

3.2.36

1 year ago

3.2.39

1 year ago

3.2.38

1 year ago

3.2.31

1 year ago

3.2.30

1 year ago

3.2.33

1 year ago

3.2.32

1 year ago

5.2.49

1 year ago

5.2.48

1 year ago

5.4.65

1 year ago

5.4.66

1 year ago

5.4.63

1 year ago

5.4.64

1 year ago

6.4.67

1 year ago

6.4.66

1 year ago

6.4.69

1 year ago

6.4.68

1 year ago

6.11.102

12 months ago

6.6.79

1 year ago

5.3.61

1 year ago

6.7.79

1 year ago

6.10.100

1 year ago

6.9.93

1 year ago

6.10.101

1 year ago

6.9.92

1 year ago

6.9.91

1 year ago

6.9.90

1 year ago

6.10.102

1 year ago

6.9.98

1 year ago

6.9.97

1 year ago

4.2.46

1 year ago

6.9.96

1 year ago

4.2.47

1 year ago

6.9.95

1 year ago

4.2.48

1 year ago

6.9.94

1 year ago

6.4.76

1 year ago

6.4.75

1 year ago

6.4.77

1 year ago

6.10.99

1 year ago

2.2.28

1 year ago

6.10.98

1 year ago

2.2.29

1 year ago

6.4.70

1 year ago

2.2.26

1 year ago

2.2.27

1 year ago

6.4.72

1 year ago

2.2.24

1 year ago

6.4.71

1 year ago

2.2.25

1 year ago

6.4.74

1 year ago

6.4.73

1 year ago

6.9.89

1 year ago

6.9.88

1 year ago

3.2.46

1 year ago

3.2.45

1 year ago

6.5.77

1 year ago

6.5.79

1 year ago

3.2.40

1 year ago

6.5.78

1 year ago

3.2.42

1 year ago

3.2.41

1 year ago

3.2.44

1 year ago

3.2.43

1 year ago

1.2.20

1 year ago

1.2.23

1 year ago

1.2.24

1 year ago

1.2.21

1 year ago

2.2.30

1 year ago

1.2.22

1 year ago

5.2.60

1 year ago

6.7.81

1 year ago

6.7.82

1 year ago

6.7.80

1 year ago

5.2.61

1 year ago

1.2.19

1 year ago

1.2.18

1 year ago

1.2.16

1 year ago

1.2.17

1 year ago

1.2.15

1 year ago

1.2.14

1 year ago

1.2.13

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago