first-of-array

    0.0.2 • Public • Published

    first-of-array

    Return the first element in an array. Is tested.

    ##Overview

    The module can be used when you need a function that returns the first element of an array

    ##Installing

    npm i first-of-array --save-dev

    ##Usage

    Simply require the first-of-array module. The export function can be used in any module you desire:

    const first = require('first-of-array');
    
    first([1,100,1000); // 1
    first([['Ahad', 12, 10000], 12, 'Three', true]); // ['Ahad', 12, 10000]

    ##TODO

    • add more tests

    ##Tests

    npm test

    Also supports the standards JavaScript library, configure as follows:

    "standard": {
        "ignore": [
          "/test/test.js",
          "app.js"
        ]
      }
    first([1,2,3,4,5]);                  // ==> returns a number
    first([['Ahad',2,3,4,5]);            // ==> returns a string
    first([[1,2e10],2,3,4,5])            // ==> returns only the first element
    first([[true, false], 'id', 1004]);  // ==> returns the first element, even if is array
    first([]);                           // ==> returns undefined, if passed empty array

    ##Related Modules

    is-even-integer

    ##Contributing

    Feel free to file an issue or bug.

    Install

    npm i first-of-array

    DownloadsWeekly Downloads

    0

    Version

    0.0.2

    License

    MIT

    Last publish

    Collaborators

    • ahadb