/*
* @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.
*/
// TypeScript Version: 4.1
///
import { Collection, AccessorArrayLike } from '@stdlib/types/array';
/**
* Object key.
*/
type Key = string | symbol | number;
/**
* Specifies which group an element in the input array belongs to.
*
* @returns object key
*/
type Nullary = ( this: U ) => Key;
/**
* Specifies which group an element in the input array belongs to.
*
* @param value - current array element
* @returns object key
*/
type Unary = ( this: U, value: T ) => Key;
/**
* Specifies which group an element in the input array belongs to.
*
* @param value - current array element
* @param index - current array element index
* @returns object key
*/
type Binary = ( this: U, value: T, index: number ) => Key;
/**
* Specifies which group an element in the input array belongs to.
*
* @param value - current array element
* @param index - current array element index
* @param arr - input array
* @returns object key
*/
type Ternary = ( this: U, value: T, index: number, arr: Collection ) => Key;
/**
* Specifies which group an element in the input array belongs to.
*
* @param value - current array element
* @param index - current array element index
* @param arr - input array
* @returns object key
*/
type Indicator = Nullary | Unary | Binary | Ternary;
/**
* Interface describing returned group results.
*/
interface ValuesResults {
/**
* Object properties.
*/
[key: K]: Array;
}
/**
* Groups element values according to an indicator function.
*
* @param x - input array
* @param indicator - indicator function specifying which group an element in the input array belongs to
* @param thisArg - indicator function execution context
* @returns group results
*
* @example
* function indicator( v ) {
* return v[ 0 ];
* }
*
* var x = [ 'beep', 'boop', 'foo', 'bar' ];
*
* var out = groupValuesBy( x, indicator );
* // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] }
*/
declare function groupValuesBy( x: Collection | AccessorArrayLike, indicator: Indicator, thisArg?: ThisParameterType> ): ValuesResults;
// EXPORTS //
export = groupValuesBy;