Debian Codegraph @

node/rxjs/src/internal/util/mapOneOrManyArgs.ts

raw
1 import { OperatorFunction } from "../types";
2 import { map } from "../operators/map";
3
4 const { isArray } = Array;
5
6 function callOrApply<T, R>(fn: ((...values: T[]) => R), args: T|T[]): R {
7 return isArray(args) ? fn(...args) : fn(args);
8 }
9
10 /**
11 * Used in several -- mostly deprecated -- situations where we need to
12 * apply a list of arguments or a single argument to a result selector.
13 */
14 export function mapOneOrManyArgs<T, R>(fn: ((...values: T[]) => R)): OperatorFunction<T|T[], R> {
15 return map(args => callOrApply(fn, args))
16 }