Skip to content

Commit 987497f

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
2 parents 685d5e1 + cbf9861 commit 987497f

File tree

132 files changed

+5805
-856
lines changed

Some content is hidden

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

132 files changed

+5805
-856
lines changed

lib/node_modules/@stdlib/_tools/eslint/rules/repl-namespace-order/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var rule = require( '@stdlib/_tools/eslint/rules/repl-namespace-order' );
3838

3939
#### rule
4040

41-
[ESLint rule][eslint-rules] to enforce that packages are added to a REPL namespace object in alphabetical order according to alias (namespace key).
41+
[ESLint rule][eslint-rules] to enforce that packages are added to a REPL namespace object in alphabetical order according to alias (namespace key).
4242

4343
**Bad**:
4444

@@ -117,8 +117,6 @@ var result;
117117
var code;
118118

119119
code = [
120-
'/* eslint-enable stdlib/repl-namespace-order */',
121-
'',
122120
'/* When adding names to the namespace, ensure that they are added in alphabetical order according to alias (namespace key). */',
123121
'',
124122
'ns.push({',

lib/node_modules/@stdlib/_tools/eslint/rules/repl-namespace-order/examples/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ var result;
2626
var code;
2727

2828
code = [
29-
'/* eslint-enable stdlib/repl-namespace-order */',
30-
'',
3129
'/* When adding names to the namespace, ensure that they are added in alphabetical order according to alias (namespace key). */',
3230
'',
3331
'ns.push({',

lib/node_modules/@stdlib/_tools/eslint/rules/repl-namespace-order/lib/main.js

Lines changed: 115 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,43 +37,81 @@ var OPTS_COMPARE = {
3737
* @returns {Object} validators
3838
*/
3939
function main( context ) {
40+
var expressions;
4041
var prevAlias;
4142

42-
return {
43-
'ObjectExpression': validate
44-
};
43+
expressions = [];
4544

4645
/**
47-
* Checks whether packages are added to a REPL namespace object in alphabetical order according to alias (namespace key).
46+
* Extracts the alias value from a given node.
4847
*
4948
* @private
50-
* @param {ASTNode} node - node to examine
49+
* @param {ASTNode} node - node containing properties to search
50+
* @returns {string} alias value
5151
*/
52-
function validate( node ) {
53-
var properties;
52+
function getAlias( node ) {
53+
var props;
5454
var alias;
55-
var prop;
5655
var i;
5756

58-
properties = node.properties;
59-
for ( i = 0; i < properties.length; i++ ) {
60-
prop = properties[ i ];
61-
if ( prop.key.value === 'alias' ) {
62-
alias = prop.value.value;
57+
props = node.properties;
58+
for ( i = 0; i < props.length; i++ ) {
59+
if ( props[ i ].key.value === 'alias' ) {
60+
alias = props[ i ].value.value;
6361
if ( alias ) {
64-
if (
65-
prevAlias &&
66-
alias.localeCompare( prevAlias, 'en', OPTS_COMPARE ) < 0 )
67-
{
68-
report( prevAlias, alias, node );
69-
} else {
70-
prevAlias = alias;
71-
}
62+
return alias;
7263
}
7364
}
7465
}
7566
}
7667

68+
/**
69+
* Compares two nodes and determines their order based on the alias property.
70+
*
71+
* @private
72+
* @param {ASTNode} a - first node
73+
* @param {ASTNode} b - second node
74+
* @returns {number} number indicating sort order
75+
*/
76+
function sortExpressions( a, b ) {
77+
var aliasA = getAlias( a.arguments[ 0 ] );
78+
var aliasB = getAlias( b.arguments[ 0 ] );
79+
return aliasA.localeCompare( aliasB, 'en', OPTS_COMPARE );
80+
}
81+
82+
/**
83+
* Fixes the lint error by reordering the packages.
84+
*
85+
* @private
86+
* @param {Function} fixer - ESLint fixer
87+
* @returns {(Object|null)} fix or null
88+
*/
89+
function fix( fixer ) {
90+
var replacingText;
91+
var startRange;
92+
var endRange;
93+
var sorted;
94+
var source;
95+
var txt;
96+
var i;
97+
98+
source = context.getSourceCode();
99+
replacingText = '';
100+
startRange = expressions[0].range[ 0 ];
101+
endRange = expressions[ expressions.length - 1 ].range[ 1 ];
102+
103+
sorted = expressions.slice().sort( sortExpressions );
104+
105+
for ( i = 0; i < sorted.length; i++ ) {
106+
txt = source.getText( sorted[ i ] );
107+
replacingText += txt;
108+
if ( i < sorted.length - 1 ) {
109+
replacingText += ';\n\n';
110+
}
111+
}
112+
return fixer.replaceTextRange( [ startRange, endRange ], replacingText ); // eslint-disable-line max-len
113+
}
114+
77115
/**
78116
* Reports the error message.
79117
*
@@ -85,19 +123,74 @@ function main( context ) {
85123
function report( last, current, node ) {
86124
context.report({
87125
'node': node,
88-
'message': '"'+current+'" should come before "'+last+'"'
126+
'message': '"'+current+'" should come before "'+last+'"',
127+
'fix': fix
89128
});
90129
}
130+
131+
/**
132+
* Checks whether the packages are added to a REPL namespace object in alphabetical order according to alias (namespace key).
133+
*
134+
* @private
135+
*/
136+
function validate() {
137+
var alias;
138+
var i;
139+
140+
for ( i = 0; i < expressions.length; i++ ) {
141+
alias = getAlias( expressions[ i ].arguments[ 0 ] );
142+
if (
143+
prevAlias &&
144+
alias.localeCompare( prevAlias, 'en', OPTS_COMPARE ) < 0
145+
) {
146+
report( prevAlias, alias, expressions[ i ].arguments[ 0 ] );
147+
} else {
148+
prevAlias = alias;
149+
}
150+
}
151+
}
152+
153+
/**
154+
* Collects all expressions which add a package to a REPL namespace.
155+
*
156+
* @private
157+
* @param {ASTNode} node - node to examine
158+
*/
159+
function collectExpressions( node ) {
160+
var object;
161+
var alias;
162+
163+
if (
164+
node.callee.type === 'MemberExpression' &&
165+
node.callee.object.name === 'ns' &&
166+
node.callee.property.name === 'push'
167+
) {
168+
object = node.arguments[ 0 ];
169+
if ( object.type === 'ObjectExpression' ) {
170+
alias = getAlias( object );
171+
if ( alias ) {
172+
expressions.push( node );
173+
}
174+
}
175+
}
176+
}
177+
178+
return {
179+
'CallExpression': collectExpressions,
180+
'Program:exit': validate
181+
};
91182
}
92183

93184

94185
// MAIN //
95186

96187
rule = {
97188
'meta': {
189+
'type': 'suggestion',
98190
'docs': {
99191
'description': 'enforce that packages are added to a REPL namespace object in alphabetical order according to alias (namespace key)'
100192
},
193+
'fixable': 'code',
101194
'schema': []
102195
},
103196
'create': main

lib/node_modules/@stdlib/_tools/eslint/rules/repl-namespace-order/test/fixtures/invalid.js

Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,67 @@ test = {
5858
'message': '"hasInt8ArraySupport" should come before "hasMapSupport"',
5959
'type': 'ObjectExpression'
6060
}
61-
]
61+
],
62+
'output': [
63+
'ns.push({',
64+
' \'alias\': \'hasInt8ArraySupport\',',
65+
' \'path\': \'@stdlib/assert/has-int8array-support\',',
66+
' \'value\': require( \'@stdlib/assert/has-int8array-support\' ),',
67+
' \'type\': \'Function\',',
68+
' \'related\': []',
69+
'});',
70+
'',
71+
'ns.push({',
72+
' \'alias\': \'hasInt32ArraySupport\',',
73+
' \'path\': \'@stdlib/assert/has-int32array-support\',',
74+
' \'value\': require( \'@stdlib/assert/has-int32array-support\' ),',
75+
' \'type\': \'Function\',',
76+
' \'related\': []',
77+
'});',
78+
'',
79+
'ns.push({',
80+
' \'alias\': \'hasMapSupport\',',
81+
' \'path\': \'@stdlib/assert/has-map-support\',',
82+
' \'value\': require( \'@stdlib/assert/has-map-support\' ),',
83+
' \'type\': \'Function\',',
84+
' \'related\': []',
85+
'});'
86+
].join( '\n' )
6287
};
6388
invalid.push( test );
6489

6590
test = {
6691
'code': [
92+
'ns.push({',
93+
' \'alias\': \'pop\',',
94+
' \'path\': \'@stdlib/utils/pop\',',
95+
' \'value\': require( \'@stdlib/utils/pop\' ),',
96+
' \'type\': \'Function\',',
97+
' \'related\': [',
98+
' \'@stdlib/utils/push\',',
99+
' \'@stdlib/utils/shift\',',
100+
' \'@stdlib/utils/unshift\'',
101+
' ]',
102+
'});',
103+
'',
104+
'ns.push({',
105+
' \'alias\': \'pluck\',',
106+
' \'path\': \'@stdlib/utils/pluck\',',
107+
' \'value\': require( \'@stdlib/utils/pluck\' ),',
108+
' \'type\': \'Function\',',
109+
' \'related\': [',
110+
' \'@stdlib/utils/deep-pluck\',',
111+
' \'@stdlib/utils/pick\'',
112+
' ]',
113+
'});'
114+
].join( '\n' ),
115+
'errors': [
116+
{
117+
'message': '"pluck" should come before "pop"',
118+
'type': 'ObjectExpression'
119+
}
120+
],
121+
'output': [
67122
'ns.push({',
68123
' \'alias\': \'pluck\',',
69124
' \'path\': \'@stdlib/utils/pluck\',',
@@ -86,14 +141,9 @@ test = {
86141
' \'@stdlib/utils/unshift\'',
87142
' ]',
88143
'});'
89-
].join( '\n' ),
90-
'errors': [
91-
{
92-
'message': '"hasInt32ArraySupport" should come before "hasMapSupport"',
93-
'type': 'ObjectExpression'
94-
}
95-
]
144+
].join( '\n' )
96145
};
146+
invalid.push( test );
97147

98148
test = {
99149
'code': [
@@ -122,7 +172,28 @@ test = {
122172
'message': '"AFINN_96" should come before "AFINN_111"',
123173
'type': 'ObjectExpression'
124174
}
125-
]
175+
],
176+
'output': [
177+
'ns.push({',
178+
' \'alias\': \'AFINN_96\',',
179+
' \'path\': \'@stdlib/datasets/afinn-96\',',
180+
' \'value\': require( \'@stdlib/datasets/afinn-96\' ),',
181+
' \'type\': \'Function\',',
182+
' \'related\': [',
183+
' \'@stdlib/datasets/afinn-111\'',
184+
' ]',
185+
'});',
186+
'',
187+
'ns.push({',
188+
' \'alias\': \'AFINN_111\',',
189+
' \'path\': \'@stdlib/datasets/afinn-111\',',
190+
' \'value\': require( \'@stdlib/datasets/afinn-111\' ),',
191+
' \'type\': \'Function\',',
192+
' \'related\': [',
193+
' \'@stdlib/datasets/afinn-96\'',
194+
' ]',
195+
'});'
196+
].join( '\n' )
126197
};
127198
invalid.push( test );
128199

lib/node_modules/@stdlib/blas/ext/base/grev/README.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ limitations under the License.
3030
var grev = require( '@stdlib/blas/ext/base/grev' );
3131
```
3232

33-
#### grev( N, x, stride )
33+
#### grev( N, x, strideX )
3434

35-
Reverses a strided array `x` in-place.
35+
Reverses a strided array in-place.
3636

3737
```javascript
3838
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
@@ -45,41 +45,36 @@ The function has the following parameters:
4545

4646
- **N**: number of indexed elements.
4747
- **x**: input array.
48-
- **stride**: index increment.
48+
- **strideX**: stride length.
4949

50-
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to reverse every other element
50+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to reverse every other element:
5151

5252
```javascript
53-
var floor = require( '@stdlib/math/base/special/floor' );
54-
5553
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
56-
var N = floor( x.length / 2 );
5754

58-
grev( N, x, 2 );
55+
grev( 4, x, 2 );
5956
// x => [ -1.0, 1.0, 4.0, -5.0, 3.0, 0.0, -2.0, -3.0 ]
6057
```
6158

6259
Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views.
6360

6461
```javascript
6562
var Float64Array = require( '@stdlib/array/float64' );
66-
var floor = require( '@stdlib/math/base/special/floor' );
6763

6864
// Initial array...
6965
var x0 = new Float64Array( [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ] );
7066

7167
// Create an offset view...
7268
var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
73-
var N = floor( x0.length/2 );
7469

7570
// Reverse every other element...
76-
grev( N, x1, 2 );
71+
grev( 3, x1, 2 );
7772
// x0 => <Float64Array>[ 1.0, -6.0, 3.0, -4.0, 5.0, -2.0 ]
7873
```
7974

80-
#### grev.ndarray( N, x, stride, offset )
75+
#### grev.ndarray( N, x, strideX, offsetX )
8176

82-
Reverses a strided array `x` in-place using alternative indexing semantics.
77+
Reverses a strided array in-place using alternative indexing semantics.
8378

8479
```javascript
8580
var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
@@ -90,9 +85,9 @@ grev.ndarray( x.length, x, 1, 0 );
9085

9186
The function has the following additional parameters:
9287

93-
- **offset**: starting index.
88+
- **offsetX**: starting index.
9489

95-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to access only the last three elements of `x`
90+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements:
9691

9792
```javascript
9893
var x = [ 1.0, -2.0, 3.0, -4.0, 5.0, -6.0 ];

0 commit comments

Comments
 (0)