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

gensequence

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gensequence - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

6

lib/src/GenSequence.d.ts

@@ -8,4 +8,6 @@ export declare type Maybe<T> = T | undefined;

/** reduce function see Array.reduce */
reduce(fnReduce: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): Maybe<T>;
reduce<U>(fnReduce: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
reduce(fnReduce: (previousValue: T, currentValue: T, currentIndex: number) => T): Maybe<T>;
reduce<U>(fnReduce: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U;
reduceToSequence<U, V extends GenIterable<U>>(fnReduce: (previousValue: V, currentValue: T, currentIndex: number) => V, initialValue: V): Sequence<U>;
reduceToSequence<U>(fnReduce: (previousValue: GenIterable<U>, currentValue: T, currentIndex: number) => GenIterable<U>, initialValue: GenIterable<U>): Sequence<U>;
scan(fnReduce: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): Sequence<T>;

@@ -12,0 +14,0 @@ scan<U>(fnReduce: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): Sequence<U>;

@@ -11,2 +11,5 @@ "use strict";

},
reduceToSequence: (fnReduce, initialValue) => {
return genSequence(reduce(fnReduce, initialValue, i));
},
scan: (fnReduce, initValue) => {

@@ -13,0 +16,0 @@ return genSequence(scan(i, fnReduce, initValue));

{
"name": "gensequence",
"version": "0.2.1",
"version": "0.2.2",
"description": "Small library to simplify working with Generators and Iterators in Javascript / Typescript",

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

@@ -51,2 +51,16 @@ import { genSequence, objectToSequence } from './GenSequence';

it('tests reducing a sequence to a sequence', () => {
const values = [1, 2, 3, 4, 5];
const gs = genSequence(values);
const result = gs.reduceToSequence<number>((a, v) => [...a, v], []);
expect(result.toArray()).to.deep.equal(values);
});
it('tests reducing a sequence to a Set to a sequence', () => {
const values = [1, 2, 3, 3, 4, 5, 5];
const gs = genSequence(values);
const result = gs.reduceToSequence<number, Set<number>>((a, v) => a.add(v), new Set<number>());
expect(result.toArray()).to.deep.equal([1, 2, 3, 4, 5]);
});
it('tests combine', () => {

@@ -53,0 +67,0 @@ const a = [1, 2, 3];

@@ -10,4 +10,6 @@

/** reduce function see Array.reduce */
reduce(fnReduce: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): Maybe<T>;
reduce<U>(fnReduce: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
reduce(fnReduce: (previousValue: T, currentValue: T, currentIndex: number) => T): Maybe<T>;
reduce<U>(fnReduce: (previousValue: U, currentValue: T, currentIndex: number) => U, initialValue: U): U;
reduceToSequence<U, V extends GenIterable<U>>(fnReduce: (previousValue: V, currentValue: T, currentIndex: number) => V, initialValue: V): Sequence<U>;
reduceToSequence<U>(fnReduce: (previousValue: GenIterable<U>, currentValue: T, currentIndex: number) => GenIterable<U>, initialValue: GenIterable<U>): Sequence<U>;
scan(fnReduce: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): Sequence<T>;

@@ -43,2 +45,5 @@ scan<U>(fnReduce: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): Sequence<U>;

},
reduceToSequence: <U>(fnReduce: (previousValue: GenIterable<U>, currentValue: T, currentIndex: number) => GenIterable<U>, initialValue: GenIterable<U>): Sequence<U> => {
return genSequence<U>(reduce<T, GenIterable<U>>(fnReduce, initialValue!, i));
},
scan: <U>(fnReduce: (prevValue: U, curValue: T, curIndex: number) => U, initValue?: U) => {

@@ -45,0 +50,0 @@ return genSequence(scan(i, fnReduce, initValue));

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