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 2.2.0 to 2.3.0

14

index.d.ts

@@ -1,5 +0,9 @@

type ArrayWithLastType<Last> = [...unknown[], Last]
export default function last(arr: []): undefined
export default function last<Last>(arr: ArrayWithLastType<Last>): Last
export default function last<Last>(arr: ArrayWithLastType<Last> | []): Last | undefined
/**
* returns the last item in an array
* @example
* last([0, 1, 2, 3])
* // => 3
* last([])
* // => undefined
*/
export default function last<T>(arr: T[]): T;

@@ -6,6 +6,7 @@ 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]);

@@ -20,2 +21,2 @@ // Not OK

// @ts-expect-error
last();
last();
{
"name": "just-last",
"version": "2.2.0",
"version": "2.3.0",
"description": "return the last member of an array",

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

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