array-head

0.1.0 • Public • Published

array-head

Returns the first element of the array or undefined given an empty or non-array value.

Build Status Code Climate js-standard-style

npm install array-head --save

You can also use Duo, Bower or download the files manually.

npm stats

npm NPM downloads Dependency Status

API Example

Pointful
var first = require('array-head')
first([25, 20, 15, 10])
//=> 25
Pointfree Style
var first = require('array-head')
var lists = [
  ['a', 'b', 'c'],
  [1, 2, 3]
]
 
lists.map(first)
//=> ['a', 1]

API

first(val)

arguments
  • val (Array) Array.
returns
  • (*) First element of the array or undefined given an empty or non-array value.

Alternatives

  • x => x[0]
  • function (x) { return x[0] }

Contributing

SEE: contributing.md

Licenses

GitHub license

Package Sidebar

Install

npm i array-head

Weekly Downloads

10

Version

0.1.0

License

MIT

Last publish

Collaborators

  • wilmoore