File: README.md

package info (click to toggle)
node-stdlib 0.0.96%2Bds1%2B~cs0.0.429-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 421,476 kB
  • sloc: javascript: 1,562,831; ansic: 109,702; lisp: 49,823; cpp: 27,224; python: 7,871; sh: 6,807; makefile: 6,089; fortran: 3,102; awk: 387
file content (558 lines) | stat: -rw-r--r-- 11,419 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
<!--

@license Apache-2.0

Copyright (c) 2020 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# Makefile

> Development utility.

This project uses [`make`][make] as its development utility. For an overview of `make`, see the `make` [manual][make]. 

## Usage

#### Help

To view a list of available `Makefile` targets,

```bash
$ make help
```

* * *

#### REPL

To launch a REPL,

```bash
$ make repl
```

* * *

#### Notes

Annotating source code is a useful means for inlining action items and notes. For example,

<!-- eslint-disable no-warning-comments -->

```javascript
// FIXME: don't release the zalgo!
function foo( cb ) {
    if ( bar ) {
        return asyncFcn( cb );
    }
    cb();
}
```

To retrieve source code annotations,

```bash
$ make notes
```

The following annotations are recognized:

-   **TODO**: annotates a future task.
-   **FIXME**: annotates a problem.
-   **HACK**: annotates fragile/non-general solutions.
-   **WARNING**: annotates possible pitfalls or gotchas.
-   **OPTIMIZE**: annotates code which needs optimizing.
-   **NOTE**: annotates questions, comments, or anything which does not fit under `TODO`/`FIXME`/`HACK`/`WARNING`/`OPTIMIZE` and should be brought to a reader's attention.

* * *

#### Files

The `Makefile` exposes several targets (also used internally) for finding project files. For example, to list all project files, excluding `node_modules`, `build`, `reports`, and hidden directories,

```bash
$ make list-files
```

To filter based on a file name or pattern,

```bash
# List only README.md files...
$ make FILES_PATTERN=README.md list-files
```

To filter based on a file path,

```bash
# List all files in the is-nan utils directory...
$ make FILES_FILTER=".*/assert/is-nan/.*" list-files
```

**Notes**:

-   Most filters should begin with `.*/` and end with `/.*`, as a filter is used as a regular expression to test a file path.

-   The `*_PATTERN` and `*_FILTER` environment variables map to `-name` and `-regex` options, respectively, for the `find` command. For certain types of operations, like regular expressions using `|` for alternative matches, you may need to use `*_FILTER` over `*_PATTERN`. For instance,

    ```bash
    # List all `R` test fixtures...
    $ make TESTS_FIXTURES_PATTERN=*.R

    # List all `R` and `Julia` test fixtures...
    $ make TESTS_FIXTURES_FILTER='.*/*\.(jl|R)' list-test-fixtures
    ```

The `Makefile` includes the following common recipes for listing different file types...

##### Sources

To list all source files, excluding examples, benchmarks, and tests,

```bash
$ make list-sources
```

To filter based on a file name or pattern,

```bash
# List only source files having the filename `index.js`...
$ make SOURCES_PATTERN=index.js list-sources
```

To filter based on a file path,

```bash
# List only source files found in a math directory...
$ make SOURCES_FILTER=".*/math/.*" list-sources
```

##### Tests

To list all test files,

```bash
$ make list-tests
```

To filter based on a file name or pattern,

```bash
# List only the main test files...
$ make TESTS_PATTERN=test.js list-tests
```

To filter based on a file path,

```bash
# List only test files in the fs directory...
$ make TESTS_FILTER=".*/fs/.*" list-tests
```

##### Test Fixtures

To list all test fixture files,

```bash
$ make list-tests-fixtures
```

To filter based on a file name or pattern,

```bash
# List only the Julia test fixtures...
$ make TESTS_FIXTURES_PATTERN=*.jl list-tests-fixtures
```

