Skip to content

Commit

Permalink
build: dependencies update
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelBorde committed Mar 6, 2024
1 parent 5ebd575 commit a014142
Show file tree
Hide file tree
Showing 41 changed files with 5,925 additions and 4,348 deletions.
6 changes: 3 additions & 3 deletions benchmarks/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ run();
async function run() {
await benchmark(
() => map((f) => f(), createPromiseFuncs()),
"Map (concurrency: 3)"
"Map (concurrency: 3)",
);
await benchmark(
() => mapWithOptions((f) => f(), { concurrency: 1 }, createPromiseFuncs()),
"Map (concurrency: 1)"
"Map (concurrency: 1)",
);
await benchmark(
() => mapSeries((f) => f(), createPromiseFuncs()),
"Map series"
"Map series",
);
}

Expand Down
8 changes: 4 additions & 4 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const { timeout } = require("@arpinum/promising");

timeout(
300,
resolveAfter
resolveAfter,
)(5000)
.then(() => console.log("Will not be called"))
.catch(console.error);
Expand All @@ -198,7 +198,7 @@ const { timeoutWithOptions } = require("@arpinum/promising");
timeoutWithOptions(
300,
{ createError },
resolveAfter
resolveAfter,
)(5000)
.then(() => console.log("Will not be called"))
.catch(console.error);
Expand Down Expand Up @@ -274,7 +274,7 @@ queue.enqueue(() => eventuallyLog("3"));

function eventuallyLog(message) {
return new Promise((resolve) => setTimeout(resolve, 1000)).then(() =>
console.log(message)
console.log(message),
);
}
```
Expand Down Expand Up @@ -310,7 +310,7 @@ stack.push(() => eventuallyLog("3"));

function eventuallyLog(message) {
return new Promise((resolve) => setTimeout(resolve, 1000)).then(() =>
console.log(message)
console.log(message),
);
}
```
Expand Down
2 changes: 1 addition & 1 deletion examples/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ queue.enqueue(() => eventuallyLog("3"));

function eventuallyLog(message) {
return new Promise((resolve) => setTimeout(resolve, 1000)).then(() =>
console.log(message)
console.log(message),
);
}
2 changes: 1 addition & 1 deletion examples/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ queue.enqueue(() => eventuallyLog("3"));

function eventuallyLog(message: string) {
return new Promise((resolve) => setTimeout(resolve, 1000)).then(() =>
console.log(message)
console.log(message),
);
}
2 changes: 1 addition & 1 deletion examples/queueCapacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ setTimeout(() => clearInterval(interval), 5000);

function eventuallyPrint(iteration) {
return new Promise((resolve) => setTimeout(resolve, 700)).then(() =>
console.log(`Processing #${iteration}`)
console.log(`Processing #${iteration}`),
);
}
2 changes: 1 addition & 1 deletion examples/queueCapacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ setTimeout(() => clearInterval(interval), 5000);

