You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/_tools/eslint/rules/jsdoc-require-throws-tags/lib/unique.js
+13-19Lines changed: 13 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -18,38 +18,32 @@
18
18
19
19
'use strict';
20
20
21
+
// MAIN //
22
+
21
23
/**
22
-
* Returns the unique elements in an array.
24
+
* Mutates a sorted input array to only contain unique values.
23
25
*
24
26
* @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
27
29
*/
28
30
functionunique(arr){
29
-
varlen;
30
-
varout;
31
-
varval;
31
+
varv;
32
32
vari;
33
33
varj;
34
34
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
-
42
35
// 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.
'* @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',
0 commit comments