Socket
Socket
Sign inDemoInstall

array-last

Package Overview
Dependencies
2
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 1.0.0

20

index.js

@@ -8,7 +8,19 @@ /*!

module.exports = function last(arr) {
if (arr == null || arr.length < 1) {
return undefined;
var isNumber = require('is-number');
var slice = require('array-slice');
module.exports = function last(arr, num) {
if (!Array.isArray(arr)) {
throw new Error('array-last expects an array as the first argument.')
}
return arr[arr.length - 1];
if (arr.length === 0) {
return null;
}
var res = slice(arr, arr.length - (isNumber(num) ? num : 1));
if (num === 1 || num == null) {
return res[0];
}
return res;
};

43

package.json
{
"name": "array-last",
"description": "Get the last element in an array.",
"version": "0.1.0",
"description": "Get the last or last n elements in an array.",
"version": "1.0.0",
"homepage": "https://github.com/jonschlinkert/array-last",

@@ -17,17 +17,6 @@ "author": {

},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/jonschlinkert/array-last/blob/master/LICENSE-MIT"
}
],
"keywords": [
"docs",
"documentation",
"generate",
"generator",
"markdown",
"templates",
"verb"
],
"license": {
"type": "MIT",
"url": "https://github.com/jonschlinkert/array-last/blob/master/LICENSE-MIT"
},
"main": "index.js",

@@ -41,9 +30,19 @@ "engines": {

"devDependencies": {
"chai": "~1.9.1",
"gulp": "^3.8.5",
"gulp-es6-module-transpiler": "^0.1.2",
"gulp-traceur": "^0.7.0",
"mocha": "*",
"should": "^4.3.1",
"verb": "~0.2.6"
}
},
"dependencies": {
"array-slice": "^0.2.2",
"is-number": "^0.1.1"
},
"keywords": [
"docs",
"documentation",
"generate",
"generator",
"markdown",
"templates",
"verb"
]
}

@@ -1,7 +0,7 @@

# array-last [![NPM version](https://badge.fury.io/js/array-last.png)](http://badge.fury.io/js/array-last)
# array-last [![NPM version](https://badge.fury.io/js/array-last.svg)](http://badge.fury.io/js/array-last)
> Get the last element in an array.
> Get the last or last n elements in an array.
## Install
Install with [npm](npmjs.org):
### Install with [npm](npmjs.org):

@@ -16,5 +16,11 @@ ```bash

var last = require('array-last');
var arr = ['a', 'b', 'c'];
console.log(last(arr));
//=> 'c'
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']
```

@@ -30,3 +36,3 @@

## License
Copyright (c) 2014 Jon Schlinkert, contributors.
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license

@@ -36,2 +42,2 @@

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on June 28, 2014._
_This file was generated by [verb](https://github.com/assemble/verb) on December 12, 2014. To update, run `npm i -g verb && verb`._

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc