Skip to content

Commit fca7ac6

Browse files
committed
docs: update README examples to use const and let
1 parent ff5a8fe commit fca7ac6

File tree

31 files changed

+1535
-1930
lines changed

31 files changed

+1535
-1930
lines changed

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

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

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

3333
#### arcsine( a, b )
3434

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

3737
```javascript
38-
var r = arcsine( 2.0, 5.0 );
38+
const r = arcsine( 2.0, 5.0 );
3939
// returns <number>
4040
```
4141

4242
If either `a` or `b` is `NaN` or `a >= b`, the function returns `NaN`.
4343

4444
```javascript
45-
var r = arcsine( 2.0, 1.0 );
45+
let r = arcsine( 2.0, 1.0 );
4646
// returns NaN
4747

4848
r = arcsine( NaN, 1.0 );
@@ -57,19 +57,19 @@ r = arcsine( 1.0, NaN );
5757
Returns a pseudorandom number generator (PRNG) for generating pseudorandom numbers drawn from an [arcsine][arcsine] distribution.
5858

5959
```javascript
60-
var rand = arcsine.factory();
60+
const rand = arcsine.factory();
6161

62-
var r = rand( 0.0, 1.0 );
62+
const r = rand( 0.0, 1.0 );
6363
// returns <number>
6464
```
6565

6666
If provided `a` and `b`, the returned generator returns random variates from the specified distribution.
6767

6868
```javascript
6969
// Draw from arcsine( -2.0, 2.0 ) distribution:
70-
var rand = arcsine.factory( -2.0, 2.0 );
70+
const rand = arcsine.factory( -2.0, 2.0 );
7171

72-
var r = rand();
72+
let r = rand();
7373
// returns <number>
7474

7575
r = rand();
@@ -79,9 +79,9 @@ r = rand();
7979
If not provided `a` and `b`, the returned generator requires that both parameters be provided at each invocation.
8080

8181
```javascript
82-
var rand = arcsine.factory();
82+
const rand = arcsine.factory();
8383

84-
var r = rand( 0.0, 1.0 );
84+
let r = rand( 0.0, 1.0 );
8585
// returns <number>
8686

8787
r = rand( -2.0, 2.0 );
@@ -98,57 +98,52 @@ The function accepts the following `options`:
9898
To use a custom PRNG as the underlying source of uniformly distributed pseudorandom numbers, set the `prng` option.
9999

100100
```javascript
101-
var minstd = require( '@stdlib/random/base/minstd' );
101+
const minstd = require( '@stdlib/random/base/minstd' );
102102

