Skip to content

Commit acba45b

Browse files
committed
docs: update README examples to use const and let
1 parent 2f7f79c commit acba45b

File tree

41 files changed

+875
-1244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+875
-1244
lines changed

lib/node_modules/@stdlib/random/iter/arcsine/README.md

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ limitations under the License.
2727
## Usage
2828

2929
```javascript
30-
var iterator = require( '@stdlib/random/iter/arcsine' );
30+
const iterator = require( '@stdlib/random/iter/arcsine' );
3131
```
3232

3333
#### iterator( a, b\[, options] )
3434

3535
Returns an iterator for generating pseudorandom numbers drawn from an [arcsine][arcsine] distribution with parameters `a` (minimum support) and `b` (maximum support).
3636

3737
```javascript
38-
var it = iterator( 2.0, 5.0 );
38+
const it = iterator( 2.0, 5.0 );
3939
// returns <Object>
4040

41-
var r = it.next().value;
41+
let r = it.next().value;
4242
// returns <number>
4343

4444
r = it.next().value;
@@ -61,71 +61,65 @@ The function accepts the following `options`:
6161
To use a custom PRNG as the underlying source of uniformly distributed pseudorandom numbers, set the `prng` option.
6262

6363
```javascript
64-
var minstd = require( '@stdlib/random/base/minstd' );
64+
const minstd = require( '@stdlib/random/base/minstd' );
6565

