package/package.json000644 0000002772 13210000617011563 0ustar00000000 000000 { "name": "array-last", "description": "Get the last or last n elements in an array.", "version": "1.3.0", "homepage": "https://github.com/jonschlinkert/array-last", "author": "Jon Schlinkert (https://github.com/jonschlinkert)", "contributors": [ "Ben Drucker (http://www.bendrucker.me)", "Blaine Bublitz (https://twitter.com/BlaineBublitz)", "Jon Schlinkert (http://twitter.com/jonschlinkert)", "Stephen A. Wilson (https://github.com/SpyMaster356)" ], "repository": "jonschlinkert/array-last", "bugs": { "url": "https://github.com/jonschlinkert/array-last/issues" }, "license": "MIT", "files": [ "index.js" ], "main": "index.js", "engines": { "node": ">=0.10.0" }, "scripts": { "test": "mocha" }, "dependencies": { "is-number": "^4.0.0" }, "devDependencies": { "ansi-bold": "^0.1.1", "array-slice": "^1.0.0", "benchmarked": "^1.1.1", "gulp-format-md": "^1.0.0", "matched": "^1.0.2", "mocha": "^3.5.0" }, "keywords": [ "array", "fast", "first", "initial", "javascript", "js", "last", "rest", "util", "utility", "utils" ], "verb": { "run": true, "toc": false, "layout": "default", "tasks": [ "readme" ], "plugins": [ "gulp-format-md" ], "related": { "list": [ "arr-union", "array-unique", "array-xor" ] }, "reflinks": [ "verb" ], "lint": { "reflinks": true } } } package/index.js000644 0000001057 13210000335010732 0ustar00000000 000000 /*! * array-last * * Copyright (c) 2014-2017, Jon Schlinkert. * Released under the MIT License. */ var isNumber = require('is-number'); module.exports = function last(arr, n) { if (!Array.isArray(arr)) { throw new Error('expected the first argument to be an array'); } var len = arr.length; if (len === 0) { return null; } n = isNumber(n) ? +n : 1; if (n === 1) { return arr[len - 1]; } var res = new Array(n); while (n--) { res[n] = arr[--len]; } return res; }; package/LICENSE000644 0000002100 12670142056010300 0ustar00000000 000000 The MIT License (MIT) Copyright (c) 2014-2017, Jon Schlinkert. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package/README.md000744 0000006612 12670142304010563 0ustar00000000 000000 # array-last [![NPM version](https://img.shields.io/npm/v/array-last.svg?style=flat)](https://www.npmjs.com/package/array-last) [![NPM monthly downloads](https://img.shields.io/npm/dm/array-last.svg?style=flat)](https://npmjs.org/package/array-last) [![NPM total downloads](https://img.shields.io/npm/dt/array-last.svg?style=flat)](https://npmjs.org/package/array-last) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/array-last.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/array-last) > Get the last or last n elements in an array. Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save array-last ``` ## Usage ```js var last = require('array-last'); last(['a', 'b', 'c', 'd', 'e', 'f']); //=> 'f' last(['a', 'b', 'c', 'd', 'e', 'f'], 1); //=> 'f' last(['a', 'b', 'c', 'd', 'e', 'f'], 3); //=> ['d', 'e', 'f'] ``` ## About
Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
Running Tests Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: ```sh $ npm install && npm test ```
Building docs _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ To generate the readme, run the following command: ```sh $ npm install -g verbose/verb#dev verb-generate-readme && verb ```
### Related projects You might also be interested in these projects: * [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://github.com/jonschlinkert/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union) * [array-unique](https://www.npmjs.com/package/array-unique): Remove duplicate values from an array. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique) * [array-xor](https://www.npmjs.com/package/array-xor): Returns the symmetric difference (exclusive-or) of an array of elements (elements that are present in… [more](https://github.com/jonschlinkert/array-xor) | [homepage](https://github.com/jonschlinkert/array-xor) ### Contributors | **Commits** | **Contributor** | | --- | --- | | 19 | [jonschlinkert](https://github.com/jonschlinkert) | | 3 | [SpyMaster356](https://github.com/SpyMaster356) | | 2 | [bendrucker](https://github.com/bendrucker) | | 2 | [phated](https://github.com/phated) | ### Author **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) * [twitter/jonschlinkert](https://twitter.com/jonschlinkert) ### License Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). Released under the [MIT License](LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on November 30, 2017._