UNPKG

@ce1pers/array-helpers

Version:
34 lines (30 loc) 1.61 kB
import { ObjectArraySorterInput } from "./types"; /** * Sorts an object array based on the provided 'sortBy' and 'sortByType'. * * @throws {Error} Throws an type error if the 'array' argument type is not array. * @throws {Error} Throws an type error if the 'sortByType' is not supported. */ export declare const objectArraySorter: <T = any>(input: ObjectArraySorterInput<T>) => any[]; /** * 중복되지 않는 조합에 대한 모든 경우의 수를 가져옵니다. * 조합은 서로 다른 n개의 원소를 가지고 순서에 상관없이 r개의 원소를 선택하는 것이다. * Input: [1, 2, 3] * Output: [ [1, 2], [1, 3], [2, 3] ] */ export declare const getCombinations: <T>(arr: T[], num: number) => T[][]; /** * 중복을 허용하는 순열에 대한 모든 경우의 수를 가져옵니다. * 순열은 서로 다른 n개의 원소를 가지고 중복 없이 순서에 상관있게 r개의 원소를 선택 혹은 나열 하는것이다. * Input: [1, 2, 3] * Output: [ [1, 2], [1, 3], [2, 1], [2, 3], [3, 1], [3, 2] ] */ export declare const getPermutations: <T>(arr: T[], num: number) => T[][]; /** * 중복순열에 대한 모든 경우의 수를 가져옵니다. * 중복순열은 서로 다른 n개의 원소를 가지고 중복을 허용하여 r개의 원소를 선택 혹은 나열 하는것이다. * (중복을 허용한다는건 본인 숫자의 중복을 의미한다.) * Input: [1, 2, 3] * Output: [ [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3] ] */ export declare const getPermutationsWithSelf: <T>(arr: T[], num: number) => T[][];