To filter based on a file path,

```bash
# List only test fixture files in the base math directory for special functions...
$ make TESTS_FIXTURES_FILTER=".*/math/special/.*" list-tests-fixtures
```

##### Benchmarks

To list all benchmark files,

```bash
$ make list-benchmarks
```

To filter based on a file name or pattern,

```bash
# List only the main benchmark files...
$ make BENCHMARKS_PATTERN=benchmark.js list-benchmarks
```

To filter based on a file path,

```bash
# List only benchmark files for base special math functions...
$ make BENCHMARKS_FILTER=".*/math/base/special/.*" list-benchmarks
```

##### Examples

To list all examples files,

```bash
$ make list-examples
```

To filter based on a file name or pattern,

```bash
# List only those examples having a filename `index.js`...
$ make EXAMPLES_PATTERN=index.js list-examples
```

To filter based on a file path,

```bash
# List only the example files for special functions in the base math directory...
$ make EXAMPLES_FILTER=".*/math/base/special/.*" list-examples
```

##### Packages

To list all packages (as absolute paths),

```bash
$ make list-pkgs
```

To filter based on a file path,

```bash
# List only the special function packages in the base math directory...
$ make PACKAGES_FILTER=".*/math/base/special/.*" list-pkgs
```

To list all package names under the `@stdlib` scope,

```bash
$ make list-pkgs-names
```

To list all package names under a `@stdlib` descendant directory,

```bash
$ make SRC_DIR=./@stdlib/math/base list-pkgs-names
```

* * *

#### Package Examples

To run package examples,

```bash
$ make examples
```

To limit which examples are run, use the same environment variables recognized by `list-examples`.

```bash
# Only run the examples for special functions in the base math directory...
$ make EXAMPLES_FILTER=".*/math/base/special/.*" EXAMPLES_PATTERN=index.js examples
```

* * *

#### Unit Tests

To run unit tests,

```bash
$ make test
```

To generate a test summary,

```bash
$ make test-summary
```

To limit which tests are run, use the same environment variables recognized by `list-tests`.

```bash
# Run only the main test file for base math utils...
$ make TESTS_FILTER=".*/math/base/utils/.*" TESTS_PATTERN=test.js test

# Run all blas tests...
$ make TESTS_FILTER=".*/math/base/blas/.*"  test-summary
```

To run unit tests against specific Node.js versions (assuming [`nvm`][nvm] is installed),

```bash
$ make test-node-versions
```

By default, tests are run against supported Node.js versions. To run against alternative versions, set the `NODE_VERSIONS` environment variable.

```bash
$ make NODE_VERSIONS='0.10 4 6' TESTS_FILTER=".*/fs/exists/.*" test-node-versions
```

To run units tests for project tools,

```bash
$ make tools-test
```

To limit which tests are run, use the same environment variables recognized by `list-tests`.

```bash
$ make tools-test TESTS_FILTER=".*/search/.*" TESTS_PATTERN=test.js
```

#### Test Coverage

To generate a test coverage report,

```bash
$ make test-cov
```

To limit which tests are run, use the same environment variables recognized by `list-tests`.

```bash
# Generate a coverage report for base math utils...
$ make TESTS_FILTER=".*/math/base/utils/.*" test-cov
```

To generate a coverage report for project tools,

```bash
$ make tools-test-cov
```

To limit which tests are run, use the same environment variables recognized by `list-tests`.

```bash
$ make tools-test-cov TESTS_FILTER=".*/search/.*" TESTS_PATTERN=test.js
```

To view a generated report in a local web browser,

```bash
$ make view-cov
```

#### Browser Tests

To run browser tests in a (headless) local web browser,

```bash
$ make test-browsers
```

To run and view the tests in a local web browser,

```bash
$ make view-browser-tests
```

To limit which tests are run, use the same environment variables recognized by `list-tests`.

