diff --git a/array/base/coverage.ndjson b/array/base/coverage.ndjson index 7f17a674a0..c741ae660d 100644 --- a/array/base/coverage.ndjson +++ b/array/base/coverage.ndjson @@ -88,3 +88,4 @@ [1194,1194,100,1,1,100,0,0,100,1194,1194,100,"8287206a5aa615fc4b6f7daff790e507a3db78fc","2023-12-30 12:36:57 -0800"] [1194,1194,100,1,1,100,0,0,100,1194,1194,100,"a6eb07f21ba96025798827e611c337d4239492aa","2023-12-31 01:12:19 -0800"] [1203,1203,100,1,1,100,0,0,100,1203,1203,100,"8391d12225f7e215aa6143cd49e452c61c844c3f","2023-12-31 14:11:05 -0800"] +[1212,1212,100,1,1,100,0,0,100,1212,1212,100,"b7789348dcfa85d8e0b0987a54dc2986f2e68ce5","2023-12-31 14:22:18 -0800"] diff --git a/array/base/group-indices-by/coverage.ndjson b/array/base/group-indices-by/coverage.ndjson new file mode 100644 index 0000000000..ddaf174330 --- /dev/null +++ b/array/base/group-indices-by/coverage.ndjson @@ -0,0 +1 @@ +[124,124,100,6,6,100,1,1,100,124,124,100,"b7789348dcfa85d8e0b0987a54dc2986f2e68ce5","2023-12-31 14:22:18 -0800"] diff --git a/array/base/group-indices-by/index.html b/array/base/group-indices-by/index.html new file mode 100644 index 0000000000..86540e113a --- /dev/null +++ b/array/base/group-indices-by/index.html @@ -0,0 +1,131 @@ + + + + + + Code coverage report for array/base/group-indices-by/lib + + + + + + + + + +
+
+

All files array/base/group-indices-by/lib

+
+ +
+ 100% + Statements + 124/124 +
+ + +
+ 100% + Branches + 6/6 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 124/124 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
index.js +
+
100%46/46100%1/1100%0/0100%46/46
main.js +
+
100%78/78100%5/5100%1/1100%78/78
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/array/base/group-indices-by/index.js.html b/array/base/group-indices-by/index.js.html new file mode 100644 index 0000000000..062c6fbb99 --- /dev/null +++ b/array/base/group-indices-by/index.js.html @@ -0,0 +1,223 @@ + + + + + + Code coverage report for array/base/group-indices-by/lib/index.js + + + + + + + + + +
+
+

All files / array/base/group-indices-by/lib index.js

+
+ +
+ 100% + Statements + 46/46 +
+ + +
+ 100% + Branches + 1/1 +
+ + +
+ 100% + Functions + 0/0 +
+ + +
+ 100% + Lines + 46/46 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +471x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*    http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+ 
+'use strict';
+ 
+/**
+* Group element indices according to an indicator function.
+*
+* @module @stdlib/array/base/group-indices-by
+*
+* @example
+* var groupIndicesBy = require( '@stdlib/array/base/group-indices-by' );
+*
+* function indicator( v ) {
+*     return v[ 0 ];
+* }
+*
+* var x = [ 'beep', 'boop', 'foo', 'bar' ];
+*
+* var out = groupIndicesBy( x, indicator );
+* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] }
+*/
+ 
+// MODULES //
+ 
+var main = require( './main.js' );
+ 
+ 
+// EXPORTS //
+ 
+module.exports = main;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/array/base/group-indices-by/main.js.html b/array/base/group-indices-by/main.js.html new file mode 100644 index 0000000000..b90eaca7c3 --- /dev/null +++ b/array/base/group-indices-by/main.js.html @@ -0,0 +1,319 @@ + + + + + + Code coverage report for array/base/group-indices-by/lib/main.js + + + + + + + + + +
+
+

All files / array/base/group-indices-by/lib main.js

+
+ +
+ 100% + Statements + 78/78 +
+ + +
+ 100% + Branches + 5/5 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 100% + Lines + 78/78 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +791x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +20x +20x +20x +9x +20x +11x +11x +20x +6x +6x +1x +1x +1x +1x +1x + 
/**
+* @license Apache-2.0
+*
+* Copyright (c) 2023 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*    http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+ 
+'use strict';
+ 
+// MODULES //
+ 
+var isArray = require( '@stdlib/assert/is-array' );
+var resolveGetter = require( '@stdlib/array/base/resolve-getter' );
+ 
+ 
+// MAIN //
+ 
+/**
+* Groups element indices according to an indicator function.
+*
+* @param {Collection} x - input array
+* @param {Function} indicator - indicator function specifying which group an element in the input collection belongs to
+* @param {*} [thisArg] - indicator function execution context
+* @returns {Object} group results
+*
+* @example
+* function indicator( v ) {
+*     return v[ 0 ];
+* }
+*
+* var x = [ 'beep', 'boop', 'foo', 'bar' ];
+*
+* var out = groupIndicesBy( x, indicator );
+* // returns { 'b': [ 0, 1, 3 ], 'f': [ 2 ] }
+*/
+function groupIndicesBy( x, indicator, thisArg ) {
+	var get;
+	var len;
+	var out;
+	var g;
+	var o;
+	var i;
+ 
+	// Get the number of elements to group:
+	len = x.length;
+ 
+	// Resolve an accessor for retrieving array elements:
+	get = resolveGetter( x );
+ 
+	// Loop over the elements and assign each to a group...
+	out = {};
+	for ( i = 0; i < len; i++ ) {
+		g = indicator.call( thisArg, get( x, i ), i, x );
+		o = out[ g ];
+		if ( isArray( o ) ) {
+			o.push( i );
+		} else {
+			out[ g ] = [ i ];
+		}
+	}
+	return out;
+}
+ 
+ 
+// EXPORTS //
+ 
+module.exports = groupIndicesBy;
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/array/base/index.html b/array/base/index.html index af6e6cfb60..955aaf5ae7 100644 --- a/array/base/index.html +++ b/array/base/index.html @@ -25,7 +25,7 @@

All files array/base/lib

100% Statements - 1203/1203 + 1212/1212
@@ -46,7 +46,7 @@

All files array/base/lib

100% Lines - 1203/1203 + 1212/1212
@@ -84,13 +84,13 @@

All files array/base/lib

100% - 1203/1203 + 1212/1212 100% 1/1 100% 0/0 100% - 1203/1203 + 1212/1212 @@ -101,7 +101,7 @@

All files array/base/lib