103-
var rand = arcsine.factory({
103+
const rand = arcsine.factory({
104104
'prng': minstd.normalized
105105
});
106106

107-
var r = rand( 2.0, 4.0 );
107+
const r = rand( 2.0, 4.0 );
108108
// returns <number>
109109
```
110110

111111
To seed a pseudorandom number generator, set the `seed` option.
112112

113113
```javascript
114-
var rand1 = arcsine.factory({
114+
const rand1 = arcsine.factory({
115115
'seed': 12345
116116
});
117117

118-
var r1 = rand1( 2.0, 4.0 );
118+
const r1 = rand1( 2.0, 4.0 );
119119
// returns <number>
120120

121-
var rand2 = arcsine.factory( 2.0, 4.0, {
121+
const rand2 = arcsine.factory( 2.0, 4.0, {
122122
'seed': 12345
123123
});
124124

125-
var r2 = rand2();
125+
const r2 = rand2();
126126
// returns <number>
127127

128-
var bool = ( r1 === r2 );
128+
const bool = ( r1 === r2 );
129129
// returns true
130130
```
131131

132132
To return a generator having a specific initial state, set the generator `state` option.
133133

134134
```javascript
135-
var rand;
136-
var bool;
137-
var r;
138-
var i;
139-
140135
// Generate pseudorandom numbers, thus progressing the generator state:
141-
for ( i = 0; i < 1000; i++ ) {
142-
r = arcsine( 2.0, 4.0 );
136+
for ( let i = 0; i < 1000; i++ ) {
137+
const r = arcsine( 2.0, 4.0 );
143138
}
144139

145140
// Create a new PRNG initialized to the current state of `arcsine`:
146-
rand = arcsine.factory({
141+
const rand = arcsine.factory({
147142
'state': arcsine.state
148143
});
149144

150145
// Test that the generated pseudorandom numbers are the same:
151-
bool = ( rand( 2.0, 4.0 ) === arcsine( 2.0, 4.0 ) );
146+
const bool = ( rand( 2.0, 4.0 ) === arcsine( 2.0, 4.0 ) );
152147
// returns true
153148
```
154149

@@ -157,7 +152,7 @@ bool = ( rand( 2.0, 4.0 ) === arcsine( 2.0, 4.0 ) );
157152
The generator name.
158153

159154
```javascript
160-
var str = arcsine.NAME;
155+
const str = arcsine.NAME;
161156
// returns 'arcsine'
162157
```
163158

@@ -166,7 +161,7 @@ var str = arcsine.NAME;
166161
The underlying pseudorandom number generator.
167162

168163
```javascript
169-
var prng = arcsine.PRNG;
164+
const prng = arcsine.PRNG;
170165
// returns <Function>
171166
```
172167

@@ -175,20 +170,16 @@ var prng = arcsine.PRNG;
175170
The value used to seed `arcsine()`.
176171

177172
```javascript
178-
var rand;
179-
var r;
180-
var i;
181-
182173
// Generate pseudorandom values...
183174
for ( i = 0; i < 100; i++ ) {
184-
r = arcsine( 0.0, 10.0 );
175+
const r = arcsine( 0.0, 10.0 );
185176
}
186177

187178
// Generate the same pseudorandom values...
188-
rand = arcsine.factory( 0.0, 10.0, {
179+
const rand = arcsine.factory( 0.0, 10.0, {
189180
'seed': arcsine.seed
190181
});
191-
for ( i = 0; i < 100; i++ ) {
182+
for ( let i = 0; i < 100; i++ ) {
192183
r = rand();
193184
}
194185
```
@@ -198,11 +189,11 @@ If provided a PRNG for uniformly distributed numbers, this value is `null`.
198189
<!-- eslint-disable stdlib/no-builtin-math -->
199190

200191
```javascript
201-
var rand = arcsine.factory({
192+
const rand = arcsine.factory({
202193
'prng': Math.random
203194
});
204195

205-
var seed = rand.seed;
196+
const seed = rand.seed;
206197
// returns null
207198
```
208199

@@ -211,7 +202,7 @@ var seed = rand.seed;
211202
Length of generator seed.
212203

213204
```javascript
214-
var len = arcsine.seedLength;
205+
const len = arcsine.seedLength;
215206
// returns <number>
216207
```
217208

@@ -220,11 +211,11 @@ If provided a PRNG for uniformly distributed numbers, this value is `null`.
220211
<!-- eslint-disable stdlib/no-builtin-math -->
221212

222213
```javascript
223-
var rand = arcsine.factory({
214+
const rand = arcsine.factory({
224215
'prng': Math.random
225216
});
226217

227-
var len = rand.seedLength;
218+
const len = rand.seedLength;
228219
// returns null
229220
```
230221

@@ -233,7 +224,7 @@ var len = rand.seedLength;
233224
Writable property for getting and setting the generator state.
234225

235226
```javascript
236-
var r = arcsine( 2.0, 4.0 );
227+
let r = arcsine( 2.0, 4.0 );
237228
// returns <number>
238229

239230
r = arcsine( 2.0, 4.0 );
@@ -242,7 +233,7 @@ r = arcsine( 2.0, 4.0 );
242233
// ...
243234

244235
// Get a copy of the current state:
245-
var state = arcsine.state;
236+
const state = arcsine.state;
246237
// returns <Uint32Array>
247238

248239
r = arcsine( 2.0, 4.0 );
@@ -269,11 +260,11 @@ If provided a PRNG for uniformly distributed numbers, this value is `null`.
269260
<!-- eslint-disable stdlib/no-builtin-math -->
270261

271262
```javascript
272-
var rand = arcsine.factory({
263+
const rand = arcsine.factory({
273264
'prng': Math.random
274265
});
275266

276-
var state = rand.state;
267+
const state = rand.state;
277268
// returns null
278269
```
279270

@@ -282,7 +273,7 @@ var state = rand.state;
282273
Length of generator state.
283274

284275
```javascript
285-
var len = arcsine.stateLength;
276+
const len = arcsine.stateLength;
286277
// returns <number>
287278
```
288279

@@ -291,11 +282,11 @@ If provided a PRNG for uniformly distributed numbers, this value is `null`.
291282
<!-- eslint-disable stdlib/no-builtin-math -->
292283

293284
```javascript
294-
var rand = arcsine.factory({
285+
const rand = arcsine.factory({
295286
'prng': Math.random
296287
});
297288

298-
var len = rand.stateLength;
289+
const len = rand.stateLength;
299290
// returns null
300291
```
301292

@@ -304,7 +295,7 @@ var len = rand.stateLength;
304295
Size (in bytes) of generator state.
305296

306297
```javascript
307-
var sz = arcsine.byteLength;
298+
const sz = arcsine.byteLength;
308299
// returns <number>
309300
```
310301

@@ -313,11 +304,11 @@ If provided a PRNG for uniformly distributed numbers, this value is `null`.
313304
<!-- eslint-disable stdlib/no-builtin-math -->
314305

315306
```javascript
316-
var rand = arcsine.factory({
307+
const rand = arcsine.factory({
317308
'prng': Math.random
318309
});
319310

320-
var sz = rand.byteLength;
311+
const sz = rand.byteLength;
321312
// returns null
322313
```
323314

@@ -326,7 +317,7 @@ var sz = rand.byteLength;
326317
Serializes the pseudorandom number generator as a JSON object.
327318

328319
```javascript
329-
var o = arcsine.toJSON();
320+
const o = arcsine.toJSON();
330321
// returns { 'type': 'PRNG', 'name': '...', 'state': {...}, 'params': [] }
331322
```
332323

@@ -335,11 +326,11 @@ If provided a PRNG for uniformly distributed numbers, this method returns `null`
335326
<!-- eslint-disable stdlib/no-builtin-math -->
336327

337328
```javascript
338-
var rand = arcsine.factory({
329+
const rand = arcsine.factory({
339330
'prng': Math.random
340331
});
341332

342-
var o = rand.toJSON();
333+
const o = rand.toJSON();
343334
// returns null
344335
```
345336

@@ -365,31 +356,27 @@ var o = rand.toJSON();
365356
<!-- eslint no-undef: "error" -->
366357

367358
```javascript
368-
var arcsine = require( '@stdlib/random/base/arcsine' );
369-
370-
var seed;
371-
var rand;
372-
var i;
359+
const arcsine = require( '@stdlib/random/base/arcsine' );
373360

374361
// Generate pseudorandom numbers...
375-
for ( i = 0; i < 100; i++ ) {
362+
for ( let i = 0; i < 100; i++ ) {
376363
console.log( arcsine( 0.0, 1.0 ) );
377364
}
378365

379366
// Create a new pseudorandom number generator...
380-
seed = 1234;
381-
rand = arcsine.factory( 2.0, 5.0, {
367+
const seed = 1234;
368+
let rand = arcsine.factory( 2.0, 5.0, {
382369
'seed': seed
383370
});
384-
for ( i = 0; i < 100; i++ ) {
371+
for ( let i = 0; i < 100; i++ ) {
385372
console.log( rand() );
386373
}
387374

388375
// Create another pseudorandom number generator using a previous seed...
389376
rand = arcsine.factory( 0.0, 1.0, {
390377
'seed': arcsine.seed
391378
});
392-
for ( i = 0; i < 100; i++ ) {
379+
for ( let i = 0; i < 100; i++ ) {
393380
console.log( rand() );
394381
}
395382
```

0 commit comments

Comments
 (0)