function eventuallyPrint(iteration: number) {
return new Promise((resolve) => setTimeout(resolve, 700)).then(() =>
console.log(`Processing #${iteration}`)
console.log(`Processing #${iteration}`),
);
}
2 changes: 1 addition & 1 deletion examples/queueConcurrency.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ setTimeout(() => {

function eventuallyLog(message, delay) {
return new Promise((resolve) => setTimeout(resolve, delay)).then(() =>
console.log(message)
console.log(message),
);
}
2 changes: 1 addition & 1 deletion examples/queueConcurrency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ setTimeout(() => {

function eventuallyLog(message: string, delay: number) {
return new Promise((resolve) => setTimeout(resolve, delay)).then(() =>
console.log(message)
console.log(message),
);
}
2 changes: 1 addition & 1 deletion examples/retryEndlessly.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const readFileAsync = promisify(readFile);

const readFileAsyncWithRetry = retryWithOptions(
{ endlessly: true, onTryError },
readFileAsync
readFileAsync,
);

function onTryError(error) {
Expand Down
2 changes: 1 addition & 1 deletion examples/retryEndlessly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const readFileAsync = promisify(readFile);

const readFileAsyncWithRetry = retryWithOptions(
{ endlessly: true, onTryError },
readFileAsync
readFileAsync,
);

function onTryError(error: Error) {
Expand Down
2 changes: 1 addition & 1 deletion examples/retryWithOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const readFileAsync = promisify(readFile);

const readFileAsyncWithRetry = retryWithOptions(
{ count: 5, onTryError, onFinalError },
readFileAsync
readFileAsync,
);

function onTryError(error) {
Expand Down
2 changes: 1 addition & 1 deletion examples/retryWithOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const readFileAsync = promisify(readFile);

const readFileAsyncWithRetry = retryWithOptions(
{ count: 5, onTryError, onFinalError },
readFileAsync
readFileAsync,
);

function onTryError(error: Error) {
Expand Down
2 changes: 1 addition & 1 deletion examples/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ stack.push(() => eventuallyLog("5"));

function eventuallyLog(message) {
return new Promise((resolve) => setTimeout(resolve, 1000)).then(() =>
console.log(message)
console.log(message),
);
}
2 changes: 1 addition & 1 deletion examples/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ stack.push(() => eventuallyLog("5"));

function eventuallyLog(message: string) {
return new Promise((resolve) => setTimeout(resolve, 1000)).then(() =>
console.log(message)
console.log(message),
);
}
2 changes: 1 addition & 1 deletion examples/stackCapacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ setTimeout(() => clearInterval(interval), 5000);

function eventuallyPrint(iteration) {
return new Promise((resolve) => setTimeout(resolve, 700)).then(() =>
console.log(`Processing #${iteration}`)
console.log(`Processing #${iteration}`),
);
}
2 changes: 1 addition & 1 deletion examples/stackCapacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ setTimeout(() => clearInterval(interval), 5000);

function eventuallyPrint(iteration: number) {
return new Promise((resolve) => setTimeout(resolve, 700)).then(() =>
console.log(`Processing #${iteration}`)
console.log(`Processing #${iteration}`),
);
}
2 changes: 1 addition & 1 deletion examples/stackConcurrency.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ setTimeout(() => {

function eventuallyLog(message, delay) {
return new Promise((resolve) => setTimeout(resolve, delay)).then(() =>
console.log(message)
console.log(message),
);
}
2 changes: 1 addition & 1 deletion examples/stackConcurrency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ setTimeout(() => {

function eventuallyLog(message: string, delay: number) {
return new Promise((resolve) => setTimeout(resolve, delay)).then(() =>
console.log(message)
console.log(message),
);
}
2 changes: 1 addition & 1 deletion examples/timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { timeout } = require("../build");

timeout(
300,
resolveAfter
resolveAfter,
)(5000)
.then(() => console.log("Will not be called"))
.catch(console.error);
Expand Down
2 changes: 1 addition & 1 deletion examples/timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { timeout } from "../lib";

timeout(
300,
resolveAfter
resolveAfter,
)(5000)
.then(() => console.log("Will not be called"))
.catch(console.error);
Expand Down
2 changes: 1 addition & 1 deletion examples/timeoutWithOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { timeoutWithOptions } = require("../build");
timeoutWithOptions(
300,
{ createError },
resolveAfter
resolveAfter,
)(5000)
.then(() => console.log("Will not be called"))
.catch(console.error);
Expand Down
2 changes: 1 addition & 1 deletion examples/timeoutWithOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { timeoutWithOptions } from "../lib";
timeoutWithOptions(
300,
{ createError },
resolveAfter
resolveAfter,
)(5000)
.then(() => console.log("Will not be called"))
.catch(console.error);
Expand Down
2 changes: 1 addition & 1 deletion examples/wrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { wrap } from "../lib";
const parse = wrap(JSON.parse);

parse('{"message": "ok"}').then((o: { message: string }) =>
console.log(o.message)
console.log(o.message),
); // ok

parse("[}").catch((e: Error) => console.error(e.message)); // Unexpected token...
2 changes: 1 addition & 1 deletion lib/operations/compose.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe("Compose", () => {

return globalPromise.then(
() => Promise.reject(new Error("Should fail")),
(rejection) => expect(rejection.message).toEqual("bleh")
(rejection) => expect(rejection.message).toEqual("bleh"),
);
});

Expand Down
2 changes: 1 addition & 1 deletion lib/operations/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AnyFunction } from "../types";
import { wrap } from "./wrap";

export function compose(
functions: AnyFunction[] = []
functions: AnyFunction[] = [],
): (...args: any[]) => Promise<any> {
if (functions.length === 0) {
return (x) => Promise.resolve(x);
Expand Down
8 changes: 4 additions & 4 deletions lib/operations/delay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import {

function rawDelay<F extends AnyFunction>(
milliseconds: number,
func: F
func: F,
): PromisifiedFunction<F> {
return (...args: Parameters<F>) =>
new Promise((resolve) => setTimeout(resolve, milliseconds)).then(() =>
func(...args)
func(...args),
) as PromisifiedReturnType<F>;
}

const curriedDelay = autoCurry(rawDelay);

export function delay<F extends AnyFunction>(
milliseconds: number,
func: F
func: F,
): PromisifiedFunction<F>;
export function delay<F extends AnyFunction>(
milliseconds: number
milliseconds: number,
): (func: F) => PromisifiedFunction<F>;
export function delay<F extends AnyFunction>(
...args: any[]
Expand Down
10 changes: 5 additions & 5 deletions lib/operations/map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ describe("Map with options", () => {
const globalPromise = mapWithOptions(
rejectFor2,
{ concurrency: 3 },
[1, 2, 3]
[1, 2, 3],
);

return globalPromise.then(
() => Promise.reject(new Error("Should fail")),
(rejection: Error) => expect(rejection.message).toEqual("bleh")
(rejection: Error) => expect(rejection.message).toEqual("bleh"),
);

function rejectFor2(x: number) {
Expand All @@ -70,12 +70,12 @@ describe("Map with options", () => {
const globalPromise = mapWithOptions(
rejectForGreaterThan2,
{ concurrency: 3 },
[1, 2, 3]
[1, 2, 3],
);

return globalPromise.then(
() => Promise.reject(new Error("Should fail")),
(rejection: Error) => expect(rejection.message).toEqual("bleh2")
(rejection: Error) => expect(rejection.message).toEqual("bleh2"),
);

function rejectForGreaterThan2(x: number) {
Expand All @@ -97,7 +97,7 @@ describe("Map with options", () => {
const globalPromise = mapWithOptions(
(f) => f(),
{ concurrency: 4 },
functions
functions,
);

return globalPromise.then(() => {
Expand Down
20 changes: 10 additions & 10 deletions lib/operations/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface Options {
function rawMapWithOptions<T1, T2>(
func: (v: T1) => T2 | Promise<T2>,
options: Options,
values: T1[]
values: T1[],
): Promise<T2[]> {
const opts = Object.assign({}, { concurrency: 3 }, options);
return doRawMapWithOptions(wrap(func), opts, values);
Expand All @@ -16,7 +16,7 @@ function rawMapWithOptions<T1, T2>(
function doRawMapWithOptions<T1, T2>(
func: (v: T1) => Promise<T2>,
options: Required<Options>,
values: T1[]
values: T1[],
): Promise<T2[]> {
if (values.length === 0) {
return Promise.resolve([]);
Expand Down Expand Up @@ -77,10 +77,10 @@ const curriedMapWithOptions = autoCurry(rawMapWithOptions);
export function mapWithOptions<T1, T2>(
func: (v: T1) => T2 | Promise<T2>,
options: Options,
values: T1[]
values: T1[],
): Promise<T2[]>;
export function mapWithOptions<T1, T2>(
func: (v: T1) => T2 | Promise<T2>
func: (v: T1) => T2 | Promise<T2>,
): (options: Options) => (values: T1[]) => Promise<T2[]>;
export function mapWithOptions<T1, T2>(
...args: any[]
Expand All @@ -90,7 +90,7 @@ export function mapWithOptions<T1, T2>(

function rawMap<T1, T2>(
func: (v: T1) => T2 | Promise<T2>,
values: T1[]
values: T1[],
): Promise<T2[]> {
return rawMapWithOptions(func, {}, values);
}
Expand All @@ -99,10 +99,10 @@ const curriedMap = autoCurry(rawMap);

export function map<T1, T2>(
func: (v: T1) => T2 | Promise<T2>,
values: T1[]
values: T1[],
): Promise<T2[]>;
export function map<T1, T2>(
func: (v: T1) => T2 | Promise<T2>
func: (v: T1) => T2 | Promise<T2>,
): (values: T1[]) => Promise<T2[]>;
export function map<T1, T2>(
...args: any[]
Expand All @@ -112,7 +112,7 @@ export function map<T1, T2>(

function rawMapSeries<T1, T2>(
func: (v: T1) => T2 | Promise<T2>,
values: T1[]
values: T1[],
): Promise<T2[]> {
return rawMapWithOptions(func, { concurrency: 1 }, values);
}
Expand All @@ -121,10 +121,10 @@ const curriedMapSeries = autoCurry(rawMapSeries);

export function mapSeries<T1, T2>(
func: (v: T1) => T2 | Promise<T2>,
values: T1[]
values: T1[],
): Promise<T2[]>;
export function mapSeries<T1, T2>(
func: (v: T1) => T2 | Promise<T2>
func: (v: T1) => T2 | Promise<T2>,
): (values: T1[]) => Promise<T2[]>;
export function mapSeries<T1, T2>(
...args: any[]
Expand Down
2 changes: 1 addition & 1 deletion lib/operations/pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AnyFunction } from "../types";
import { compose } from "./compose";

export function pipe(
functions: AnyFunction[] = []
functions: AnyFunction[] = [],
): (...args: any[]) => Promise<any> {
return compose(functions.slice().reverse());
}
Loading

0 comments on commit a014142

Please sign in to comment.