Function sampleSize

  • Gets n random elements at unique keys from collection up to the size of collection.

    Differences from lodash:

    • no special treatment given to fraction values of n

    Contribution to minified bundle size, when it is the only function imported:

    • Lodash: 5,786 bytes
    • Micro-dash: 826 bytes

    Type Parameters

    • T

    Parameters

    • array: Nil | readonly T[]
    • Optional n: number

    Returns T[]

  • Type Parameters

    • T

    Parameters

    • object: Nil | T
    • Optional n: number

    Returns T[keyof T][]