Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils/group-own/docs/types/index.d"

Index

Interfaces

Type aliases

Functions

Type aliases

Binary

Binary<V, K>: (value: V, key: string) => K

Specifies which group a property belongs to.

param

object value

param

object key

returns

group key

Type parameters

  • V

  • K: string | symbol

Type declaration

    • (value: V, key: string): K
    • Parameters

      • value: V
      • key: string

      Returns K

Indicator

Indicator<V, K>: Nullary<K> | Unary<V, K> | Binary<V, K>

Specifies which group a property belongs to.

param

object value

param

object key

returns

group key

Type parameters

  • V

  • K: string | symbol

Nullary

Nullary<K>: () => K

Specifies which group a property belongs to.

returns

group key

Type parameters

  • K: string | symbol

Type declaration

    • (): K
    • Returns K

Unary

Unary<V, K>: (value: V) => K

Specifies which group a property belongs to.

param

object value

returns

group key

Type parameters

  • V

  • K: string | symbol

Type declaration

    • (value: V): K
    • Parameters

      • value: V

      Returns K

Functions

Export assignment groupOwn

  • groupOwn<T, K>(obj: T, indicator: Indicator<T[keyof T], K>): {}
  • groupOwn<T, K>(obj: T, options: Options & { returns: "indices" }, indicator: Indicator<T[keyof T], K>): {}
  • groupOwn<T, K>(obj: T, options: Options & { returns: "*" }, indicator: Indicator<T[keyof T], K>): {}
  • groupOwn<T, K>(obj: T, options: Options & { returns?: undefined | "values" }, indicator: Indicator<T[keyof T], K>): {}
  • Groups an object's own property values according to an indicator function.

    Notes

    • When invoked, the indicator function is provided two arguments:

      • value: object value
      • key: object key
    • The value returned by an indicator function should be a value which can be serialized as an object key.

    • If provided an empty object, the function returns an empty object.

    • The function iterates over an object's own properties.

    • Key iteration order is not guaranteed, and, thus, result order is not guaranteed.

    Type parameters

    • T: object

    • K: string | symbol

    Parameters

    • obj: T

      input object

    • indicator: Indicator<T[keyof T], K>

      indicator function indicating which group an element in the input object belongs to

    Returns {}

    group results

    Example

    function indicator( v ) {
        return v[ 0 ];
    }
    var obj = {
        'a': 'apple',
        'b': 'banana',
        'c': 'cherry',
        'd': 'date'
    };
    var out = groupOwn( obj, indicator );
    // e.g., returns { 'a': [ 'apple' ], 'b': [ 'banana' ], 'c': [ 'cherry' ], 'd': [ 'date' ] }
  • Groups an object's own property values according to an indicator function.

    Notes

    • When invoked, the indicator function is provided two arguments:

      • value: object value
      • key: object key
    • The value returned by an indicator function should be a value which can be serialized as an object key.

    • If provided an empty object, the function returns an empty object.

    • The function iterates over an object's own properties.

    • Key iteration order is not guaranteed, and, thus, result order is not guaranteed.

    Type parameters

    • T: object

    • K: string | symbol

    Parameters

    • obj: T

      input object

    • options: Options & { returns: "indices" }

      function options

    • indicator: Indicator<T[keyof T], K>

      indicator function indicating which group an element in the input object belongs to

    Returns {}

    group results

    Example

    function indicator( v ) {
        return v[ 0 ];
    }
    var obj = {
        'a': 'apple',
        'b': 'banana',
        'c': 'cherry',
        'd': 'date'
    };
    var opts = {
        'returns': 'indices'
    };
    var out = groupOwn( obj, opts, indicator );
    // e.g., returns { 'a': [ 'a' ], 'b': [ 'b' ], 'c': [ 'c' ], 'd': [ 'd' ] }
  • Groups an object's own property values according to an indicator function.

    Notes

    • When invoked, the indicator function is provided two arguments:

      • value: object value
      • key: object key
    • The value returned by an indicator function should be a value which can be serialized as an object key.

    • If provided an empty object, the function returns an empty object.

    • The function iterates over an object's own properties.

    • Key iteration order is not guaranteed, and, thus, result order is not guaranteed.

    Type parameters

    • T: object

    • K: string | symbol

    Parameters

    • obj: T

      input object

    • options: Options & { returns: "*" }

      function options

    • indicator: Indicator<T[keyof T], K>

      indicator function indicating which group an element in the input object belongs to

    Returns {}

    group results

    Example

    function indicator( v ) {
        return v[ 0 ];
    }
    var obj = {
        'a': 'apple',
        'b': 'banana',
        'c': 'cherry',
        'd': 'date'
    };
    var opts = {
        'returns': '*'
    };
    var out = groupOwn( obj, opts, indicator );
    // e.g., returns { 'a': [ [ 'a', 'apple' ] ], 'b': [ [ 'b', 'banana' ] ], 'c': [ [ 'c', 'cherry' ] ], 'd': [ [ 'd', 'date' ] ] }
  • Groups an object's own property values according to an indicator function.

    Notes

    • When invoked, the indicator function is provided two arguments:

      • value: object value
      • key: object key
    • The value returned by an indicator function should be a value which can be serialized as an object key.

    • If provided an empty object, the function returns an empty object.

    • The function iterates over an object's own properties.

    • Key iteration order is not guaranteed, and, thus, result order is not guaranteed.

    Type parameters

    • T: object

    • K: string | symbol

    Parameters

    • obj: T

      input object

    • options: Options & { returns?: undefined | "values" }

      function options

    • indicator: Indicator<T[keyof T], K>

      indicator function indicating which group an element in the input object belongs to

    Returns {}

    group results

    Example

    function indicator( v ) {
        return v[ 0 ];
    }
    var obj = {
        'a': 'apple',
        'b': 'banana',
        'c': 'cherry',
        'd': 'date'
    };
    var opts = {
        'returns': 'values'
    };
    var out = groupOwn( obj, opts, indicator );
    // e.g., returns { 'a': [ 'apple' ], 'b': [ 'banana' ], 'c': [ 'cherry' ], 'd': [ 'date' ] }