Skip to content

Commit b34257e

Browse files
committed
feat: drop support for Node 10
1 parent 8f4f2b1 commit b34257e

File tree

9 files changed

+857
-1251
lines changed

9 files changed

+857
-1251
lines changed

.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package-lock.json
2+
yarn.lock
3+
build
4+
pkg
5+
coverage

docs/task-instance.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ Expand the error types of a task. Purely a TypeScript type system modification.
7676
{% tab title="Usage" %}
7777
7878
```typescript
79-
const task: Task<number | AnotherErrorPossibility, number> = Task.fail(
80-
5,
81-
).errorUnion<AnotherErrorPossibility>()
79+
const task: Task<number | AnotherErrorPossibility, number> =
80+
Task.fail(5).errorUnion<AnotherErrorPossibility>()
8281
```
8382

8483
{% endtab %}

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@
7474
"eslint-plugin-prettier": "^3.4.0",
7575
"gzip-size-cli": "^5.0.0",
7676
"husky": "^6.0.0",
77-
"jest": "^26.6.3",
77+
"jest": "^27.0.0",
7878
"lint-staged": "^11.0.0",
7979
"prettier": "^2.3.0",
8080
"semantic-release": "^17.4.3",
8181
"terser": "^5.7.0",
82-
"ts-jest": "^26.5.5",
82+
"ts-jest": "^27.0.0",
8383
"ts-toolbelt": "^9.6.0",
8484
"typescript": "^4.3.2"
8585
},

src/Subscription/Subscription.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ export class Subscription<T> {
1111
EventSubscriber<T>
1212
>()
1313
private status_: Status = "inactive"
14-
private statusSubscribers_: Set<StatusSubscriber> = new Set<StatusSubscriber>()
14+
private statusSubscribers_: Set<StatusSubscriber> =
15+
new Set<StatusSubscriber>()
1516

1617
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1718
public emit(value: T): Task<any, any[]> {

src/Task/Task.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,10 @@ export const fromLazyPromise = <S>(
232232
* lazily returns a Task instead.
233233
* @param fn A function which returns a promise
234234
*/
235-
export const wrapPromiseCreator = <S, Args extends unknown[]>(
236-
fn: (...args: Args) => Promise<S>,
237-
) => (...args: Args): Task<unknown, S> => fromLazyPromise(() => fn(...args))
235+
export const wrapPromiseCreator =
236+
<S, Args extends unknown[]>(fn: (...args: Args) => Promise<S>) =>
237+
(...args: Args): Task<unknown, S> =>
238+
fromLazyPromise(() => fn(...args))
238239

239240
/**
240241
* Given a task, create a Promise which resolves when the task does.
@@ -955,9 +956,9 @@ export class Task<E, S> implements PromiseLike<S> {
955956
public ap<
956957
E2,
957958
S2,
958-
S3 = S extends (arg: S2) => unknown ? ReturnType<S> : never
959+
S3 = S extends (arg: S2) => unknown ? ReturnType<S> : never,
959960
>(task: Task<E | E2, S2>): Task<E | E2, S3> {
960-
return ap((this as unknown) as Task<E, (result: S2) => S3>, task)
961+
return ap(this as unknown as Task<E, (result: S2) => S3>, task)
961962
}
962963

963964
public wait(ms: number): Task<E, S> {

src/__tests__/piuggi2.spec.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ const contentToQuery: ContentTypes[] = [
5555
const unpublishAndDelete = (entry: typeof ENTRY) =>
5656
entry.isPublished() ? entry.unpublish() : entry.delete()
5757

58-
const queryContentType = (environment: typeof ENV) => (
59-
contentType: ContentTypes,
60-
) =>
61-
environment[contentType]({
62-
order: "sys.createdAt",
63-
limit: 1000,
64-
})
65-
.map(response => response.items.map(unpublishAndDelete))
66-
.chain(Task.sequence)
58+
const queryContentType =
59+
(environment: typeof ENV) => (contentType: ContentTypes) =>
60+
environment[contentType]({
61+
order: "sys.createdAt",
62+
limit: 1000,
63+
})
64+
.map(response => response.items.map(unpublishAndDelete))
65+
.chain(Task.sequence)
6766

6867
describe("piugi script 2", () => {
6968
test("the test", () =>

src/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export { RemoteData, Task, ExternalTask, LoopContinue, LoopBreak, Subscription }
1010
* returns a promise instead.
1111
* @param fn A function which returns a promise
1212
*/
13-
export const wrapTaskCreator = <S, Args extends unknown[]>(
14-
fn: (...args: Args) => Task<unknown, S>,
15-
) => (...args: Args): Promise<S> => fn(...args).toPromise()
13+
export const wrapTaskCreator =
14+
<S, Args extends unknown[]>(fn: (...args: Args) => Task<unknown, S>) =>
15+
(...args: Args): Promise<S> =>
16+
fn(...args).toPromise()

src/util.ts

+14-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ export const range = (end: number, start = 0): number[] =>
33
.fill(undefined)
44
.map((_, i) => start + i)
55

6-
export const to = <A, T>(fn: (items: A[]) => T) =>
6+
export const to =
7+
<A, T>(fn: (items: A[]) => T) =>
78
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
89
(sum: any, _item: A, index: number, all: A[]): T => {
910
const isLast = index === all.length - 1
@@ -15,16 +16,21 @@ export const to = <A, T>(fn: (items: A[]) => T) =>
1516
return fn(all)
1617
}
1718

18-
export const constant = <T>(value: T): (() => T) => () => value
19+
export const constant =
20+
<T>(value: T): (() => T) =>
21+
() =>
22+
value
1923

2024
export const identity = <T>(x: T): T => x
2125

22-
export const toIndexedObject = <T, V, R extends { [key: string]: V }>(
23-
fn: (item: T, index: number) => [string, V],
24-
) => (sum: R, item: T, index: number): R => {
25-
const [key, value] = fn(item, index)
26-
return ((sum as { [key: string]: V })[key] = value), sum
27-
}
26+
export const toIndexedObject =
27+
<T, V, R extends { [key: string]: V }>(
28+
fn: (item: T, index: number) => [string, V],
29+
) =>
30+
(sum: R, item: T, index: number): R => {
31+
const [key, value] = fn(item, index)
32+
return ((sum as { [key: string]: V })[key] = value), sum
33+
}
2834

2935
export const mapToIndexedObject = <T, V, R extends { [key: string]: V }>(
3036
fn: (item: T, index: number) => [string, V],

0 commit comments

Comments
 (0)