Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

initial

v4.17.11arrow_drop_down
v4.17.11
STATUS
Passing
DOWNLOADS
161
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
A year ago
SIZE
630 B
Gets all but the last element of `array`.
1 contributor
Install initial as a package?
Copied
npm i @bit/lodash.lodash.initial
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
initial.js
22 Lines(6 sloc)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import baseSlice from './_baseSlice.js';

/**
 * Gets all but the last element of `array`.
 *
 * @static
 * @memberOf _
 * @since 0.1.0
 * @category Array
 * @param {Array} array The array to query.
 * @returns {Array} Returns the slice of `array`.
 * @example
 *
 * _.initial([1, 2, 3]);
 * // => [1, 2]
 */
function initial(array) {
  var length = array == null ? 0 : array.length;
  return length ? baseSlice(array, 0, -1) : [];
}

export default initial;