Takes exactly the given count of elements.

Type signature

(count: number) => (xs: any[]) => any[]

Examples

exact(5)([1, 2, 3]);
// ⇒ [1, 2, 3, undefined, undefined]
Try in REPL
exact(2)([1, 2, 3]);
// ⇒ [1, 2]
Try in REPL

Questions

  • How to get exactly N elements out of an array?

TypeScript sourceJavaScript source