any value to take elements from. Usually an Array
, Object
, Map
, Iterator
etc. but you can also pass single values, like a number
, string
etc - see loopSingles
option.
the number of elements to take. If a function
, it will be called with (item, keyIdx, value, count)
. If it returns true
it will take items, as soon as it returns false
or z.STOP
it stops taking items.
Optional
options: Toptionsyou can optionally pass an IloopOptions
object to control which keys / idx are visited (own / inherited / enumerable etc) and more.
z.filter
for filtering elements - the filterSingles
option also applies here: if take
is used with isSingle
values, filterSingles
must be true
or it will throw an error.
Takes
n
elements from the beginning of the value (Array
,Object
,Set
,Map
etc). Ifn
is a function, it stops as soon as it returnsfalse
orz.STOP
.If
options.props
& value is an_.isObject()
other thanrealObject
, it will retrieve (i.eclone
) both:n
keys/idx of the value (eg the Array elements, Set items etc)n
of propsNote: No guaranteed order for property bags like
Objects
,Sets
,Maps
etc and return the same value type of input value.