Skip to content

Commit 627e64e

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents 23e7046 + 92d033e commit 627e64e

File tree

87 files changed

+2172
-414
lines changed

Some content is hidden

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

87 files changed

+2172
-414
lines changed

lib/node_modules/@stdlib/_tools/scripts/publish_packages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ function publish( pkg, clbk ) {
433433
}
434434
else {
435435
// Do not copy nested packages which will instead be pulled in as separate dependencies:
436-
command = 'rsync -r --ignore-missing-args --include=\'benchmark/***\' --include=\'bin/***\' --include=\'data/***\' --include=\'docs/***\' --include=\'etc/***\' --include=\'examples/***\' --include=\'lib/***\' --include=\'include/***\' --include=\'src/***\' --include=\'test/***\' --exclude=\'*/***\' '+src+'/*** '+dist;
436+
command = 'rsync -r --ignore-missing-args --include=\'benchmark/***\' --include=\'bin/***\' --include=\'data/***\' --include=\'docs/***\' --include=\'etc/***\' --include=\'examples/***\' --include=\'lib/***\' --include=\'include/***\' --include=\'scripts/***\' --include=\'src/***\' --include=\'test/***\' --exclude=\'*/***\' '+src+'/*** '+dist;
437437
}
438438
debug( 'Copying files: %s', command );
439439
shell( command );

lib/node_modules/@stdlib/_tools/scripts/templates/.npmignore.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Makefile
3636
**/examples/
3737
reports/
3838
support/
39+
scripts/
3940
**/tmp/
4041
workshops/
4142

lib/node_modules/@stdlib/_tools/scripts/templates/workflow_test.yml.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ on:
2525
# * is a special character in YAML so you have to quote this string
2626
- cron: '30 1 * * 6'
2727
workflow_dispatch:
28+
push:
2829

2930
# Workflow jobs:
3031
jobs:
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2021 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# Arrow Function Support
22+
23+
> Detect native [`arrow function`][mdn-arrow-function] support.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var hasArrowFunctionSupport = require( '@stdlib/assert/has-arrow-function-support' );
31+
```
32+
33+
#### hasArrowFunctionSupport()
34+
35+
Detects if a runtime environment supports ES2015 [`arrow functions`][mdn-arrow-function]` such as `( a, b ) => a + b`, `x => x`, or `( x ) => { return x*x; }`.
36+
37+
```javascript
38+
var bool = hasArrowFunctionSupport();
39+
// returns <boolean>
40+
```
41+
42+
</section>
43+
44+
<!-- /.usage -->
45+
46+
<section class="notes">
47+
48+
## Notes
49+
50+
- The implementation uses code evaluation, which may be problematic in browser contexts enforcing a strict [content security policy][mdn-csp] (CSP).
51+
52+
</section>
53+
54+
<!-- /.notes -->
55+
56+
<section class="examples">
57+
58+
## Examples
59+
60+
<!-- eslint no-undef: "error" -->
61+
62+
```javascript
63+
var hasArrowFunctionSupport = require( '@stdlib/assert/has-arrow-function-support' );
64+
65+
var bool = hasArrowFunctionSupport();
66+
if ( bool ) {
67+
console.log( 'Environment has native arrow function support.' );
68+
} else {
69+
console.log( 'Environment lacks native arrow function support.' );
70+
}
71+
```
72+
73+
</section>
74+
75+
<!-- /.examples -->
76+
77+
* * *
78+
79+
<section class="cli">
80+
81+
## CLI
82+
83+
<section class="usage">
84+
85+
### Usage
86+
87+
```text
88+
Usage: has-arrow-function-support [options]
89+
90+
Options:
91+
92+
-h, --help Print this message.
93+
-V, --version Print the package version.
94+
```
95+
96+
</section>
97+
98+
<!-- /.usage -->
99+
100+
<section class="examples">
101+
102+
### Examples
103+
104+
```bash
105+
$ has-arrow-function-support
106+
<boolean>
107+
```
108+
109+
</section>
110+
111+
<!-- /.examples -->
112+
113+
</section>
114+
115+
<!-- /.cli -->
116+
117+
<section class="links">
118+
119+
[mdn-arrow-function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
120+
121+
[mdn-csp]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
122+
123+
</section>
124+
125+
<!-- /.links -->
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
25+
var pkg = require( './../package.json' ).name;
26+
var hasArrowFunctionSupport = require( './../lib' );
27+
28+
29+
// MAIN //
30+
31+
bench( pkg, function benchmark( b ) {
32+
var bool;
33+
var i;
34+
35+
b.tic();
36+
for ( i = 0; i < b.iterations; i++ ) {
37+
// Note: the following *could* be optimized away via loop-invariant code motion. If so, the entire loop will disappear.
38+
bool = hasArrowFunctionSupport();
39+
if ( !isBoolean( bool ) ) {
40+
b.fail( 'should return a boolean' );
41+
}
42+
}
43+
b.toc();
44+
if ( !isBoolean( bool ) ) {
45+
b.fail( 'should return a boolean' );
46+
}
47+
b.pass( 'benchmark finished' );
48+
b.end();
49+
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* @license Apache-2.0
5+
*
6+
* Copyright (c) 2 The Stdlib Authors.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
21+
'use strict';
22+
23+
// MODULES //
24+
25+
var resolve = require( 'path' ).resolve;
26+
var readFileSync = require( '@stdlib/fs/read-file' ).sync;
27+
var CLI = require( '@stdlib/cli/ctor' );
28+
var detect = require( './../lib' );
29+
30+
31+
// MAIN //
32+
33+
/**
34+
* Main execution sequence.
35+
*
36+
* @private
37+
*/
38+
function main() {
39+
var flags;
40+
var cli;
41+
42+
// Create a command-line interface:
43+
cli = new CLI({
44+
'pkg': require( './../package.json' ),
45+
'options': require( './../etc/cli_opts.json' ),
46+
'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
47+
'encoding': 'utf8'
48+
})
49+
});
50+
51+
// Get any provided command-line options:
52+
flags = cli.flags();
53+
if ( flags.help || flags.version ) {
54+
return;
55+
}
56+
57+
console.log( detect() ); // eslint-disable-line no-console
58+
}
59+
60+
main();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
{{alias}}()
3+
Tests whether an environment supports native arrow functions.
4+
5+
Returns
6+
-------
7+
bool: boolean
8+
Boolean indicating if an environment support arrow functions.
9+
10+
Examples
11+
--------
12+
> var bool = {{alias}}()
13+
<boolean>
14+
15+
See Also
16+
--------
17+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 2.0
20+
21+
/**
22+
* Tests for native arrow function support.
23+
*
24+
* @returns boolean indicating if an environment has native arrow function support
25+
*
26+
* @example
27+
* var bool = hasArrowFunctionSupport();
28+
* // returns <boolean>
29+
*/
30+
declare function hasArrowFunctionSupport(): boolean;
31+
32+
33+
// EXPORTS //
34+
35+
export = hasArrowFunctionSupport;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import hasArrowFunctionSupport = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
hasArrowFunctionSupport(); // $ExpectType boolean
27+
}
28+
29+
// The compiler throws an error if the function is provided arguments...
30+
{
31+
hasArrowFunctionSupport( true ); // $ExpectError
32+
hasArrowFunctionSupport( [], 123 ); // $ExpectError
33+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
Usage: has-arrow-function-support [options]
3+
4+
Options:
5+
6+
-h, --help Print this message.
7+
-V, --version Print the package version.

0 commit comments

Comments
 (0)