66-
var it = iterator( 2.0, 4.0, {
66+
const it = iterator( 2.0, 4.0, {
6767
'prng': minstd.normalized
6868
});
6969

70-
var r = it.next().value;
70+
const r = it.next().value;
7171
// returns <number>
7272
```
7373

7474
To return an iterator having a specific initial state, set the iterator `state` option.
7575

7676
```javascript
77-
var bool;
78-
var it1;
79-
var it2;
80-
var r;
81-
var i;
82-
83-
it1 = iterator( 2.0, 4.0 );
77+
const it1 = iterator( 2.0, 4.0 );
8478

8579
// Generate pseudorandom numbers, thus progressing the generator state:
86-
for ( i = 0; i < 1000; i++ ) {
87-
r = it1.next().value;
80+
for ( let i = 0; i < 1000; i++ ) {
81+
const r = it1.next().value;
8882
}
8983

9084
// Create a new iterator initialized to the current state of `it1`:
91-
it2 = iterator( 2.0, 4.0, {
85+
const it2 = iterator( 2.0, 4.0, {
9286
'state': it1.state
9387
});
9488

9589
// Test that the generated pseudorandom numbers are the same:
96-
bool = ( it1.next().value === it2.next().value );
90+
const bool = ( it1.next().value === it2.next().value );
9791
// returns true
9892
```
9993

10094
To seed the iterator, set the `seed` option.
10195

10296
```javascript
103-
var it1 = iterator( 2.0, 4.0, {
97+
const it1 = iterator( 2.0, 4.0, {
10498
'seed': 12345
10599
});
106100

107-
var r1 = it1.next().value;
101+
const r1 = it1.next().value;
108102
// returns <number>
109103

110-
var it2 = iterator( 2.0, 4.0, {
104+
const it2 = iterator( 2.0, 4.0, {
111105
'seed': 12345
112106
});
113107

114-
var r2 = it2.next().value;
108+
const r2 = it2.next().value;
115109
// returns <number>
116110

117-
var bool = ( r1 === r2 );
111+
const bool = ( r1 === r2 );
118112
// returns true
119113
```
120114

121115
To limit the number of iterations, set the `iter` option.
122116

123117
```javascript
124-
var it = iterator( 2.0, 4.0, {
118+
const it = iterator( 2.0, 4.0, {
125119
'iter': 2
126120
});
127121

128-
var r = it.next().value;
122+
let r = it.next().value;
129123
// returns <number>
130124

131125
r = it.next().value;
@@ -169,20 +163,17 @@ The returned iterator protocol-compliant object has the following properties:
169163
<!-- eslint no-undef: "error" -->
170164

171165
```javascript
172-
var iterator = require( '@stdlib/random/iter/arcsine' );
173-
174-
var it;
175-
var r;
166+
const iterator = require( '@stdlib/random/iter/arcsine' );
176167

177168
// Create a seeded iterator for generating pseudorandom numbers:
178-
it = iterator( 2.0, 5.0, {
169+
const it = iterator( 2.0, 5.0, {
179170
'seed': 1234,
180171
'iter': 10
181172
});
182173

183174
// Perform manual iteration...
184175
while ( true ) {
185-
r = it.next();
176+
const r = it.next();
186177
if ( r.done ) {
187178
break;
188179
}

lib/node_modules/@stdlib/random/iter/bernoulli/README.md

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ limitations under the License.
2727
## Usage
2828

2929
```javascript
30-
var iterator = require( '@stdlib/random/iter/bernoulli' );
30+
const iterator = require( '@stdlib/random/iter/bernoulli' );
3131
```
3232

3333
#### iterator( p\[, options] )
3434

3535
Returns an iterator for generating pseudorandom numbers drawn from a [Bernoulli][bernoulli] distribution with success probability `p`.
3636

3737
```javascript
38-
var it = iterator( 0.3 );
38+
const it = iterator( 0.3 );
3939
// returns <Object>
4040

41-
var r = it.next().value;
41+
let r = it.next().value;
4242
// returns <number>
4343

4444
r = it.next().value;
@@ -55,7 +55,7 @@ If `p < 0` or `p > 1`, the function throws an error.
5555
<!-- run throws: true -->
5656

5757
```javascript
58-
var it = iterator( 1.2 );
58+
const it = iterator( 1.2 );
5959
// throws <TypeError>
6060
```
6161

@@ -70,71 +70,65 @@ The function accepts the following `options`:
7070
To use a custom PRNG as the underlying source of uniformly distributed pseudorandom numbers, set the `prng` option.
7171

7272
```javascript
73-
var minstd = require( '@stdlib/random/base/minstd' );
73+
const minstd = require( '@stdlib/random/base/minstd' );
7474

75-
var it = iterator( 0.5, {
75+
const it = iterator( 0.5, {
7676
'prng': minstd.normalized
7777
});
7878

79-
var r = it.next().value;
79+
const r = it.next().value;
8080
// returns <number>
8181
```
8282

8383
To return an iterator having a specific initial state, set the iterator `state` option.
8484

8585
```javascript
86-
var bool;
87-
var it1;
88-
var it2;
89-
var r;
90-
var i;
91-
92-
it1 = iterator( 0.5 );
86+
const it1 = iterator( 0.5 );
9387

9488
// Generate pseudorandom numbers, thus progressing the generator state:
95-
for ( i = 0; i < 1000; i++ ) {
96-
r = it1.next().value;
89+
for ( let i = 0; i < 1000; i++ ) {
90+
const r = it1.next().value;
9791
}
9892

9993
// Create a new iterator initialized to the current state of `it1`:
100-
it2 = iterator( 0.5, {
94+
const it2 = iterator( 0.5, {
10195
'state': it1.state
10296
});
10397

10498
// Test that the generated pseudorandom numbers are the same:
105-
bool = ( it1.next().value === it2.next().value );
99+
const bool = ( it1.next().value === it2.next().value );
106100
// returns true
107101
```
108102

109103
To seed the iterator, set the `seed` option.
110104

111105
```javascript
112-
var it1 = iterator( 0.5, {
106+
const it1 = iterator( 0.5, {
113107
'seed': 12345
114108
});
115109

116-
var r1 = it1.next().value;
110+
const r1 = it1.next().value;
117111
// returns <number>
118112

119-
var it2 = iterator( 0.5, {
113+
const it2 = iterator( 0.5, {
120114
'seed': 12345
121115
});
122116

123-
var r2 = it2.next().value;
117+
const r2 = it2.next().value;
124118
// returns <number>
125119

126-
var bool = ( r1 === r2 );
120+
const bool = ( r1 === r2 );
127121
// returns true
128122
```
129123

130124
To limit the number of iterations, set the `iter` option.
131125

132126
```javascript
133-
var it = iterator( 0.5, {
127+
const it = iterator( 0.5, {
134128
'iter': 2
135129
});
136130

137-
var r = it.next().value;
131+
let r = it.next().value;
138132
// returns <number>
139133

140134
r = it.next().value;
@@ -178,20 +172,17 @@ The returned iterator protocol-compliant object has the following properties:
178172
<!-- eslint no-undef: "error" -->
179173

180174
```javascript
181-
var iterator = require( '@stdlib/random/iter/bernoulli' );
182-
183-
var it;
184-
var r;
175+
const iterator = require( '@stdlib/random/iter/bernoulli' );
185176

186177
// Create a seeded iterator for generating pseudorandom numbers:
187-
it = iterator( 0.3, {
178+
const it = iterator( 0.3, {
188179
'seed': 1234,
189180
'iter': 10
190181
});
191182

192183
// Perform manual iteration...
193184
while ( true ) {
194-
r = it.next();
185+
const r = it.next();
195186
if ( r.done ) {
196187
break;
197188
}

0 commit comments

Comments
 (0)