Skip to content

Commit b0b9cb6

Browse files
authored
Merge branch 'stdlib-js:develop' into tests-some-by
2 parents 6826ae9 + 930998f commit b0b9cb6

Some content is hidden

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

76 files changed

+6870
-95
lines changed

.github/workflows/namespace_declarations.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ jobs:
115115
116116
# Branch name slug with slashes replaced by dashes:
117117
branch_name="update-${display_namespace//\//-}-declarations"
118+
119+
# If an open PR already exists for this branch, skip this namespace entirely:
120+
existing_pr=$(gh pr list --head "$branch_name" --state open --json number -q '.[0].number' || true)
121+
if [ -n "$existing_pr" ]; then
122+
echo "Open PR exists for $branch_name (#$existing_pr). Skipping $namespace."
123+
continue
124+
fi
125+
126+
# Switch to the new branch:
118127
git checkout -b "$branch_name"
119128
120129
# Generate declarations for this namespace:

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

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* limitations under the License.
1919
*/
2020

21-
/* eslint-disable node/no-sync, no-console */
21+
/* eslint-disable node/no-sync, no-console, max-statements */
2222

2323
'use strict';
2424

@@ -44,6 +44,54 @@ var RE_TS_EXPORT = /export = ([^;]+);/;
4444
var RE_EXAMPLE = /@example[\s\S]*?(?=@example|\*\/)/g;
4545
var RE_NAMESPACE = /@namespace ([a-z.0-9]+)/i;
4646
var RE_COPYRIGHT_YEAR = /Copyright \(c\) (\d{4}) The Stdlib Authors\./;
47+
var RESERVED_WORDS = [
48+
'break',
49+
'case',
50+
'catch',
51+
'class',
52+
'const',
53+
'continue',
54+
'debugger',
55+
'default',
56+
'delete',
57+
'do',
58+
'else',
59+
'export',
60+
'extends',
61+
'false',
62+
'finally',
63+
'for',
64+
'function',
65+
'if',
66+
'import',
67+
'in',
68+
'instanceof',
69+
'new',
70+
'null',
71+
'return',
72+
'super',
73+
'switch',
74+
'this',
75+
'throw',
76+
'true',
77+
'try',
78+
'typeof',
79+
'var',
80+
'void',
81+
'while',
82+
'with',
83+
'let',
84+
'static',
85+
'yield',
86+
'await',
87+
'enum',
88+
'implements',
89+
'interface',
90+
'package',
91+
'private',
92+
'protected',
93+
'public'
94+
];
4795

4896

4997
// FUNCTIONS //
@@ -175,6 +223,7 @@ function create( fullPath ) {
175223
var tsDefPath;
176224
var testFile;
177225
var typesDir;
226+
var safeName;
178227
var defFile;
179228
var pkgPath;
180229
var match;
@@ -237,11 +286,16 @@ function create( fullPath ) {
237286
}
238287
while ( match !== null ) {
239288
name = match[ 1 ];
289+
if ( contains( RESERVED_WORDS, name ) ) {
290+
safeName = '_' + name;
291+
} else {
292+
safeName = name;
293+
}
240294
pkgPath = match[ 2 ];
241295

242296
tsDefPath = replace( require.resolve( pkgPath ), 'lib/index.js', 'docs/types/index.d.ts' );
243297
if ( fs.existsSync( tsDefPath ) ) {
244-
stmt = replace( IMPORT_STATEMENT, '<name>', name );
298+
stmt = replace( IMPORT_STATEMENT, '<name>', safeName );
245299
stmt = replace( stmt, '<path>', pkgPath );
246300
importStmts.push( stmt );
247301

@@ -253,7 +307,7 @@ function create( fullPath ) {
253307
if ( !tsDoc ) {
254308
tsDoc = tsDef.match( /(\/\*\*\n[^/]+?\*\/)\ndeclare class/ );
255309
}
256-
prop = '\t'+name+': typeof '+name+';';
310+
prop = '\t'+name+': typeof '+safeName+';';
257311
if ( tsDoc && tsDoc[ 1 ] ) {
258312
str = tsDoc[ 1 ];
259313
str = replace( str, RE_EXAMPLE, onReplace );

lib/node_modules/@stdlib/array/base/docs/types/index.d.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ interface Namespace {
742742
* var x = [ 'beep', 'boop', 'foo', 'bar' ];
743743
* var filter = [ true, true, false, true ];
744744
*
745-
* var out = ns.bifurcateEntries( arr, filter );
745+
* var out = ns.bifurcateEntries( x, filter );
746746
* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ]
747747
*/
748748
bifurcateEntries: typeof bifurcateEntries;
@@ -822,7 +822,7 @@ interface Namespace {
822822
* var x = [ 'beep', 'boop', 'foo', 'bar' ];
823823
* var filter = [ true, true, false, true ];
824824
*
825-
* var out = ns.bifurcateValues( arr, filter );
825+
* var out = ns.bifurcateValues( x, filter );
826826
* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]
827827
*/
828828
bifurcateValues: typeof bifurcateValues;
@@ -2138,16 +2138,16 @@ interface Namespace {
21382138
*
21392139
* @example
21402140
* function fcn( v ) {
2141-
* return v > 0;
2141+
* return v > 0;
21422142
* }
21432143
* var x = [ 1, 1, 0, 0, 0 ];
21442144
*
2145-
* var result = cunoneByright( x, fcn );
2145+
* var result = ns.cunoneByRight( x, fcn );
21462146
* // returns [ true, true, true, false, false ]
21472147
*
21482148
* @example
21492149
* function fcn( v ) {
2150-
* return v > 0;
2150+
* return v > 0;
21512151
* }
21522152
* var x = [ 0, 1, 1, 0, 0 ];
21532153
* var y = [ false, null, false, null, false, null, false, null, false, null ];
@@ -2734,7 +2734,7 @@ interface Namespace {
27342734
* @example
27352735
* var arr = [ 1, 2, 3 ];
27362736
*
2737-
* var out = ns.first( x );
2737+
* var out = ns.first( arr );
27382738
* // returns 1
27392739
*/
27402740
first: typeof first;
@@ -3537,7 +3537,7 @@ interface Namespace {
35373537
* @example
35383538
* var arr = [ 1, 2, 3 ];
35393539
*
3540-
* var out = ns.last( x );
3540+
* var out = ns.last( arr );
35413541
* // returns 3
35423542
*/
35433543
last: typeof last;
@@ -4014,7 +4014,7 @@ interface Namespace {
40144014
*
40154015
* var mask = [ [ [ [ 0, 1 ], [ 0, 0 ] ] ] ];
40164016
*
4017-
* mskbinary2d( [ x, y, mask, z ], shape, add );
4017+
* ns.mskbinary4d( [ x, y, mask, z ], shape, add );
40184018
*
40194019
* console.log( z );
40204020
* // => [ [ [ [ 2.0, 0.0 ], [ 2.0, 2.0 ] ] ] ]
@@ -4946,6 +4946,8 @@ interface Namespace {
49464946
* @returns output array
49474947
*
49484948
* @example
4949+
* var isPositiveNumber = require( '@stdlib/assert/is-positive-number' ).isPrimitive;
4950+
*
49494951
* var x = [ 1, -2, -3, 4 ];
49504952
*
49514953
* var out = ns.reject( x, isPositiveNumber );
@@ -5976,7 +5978,7 @@ interface Namespace {
59765978
* var x = ones5d( shape );
59775979
* var y = zeros5d( shape );
59785980
*
5979-
* unary2dBy( [ x, y ], shape, scale );
5981+
* ns.unary5dBy( [ x, y ], shape, scale );
59805982
*
59815983
* console.log( y );
59825984
* // => [ [ [ [ [ -10.0, -10.0 ], [ -10.0, -10.0 ] ] ] ] ]

0 commit comments

Comments
 (0)