Skip to content

Commit cb29bbf

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents aaa9c50 + 3ffc53b commit cb29bbf

File tree

13 files changed

+81
-36
lines changed

13 files changed

+81
-36
lines changed

lib/node_modules/@stdlib/_tools/eslint/rules/jsdoc-require-throws-tags/lib/main.js

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,19 @@ function main( context ) {
7979
* @param {ASTNode} node - function node
8080
*/
8181
function registerFunction( node ) {
82-
var name = node.id.name;
83-
if ( name ) {
84-
if ( !hasOwnProp( functionHash, name ) ) {
85-
functionHash[ name ] = {
86-
'name': name,
87-
'start': node.start,
88-
'end': node.end,
89-
'loc': node.loc,
90-
'throwAnnotations': extractThrowsAnnotations( node )
91-
};
82+
var name;
83+
if ( node.id ) {
84+
name = node.id.name;
85+
if ( name ) {
86+
if ( !hasOwnProp( functionHash, name ) ) {
87+
functionHash[ name ] = {
88+
'name': name,
89+
'start': node.start,
90+
'end': node.end,
91+
'loc': node.loc,
92+
'throwAnnotations': extractThrowsAnnotations( node )
93+
};
94+
}
9295
}
9396
}
9497
}
@@ -163,15 +166,19 @@ function main( context ) {
163166
* @param {Object} fcn - function metadata
164167
*/
165168
function validateFunction( fcn ) {
166-
var annotations = unique( fcn.throwAnnotations );
167-
var statements = unique( fcn.throwStatements );
169+
var annotations;
170+
var statements;
168171
var stmt;
169172
var i;
170173

171-
for ( i = 0; i < statements.length; i++ ) {
172-
stmt = statements[ i ];
173-
if ( !contains( annotations, stmt ) ) {
174-
report( fcn, stmt );
174+
if ( fcn.throwStatements.length > 0 ) {
175+
annotations = unique( fcn.throwAnnotations.sort() );
176+
statements = unique( fcn.throwStatements.sort() );
177+
for ( i = 0; i < statements.length; i++ ) {
178+
stmt = statements[ i ];
179+
if ( !contains( annotations, stmt ) ) {
180+
report( fcn, stmt );
181+
}
175182
}
176183
}
177184
}

lib/node_modules/@stdlib/_tools/eslint/rules/jsdoc-require-throws-tags/lib/unique.js

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,32 @@
1818

1919
'use strict';
2020

21+
// MAIN //
22+
2123
/**
22-
* Returns the unique elements in an array.
24+
* Mutates a sorted input array to only contain unique values.
2325
*
2426
* @private
25-
* @param {Array} arr - input array
26-
* @returns {Array} array of unique elements
27+
* @param {Array} arr - sorted array
28+
* @returns {Array} input array
2729
*/
2830
function unique( arr ) {
29-
var len;
30-
var out;
31-
var val;
31+
var v;
3232
var i;
3333
var j;
3434

35-
// Copy the array to avoid mutation:
36-
out = Array.prototype.slice.call( arr );
37-
len = out.length;
38-
39-
// Sort array in ascending order:
40-
out.sort();
41-
4235
// Loop through the array, only incrementing a pointer when successive values are different. When a succeeding value is different, move the pointer and set the next value. In the trivial case where all array elements are unique, we incur a slight penalty in resetting the element value for each unique value. In other cases, we simply move a unique value to a new position in the array. The end result is a sorted array with unique values.
43-
for ( i = 1, j = 0; i < len; i++ ) {
44-
val = out[ i ];
45-
if ( out[ j ] !== val ) {
36+
for ( i = 1, j = 0; i < arr.length; i++ ) {
37+
v = arr[ i ];
38+
if ( arr[ j ] !== v ) {
4639
j += 1;
47-
out[ j ] = val;
40+
arr[ j ] = v;
4841
}
4942
}
5043
// Truncate the array:
51-
out.length = j+1;
52-
return out;
44+
arr.length = j+1;
45+
46+
return arr;
5347
}
5448

5549

lib/node_modules/@stdlib/_tools/eslint/rules/jsdoc-require-throws-tags/test/fixtures/valid.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,35 @@ test = {
185185
};
186186
valid.push( test );
187187

188+
test = {
189+
'code': [
190+
'/**',
191+
'* Invokes a function once for each element in a collection and updates a collection in-place, iterating from right to left.',
192+
'*',
193+
'* @param {Collection} collection - input collection',
194+
'* @param {Options} [options] - function options',
195+
'* @param {*} [options.thisArg] - execution context',
196+
'* @param {PositiveInteger} [options.limit] - maximum number of pending invocations at any one time',
197+
'* @param {boolean} [options.series=false] - boolean indicating whether to wait for a previous invocation to complete before invoking a provided function for the next element in a collection',
198+
'* @param {Function} fcn - function to invoke for each element in a collection',
199+
'* @param {Callback} done - function to invoke upon completion',
200+
'* @throws {TypeError} first argument must be a collection',
201+
'* @throws {TypeError} options argument must be an object',
202+
'* @throws {TypeError} must provide valid options',
203+
'* @throws {TypeError} second-to-last argument must be a function',
204+
'* @throws {TypeError} last argument must be a function',
205+
'* @returns {void}',
206+
'*/',
207+
'function inmapRightAsync( collection, options, fcn, done ) {',
208+
' if ( arguments.length < 4 ) {',
209+
' return factory( options )( collection, fcn );',
210+
' }',
211+
' factory( options, fcn )( collection, done );',
212+
'}'
213+
].join( '\n' )
214+
};
215+
valid.push( test );
216+
188217

189218
// EXPORTS //
190219

lib/node_modules/@stdlib/nlp/lda/lib/lda.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ function lda( documents, K, options ) {
171171
* @private
172172
* @param {NonNegativeInteger} k - topic
173173
* @param {PositiveInteger} [no=10] - number of terms
174+
* @throws {TypeError} first argument must be a nonnegative integer smaller than the total number of topics
175+
* @throws {TypeError} second argument must be a positive integer
174176
* @returns {Array} word probability array
175177
*/
176178
function getTerms( k, no ) {

lib/node_modules/@stdlib/stats/kde2d/docs/repl.txt

Whitespace-only changes.

lib/node_modules/@stdlib/stats/kstest/lib/get_cdf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var CDF = require( './cdf.js' );
3030
*
3131
* @private
3232
* @param {string} name - distribution name
33+
* @throws {Error} unsupported/unrecognized distribution name
3334
* @returns {Function} cumulative distribution function (CDF)
3435
*/
3536
function getCDF( name ) {

lib/node_modules/@stdlib/stats/kstest/lib/print.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ var roundn = require( '@stdlib/math/base/special/roundn' );
3535
* @param {Object} [opts] - options object
3636
* @param {PositiveInteger} [opts.numdigits=4] - number of digits after the decimal point
3737
* @param {boolean} [opts.decision=true] - boolean indicating whether to print the test decision
38+
* @throws {TypeError} options argument must be an object
39+
* @throws {TypeError} must provide valid options
3840
* @returns {string} formatted output
3941
*/
4042
function print( opts ) { // eslint-disable-line stdlib/no-redeclare

lib/node_modules/@stdlib/stats/ttest/lib/print.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ var roundn = require( '@stdlib/math/base/special/roundn' );
3535
* @param {Object} [opts] - options object
3636
* @param {PositiveInteger} [opts.numdigits=4] - number of digits after the decimal point
3737
* @param {boolean} [opts.decision=true] - boolean indicating whether to print the test decision
38+
* @throws {TypeError} options argument must be an object
39+
* @throws {TypeError} must provide valid options
3840
* @returns {string} formatted output
3941
*/
4042
function print( opts ) { // eslint-disable-line stdlib/no-redeclare

lib/node_modules/@stdlib/stats/ttest2/lib/print.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ var roundn = require( '@stdlib/math/base/special/roundn' );
3535
* @param {Object} [opts] - options object
3636
* @param {PositiveInteger} [opts.numdigits=4] - number of digits after the decimal point
3737
* @param {boolean} [opts.decision=true] - boolean indicating whether to print the test decision
38+
* @throws {TypeError} options has to be simple object
39+
* @throws {TypeError} must provide valid options
3840
* @returns {string} formatted output
3941
*/
4042
function print( opts ) { // eslint-disable-line stdlib/no-redeclare

lib/node_modules/@stdlib/stats/ztest/lib/print.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ var roundn = require( '@stdlib/math/base/special/roundn' );
3535
* @param {Object} [opts] - options object
3636
* @param {PositiveInteger} [opts.numdigits=4] - number of digits after the decimal point
3737
* @param {boolean} [opts.decision=true] - boolean indicating whether to print the test decision
38+
* @throws {TypeError} options argument must be an object
39+
* @throws {TypeError} must provide valid options
3840
* @returns {string} formatted output
3941
*/
4042
function print( opts ) { // eslint-disable-line stdlib/no-redeclare

0 commit comments

Comments
 (0)