New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

just-last

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

just-last - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

1

index.d.ts

@@ -9,2 +9,3 @@ /**

*/
export default function last<T>(arr: readonly [...any, T]): T;
export default function last<T>(arr: T[]): T;

@@ -6,8 +6,18 @@ import last from './index'

const test2: number[] = last([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
const test3: { d: number } = last([{ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }]);
const test4: RegExp = last(["a", 1, true, /r/g]);
const test5: number = last([1]);
const test6: undefined = last([]);
//you have to be a bit more generic when array has mixed types
const test3: object = last([{ a: 1 }, { b: 2 }, { c: 3 }, { d: 4 }]);
const test4: any = last(['a', 1, true, /r/g]);
// make sure it works with readonly arrays
const test7: 5 = last([1, 2, 3, 4, 5] as const);
// make sure it works with dynamic arrays and not just static ones
const dynArr = [1, 2, 3];
dynArr.push(4);
const test8: number = last(dynArr);
const dynArr2: (number | string)[] = [1, 2];
dynArr2.push("hi");
const test9: number | string = last(dynArr2);
// Not OK

@@ -14,0 +24,0 @@ // @ts-expect-error

2

package.json
{
"name": "just-last",
"version": "3.0.0",
"version": "3.0.1",
"description": "return the last member of an array",

@@ -5,0 +5,0 @@ "main": "index.js",

## just-last
Part of a [library](../../../../) of zero-dependency npm modules that do just do one thing.
Part of a [library](https://anguscroll.com/just) of zero-dependency npm modules that do just do one thing.
Guilt-free utilities for every occasion.
[Try it now](http://anguscroll.com/just/just-last)
[`🍦 Try it`](https://anguscroll.com/just/just-last)
```shell
npm install just-last
```
```shell
yarn add just-last
```
Return the last member of an array
```js

@@ -19,1 +28,2 @@ import last from 'just-last';

```
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc