Skip to content

Commit c0dc7bb

Browse files
committed
docs: update README examples to use const and let
1 parent 00be223 commit c0dc7bb

File tree

56 files changed

+532
-600
lines changed

Some content is hidden

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

56 files changed

+532
-600
lines changed

lib/node_modules/@stdlib/_tools/pkgs/name2bucket/README.md

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

2929
```javascript
30-
var name2bucket = require( '@stdlib/_tools/pkgs/name2bucket' );
30+
const name2bucket = require( '@stdlib/_tools/pkgs/name2bucket' );
3131
```
3232

3333
#### name2bucket( name, buckets )
3434

3535
Deterministically converts a package `name` (or a list of package names) to a bucket.
3636

3737
```javascript
38-
var out = name2bucket( '@stdlib/math/base/special/sin', 10 );
38+
const out = name2bucket( '@stdlib/math/base/special/sin', 10 );
3939
// returns <number>
4040
```
4141

4242
To convert more than one package `name`, provide a list of package names.
4343

4444
```javascript
45-
var list = [
45+
const list = [
4646
'@stdlib/math/base/special/sin',
4747
'@stdlib/math/base/special/cos'
4848
];
49-
var out = name2bucket( list, 10 );
49+
const out = name2bucket( list, 10 );
5050
// returns [ <number>, <number> ]
5151
```
5252

@@ -61,14 +61,14 @@ var out = name2bucket( list, 10 );
6161
- The function maps standalone and non-standalone `stdlib` packages to the same bucket.
6262

6363
```javascript
64-
var list = [
64+
const list = [
6565
'@stdlib/math/base/special/sin',
6666
'@stdlib/math-base-special-sin'
6767
];
68-
var out = name2bucket( list, 10 );
68+
const out = name2bucket( list, 10 );
6969
// returns [...]
7070

71-
var bool = ( out[ 0 ] === out[ 1 ] );
71+
const bool = ( out[ 0 ] === out[ 1 ] );
7272
// returns true
7373
```
7474

@@ -83,33 +83,33 @@ var out = name2bucket( list, 10 );
8383
<!-- eslint no-undef: "error" -->
8484

8585
```javascript
86-
var join = require( 'path' ).join;
87-
var pkgNames = require( '@stdlib/_tools/pkgs/names' ).sync;
88-
var rootDir = require( '@stdlib/_tools/utils/root-dir' );
89-
var chi2gof = require( '@stdlib/stats/chi2gof' );
90-
var countBy = require( '@stdlib/utils/count-by' );
91-
var objectValues = require( '@stdlib/utils/values' );
92-
var identity = require( '@stdlib/utils/identity-function' );
93-
var name2bucket = require( '@stdlib/_tools/pkgs/name2bucket' );
86+
const join = require( 'path' ).join;
87+
const pkgNames = require( '@stdlib/_tools/pkgs/names' ).sync;
88+
const rootDir = require( '@stdlib/_tools/utils/root-dir' );
89+
const chi2gof = require( '@stdlib/stats/chi2gof' );
90+
const countBy = require( '@stdlib/utils/count-by' );
91+
const objectValues = require( '@stdlib/utils/values' );
92+
const identity = require( '@stdlib/utils/identity-function' );
93+
const name2bucket = require( '@stdlib/_tools/pkgs/name2bucket' );
9494
9595
// Resolve a namespace directory:
96-
var dir = join( rootDir(), 'lib', 'node_modules', '@stdlib', 'math', 'base', 'special' );
96+
const dir = join( rootDir(), 'lib', 'node_modules', '@stdlib', 'math', 'base', 'special' );
9797
9898
// Resolve a list of package names:
99-
var names = pkgNames({
99+
const names = pkgNames({
100100
'dir': dir
101101
});
102102
103103
// Place the names into 10 buckets:
104-
var out = name2bucket( names, 10 );
104+
const out = name2bucket( names, 10 );
105105
console.log( out.join( '\n' ) );
106106
107107
// Count the number of names in each bin:
108-
var counts = countBy( out, identity );
108+
const counts = countBy( out, identity );
109109
console.log( counts );
110110
111111
// Determine whether the names are uniformly distributed:
112-
var o = chi2gof( objectValues( counts ), 'discrete-uniform', 0, 9 );
112+
const o = chi2gof( objectValues( counts ), 'discrete-uniform', 0, 9 );
113113
console.log( o.toString() );
114114
```
115115

lib/node_modules/@stdlib/_tools/remark/plugins/remark-lint-eslint/README.md

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

2929
```javascript
30-
var plugin = require( '@stdlib/_tools/remark/plugins/remark-lint-eslint' );
30+
const plugin = require( '@stdlib/_tools/remark/plugins/remark-lint-eslint' );
3131
```
3232

3333
#### plugin()
3434

3535
A [remark][remark] plugin which, when provided a Markdown abstract syntax `tree`, lints JavaScript code blocks using the default [ESLint][eslint] configuration.
3636

37+
<!-- eslint-disable node/no-sync -->
38+
3739
```javascript
38-
var remark = require( 'remark' );
40+
const remark = require( 'remark' );
3941

4042
// Create a synchronous Markdown text linter:
41-
var linter = remark().use( plugin ).processSync;
43+
const linter = remark().use( plugin ).processSync;
4244

4345
// Lint Markdown:
44-
var vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
46+
const vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
4547
```
4648

4749
#### plugin.factory( \[options] )
4850

4951
Returns a configured [remark][remark] plugin for linting JavaScript code blocks.
5052

53+
<!-- eslint-disable node/no-sync -->
54+
5155
```javascript
52-
var remark = require( 'remark' );
56+
const remark = require( 'remark' );
5357

5458
// Create a synchronous Markdown text linter:
55-
var linter = remark().use( plugin.factory() ).processSync;
59+
const linter = remark().use( plugin.factory() ).processSync;
5660

5761
// Lint Markdown:
58-
var vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
62+
const vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
5963
```
6064

6165
The function recognizes the following `options`:
@@ -66,22 +70,24 @@ To specify configuration `options`, set the respective properties.
6670

6771
<!-- run-disable -->
6872

73+
<!-- eslint-disable node/no-sync -->
74+
6975
```javascript
70-
var remark = require( 'remark' );
76+
const remark = require( 'remark' );
7177

7278
// Define options:
73-
var opts = {
79+
const opts = {
7480
'config': '/path/to/.eslintrc'
7581
};
7682

7783
// Create a plugin:
78-
var lint = plugin.factory( opts );
84+
const lint = plugin.factory( opts );
7985

8086
// Create a synchronous Markdown text linter:
81-
var linter = remark().use( lint ).processSync;
87+
const linter = remark().use( lint ).processSync;
8288

8389
// Lint Markdown:
84-
var vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
90+
const vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
8591
```
8692

8793
</section>
@@ -103,9 +109,9 @@ var vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
103109
<!-- eslint-disable no-new-wrappers, no-sparse-arrays -->
104110

105111
```javascript
106-
var x = new Number( 3.14 );
112+
const x = new Number( 3.14 );
107113

108-
var arr = [ 1, , , 4, 5 ];
114+
const arr = [ 1, , , 4, 5 ];
109115
```
110116

111117
The plugin supports multiple consecutive comments.
@@ -119,9 +125,9 @@ var vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
119125
<!-- eslint-disable no-sparse-arrays -->
120126

121127
```javascript
122-
var x = new Number( 3.14 );
128+
const x = new Number( 3.14 );
123129

124-
var arr = [ 1, , , 4, 5 ];
130+
const arr = [ 1, , , 4, 5 ];
125131
```
126132

127133
Prior to linting, the plugin converts the content of each HTML comment to a JavaScript comment and prepends each comment to the content inside the code block. Accordingly, the plugin would transform the above example to
@@ -135,9 +141,9 @@ var vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
135141
```javascript
136142
/* eslint-disable no-new-wrappers */
137143
/* eslint-disable no-sparse-arrays */
138-
var x = new Number( 3.14 );
144+
const x = new Number( 3.14 );
139145

140-
var arr = [ 1, , , 4, 5 ];
146+
const arr = [ 1, , , 4, 5 ];
141147
```
142148

143149
- Configuration comments **only** apply to a code block which follows immediately after. Hence, the plugin does **not** apply the following configuration comment to a subsequent code block.
@@ -149,7 +155,7 @@ var vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
149155
Beep boop.
150156

151157
```javascript
152-
var x = new Number( 3.14 );
158+
const x = new Number( 3.14 );
153159
```
154160

155161
- The plugin lints each code block separately, and configuration comments are **not** shared between code blocks. Thus, one must repeat configuration comments for each code block.
@@ -161,15 +167,15 @@ var vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
161167
<!-- eslint-disable no-new-wrappers -->
162168

163169
```javascript
164-
var x = new Number( 3.14 );
170+
const x = new Number( 3.14 );
165171
```
166172

167173
Boop.
168174

169175
<!-- eslint-disable no-new-wrappers -->
170176

171177
```javascript
172-
var x = new Number( -3.14 );
178+
const x = new Number( -3.14 );
173179
```
174180

175181
- To skip linting for a particular code block, use the **non-standard** comment `<!-- eslint-skip -->`.
@@ -181,7 +187,7 @@ var vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
181187
<!-- eslint-skip -->
182188

183189
```javascript
184-
var x = new Number( 3.14 );
190+
const x = new Number( 3.14 );
185191
```
186192

187193
For skipped code blocks, the plugin reports neither rule nor syntax errors.
@@ -201,29 +207,29 @@ var vfile = linter( '```javascript\nvar beep = \'boop\';\n```' );
201207
<!-- eslint no-undef: "error" -->
202208

203209
```javascript
204-
var join = require( 'path' ).join;
205-
var resolve = require( 'path' ).resolve;
206-
var remark = require( 'remark' );
207-
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
208-
var factory = require( '@stdlib/_tools/remark/plugins/remark-lint-eslint' ).factory;
210+
const join = require( 'path' ).join;
211+
const resolve = require( 'path' ).resolve;
212+
const remark = require( 'remark' );
213+
const readFileSync = require( '@stdlib/fs/read-file' ).sync;
214+
const factory = require( '@stdlib/_tools/remark/plugins/remark-lint-eslint' ).factory;
209215

210216
// Define path to an ESLint config file:
211-
var config = resolve( __dirname, '..', '..', '..', '..', '..', '..', '..', 'etc', 'eslint', '.eslintrc.markdown.js' );
217+
const config = resolve( __dirname, '..', '..', '..', '..', '..', '..', '..', 'etc', 'eslint', '.eslintrc.markdown.js' );
212218

213219
// Load a Markdown file:
214-
var fpath = join( __dirname, 'examples', 'fixtures', 'file.md' );
215-
var file = readFileSync( fpath );
220+
const fpath = join( __dirname, 'examples', 'fixtures', 'file.md' );
221+
const file = readFileSync( fpath );
216222

217223
// Define plugin options:
218-
var opts = {
224+
const opts = {
219225
'config': config
220226
};
221227

222228
// Create a plugin:
223-
var plugin = factory( opts );
229+
const plugin = factory( opts );
224230

225231
// Lint code blocks:
226-
var out = remark().use( plugin ).processSync( file.toString() );
232+
const out = remark().use( plugin ).processSync( file.toString() );
227233

228234
console.log( out );
229235
```

lib/node_modules/@stdlib/_tools/remark/plugins/remark-namespace-toc/examples/fixtures/asinh/README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ limitations under the License.
2929
<!-- run-disable -->
3030

3131
```javascript
32-
var asinh = require( '@stdlib/math/base/special/fast/asinh' );
32+
const asinh = require( '@stdlib/math/base/special/fast/asinh' );
3333
```
3434

3535
#### asinh( x )
@@ -39,7 +39,7 @@ Computes the [hyperbolic arcsine][inverse-hyperbolic] of a `number` (in radians)
3939
<!-- run-disable -->
4040

4141
```javascript
42-
var v = asinh( 0.0 );
42+
let v = asinh( 0.0 );
4343
// returns 0.0
4444

4545
v = asinh( -0.0 );
@@ -74,7 +74,7 @@ v = asinh( Infinity );
7474
<!-- run-disable -->
7575

7676
```javascript
77-
var v = asinh( 1.0e200 );
77+
const v = asinh( 1.0e200 );
7878
// returns Infinity
7979
// (expected 461.2101657793691)
8080
```
@@ -84,7 +84,7 @@ v = asinh( Infinity );
8484
<!-- run-disable -->
8585

8686
```javascript
87-
var v = asinh( 1.0e-50 );
87+
const v = asinh( 1.0e-50 );
8888
// returns 0.0
8989
// (expected 1.0e-50)
9090
```
@@ -100,13 +100,12 @@ v = asinh( Infinity );
100100
<!-- eslint no-undef: "error" -->
101101

102102
```javascript
103-
var linspace = require( '@stdlib/array/base/linspace' );
104-
var asinh = require( '@stdlib/math/base/special/fast/asinh' );
103+
const linspace = require( '@stdlib/array/base/linspace' );
104+
const asinh = require( '@stdlib/math/base/special/fast/asinh' );
105105

106-
var x = linspace( -5.0, 5.0, 103 );
106+
const x = linspace( -5.0, 5.0, 103 );
107107

108-
var i;
109-
for ( i = 0; i < x.length; i++ ) {
108+
for ( let i = 0; i < x.length; i++ ) {
110109
console.log( asinh( x[ i ] ) );
111110
}
112111
```

0 commit comments

Comments
 (0)