Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@async-generators/last

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@async-generators/last - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

2

dist/commonjs/index.d.ts
export default function <T>(source: AsyncIterable<T> | Iterable<T>): Promise<T | undefined>;
export default function <T>(source: AsyncIterable<T> | Iterable<T>, predicate: (item: T) => boolean): Promise<T | undefined>;
export default function <T>(source: AsyncIterable<T> | Iterable<T>, predicate: (item: T) => Promise<boolean> | boolean): Promise<T | undefined>;

@@ -5,12 +5,16 @@ "use strict";

async function basic(source) {
let last = undefined;
for await (let item of iterable_1.default(source)) {
return item;
last = item;
}
return last;
}
async function predicated(source, predicate) {
let last = undefined;
for await (let item of iterable_1.default(source)) {
if (predicate(item)) {
return item;
if (await predicate(item)) {
last = item;
}
}
return last;
}

@@ -17,0 +21,0 @@ function default_1(source, predicate) {

export default function <T>(source: AsyncIterable<T> | Iterable<T>): Promise<T | undefined>;
export default function <T>(source: AsyncIterable<T> | Iterable<T>, predicate: (item: T) => boolean): Promise<T | undefined>;
export default function <T>(source: AsyncIterable<T> | Iterable<T>, predicate: (item: T) => Promise<boolean> | boolean): Promise<T | undefined>;
import iterable from '@async-generators/iterable';
async function basic(source) {
let last = undefined;
for await (let item of iterable(source)) {
return item;
last = item;
}
return last;
}
async function predicated(source, predicate) {
let last = undefined;
for await (let item of iterable(source)) {
if (predicate(item)) {
return item;
if (await predicate(item)) {
last = item;
}
}
return last;
}

@@ -14,0 +18,0 @@ export default function (source, predicate) {

{
"name": "@async-generators/last",
"description": "get the last (predicated) item from a source iterable",
"version": "0.1.1",
"version": "0.1.2",
"author": {

@@ -6,0 +6,0 @@ "name": "Meirion Hughes",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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