```bash
# Run base math utils tests in a headless local web browser...
$ make TESTS_FILTER=".*/math/base/utils/.*" test-browsers

# Run @stdlib utils tests in a local web browser...
$ make TESTS_FILTER=".*/\@stdlib/utils/.*" test-view-browsers
```

* * *

#### Benchmarks

To run benchmarks,

```bash
$ make benchmark
```

To limit which benchmarks are run, use the same environment variables recognized by `list-benchmarks`.

```bash
# Run only the benchmarks for base special math functions...
$ make BENCHMARKS_FILTER=".*/math/base/special/.*" BENCHMARKS_PATTERN=benchmark.js benchmark
```

* * *

#### Documentation

To generate documentation from [JSDoc][jsdoc] source code comments,

```bash
$ make docs-src
```

To view the documentation in a local web browser,

```bash
$ make view-src-docs
```

* * *

#### Lint

To lint files, including tests, examples, filenames, `package.json`, and Markdown,

```bash
$ make SOURCES_FILTER=... TESTS_FILTER=... EXAMPLES_FILTER=... BENCHMARKS_FILTER=... MARKDOWN_FILTER=... lint
```

To lint only source files,

```bash
$ make SOURCES_FILTER=... lint-src
```

To lint only test files,

```bash
$ make TESTS_FILTER=... lint-tests
```

To lint only example files,

```bash
$ make EXAMPLES_FILTER=... lint-examples
```

To lint only benchmark files,

```bash
$ make BENCHMARKS_FILTER=... lint-benchmarks
```

To lint only Markdown files,

```bash
$ make MARKDOWN_FILTER=... lint-markdown
```

To lint only JavaScript files,

```bash
$ make SOURCES_FILTER=... TESTS_FILTER=... EXAMPLES_FILTER=... BENCHMARKS_FILTER=... lint-javascript
```

To lint filenames,

```bash
$ make lint-filenames
```

To lint `package.json` files,

```bash
$ make lint-pkg-json
```

* * *

#### Complexity

To analyze code complexity,

```bash
$ make SOURCES_FILTER=... TESTS_FILTER=... EXAMPLES_FILTER=... complexity
```

To analyze only source files,

```bash
$ make SOURCES_FILTER=... complexity-src
```

To analyze only test files,

```bash
$ make TESTS_FILTER=... complexity-tests
```

To analyze only example files,

```bash
$ make EXAMPLES_FILTER=... complexity-examples
```

To analyze only benchmark files,

```bash
$ make BENCHMARKS_FILTER=... complexity-benchmarks
```

To analyze only JavaScript files,

```bash
$ make SOURCES_FILTER=... TESTS_FILTER=... EXAMPLES_FILTER=... complexity-javascript
```

* * *

#### Dependencies

To check whether dependencies are up-to-date,

```bash
$ make check-deps
```

To check licenses of installed package dependencies,

```bash
$ make check-licenses
```

* * *

#### Bash Completion

To enable [bash completion][bash-completion] of Makefile targets, add

```text
complete -W "\`find . ! \( -path \"*/node_modules/*\" -prune \) -and \( -name 'Makefile' -o -name '*.mk' \) | xargs grep '^.PHONY: ' | awk '{print $2}'\`" make
```

to your `~/.bash_profile` or `~/.bashrc`. Note that completion is **not** exhaustive, as the above only includes targets which have been **explicitly** declared phony targets

```text
.PHONY: beep-boop
```

and does not include targets declared via variables. Excluded targets could be included by mining the Makefile database `make -qp`, but such inclusion has a performance cost and is unnecessary due to the predominant use of `PHONY`.

<section class="links">

[make]: https://www.gnu.org/software/make/manual/make.html#Introduction

[jsdoc]: http://usejsdoc.org/

[nvm]: https://github.com/creationix/nvm

[bash-completion]: https://www.gnu.org/software/bash/manual/bashref.html#Programmable-Completion

</section>

<!-- /.links -->