conductor
Why I'm building conductorGitHub
v1.5.0
v1.5.0
  • Introduction
  • Overview
    • Introduction
    • Core concepts
  • API reference
    • always
    • append
    • apply
    • arity
    • branch
    • capitalize
    • compose
    • concat
    • curry
    • curryN
    • delay
    • dump
    • entries
    • equals
    • equalsBy
    • factory
    • filter
    • findIndex
    • flatten
    • flip
    • forEach
    • get
    • head
    • ifElse
    • identity
    • into
    • isPromise
    • iterate
    • join
    • keys
    • map
    • merge
    • mergeBy
    • next
    • not
    • pluck
    • prepend
    • random
    • reduce
    • replace
    • slice
    • some
    • split
    • take
    • then
    • toLowerCase
    • transduce
    • transformers
      • transformers/filter
      • transformers/map
    • type
    • upsert
    • values
  • Guides
    • example use cases
    • checkGuards
Powered by GitBook
On this page
  • description
  • examples
  • using a positive count argument
  • using a negative count argument
  • using a count argument greater than the array's length
  1. API reference

take

PrevioussplitNextthen

Last updated 6 years ago

take :: (Integer count, Array input) => Array output

Available since v1.5.0

description

take returns a new array only keeping the first count elements of the input array. If count is negative, take returns the last count elements.

examples

using a positive count argument

import { take } from 'conductor'

take(2, [1, 2, 3]) // [1, 2]

using a negative count argument

import { take } from 'conductor'

take(-2, [1, 2, 3]) // [2, 3]

using a count argument greater than the array's length

import { take } from 'conductor'

take(100, [1, 2, 3]) // [1, 2, 3]
See source code