Skip to content

Commit 830713a

Browse files
IMax153mikearnaldi
authored andcommitted
feat(@tsplus/stdlib): convert annotations to pipeable
1 parent ffa0553 commit 830713a

File tree

626 files changed

+5414
-7146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

626 files changed

+5414
-7146
lines changed

.changeset/purple-singers-return.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@tsplus/runtime": patch
3+
"@tsplus/stdlib": patch
4+
---
5+
6+
convert annotations to pipeable where possible

.github/changeset-version.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const { execSync } = require("node:child_process");
22

33
execSync("npx changeset version");
4-
execSync("YARN_ENABLE_IMMUTABLE_INSTALLS=false node .yarn/releases/yarn-3.1.1.cjs");
4+
execSync("YARN_ENABLE_IMMUTABLE_INSTALLS=false node .yarn/releases/yarn-3.2.2.cjs");

.yarn/releases/yarn-3.1.1.cjs

-768
This file was deleted.

.yarn/releases/yarn-3.2.2.cjs

+783
Large diffs are not rendered by default.

.yarnrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ plugins:
44
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
55
spec: "@yarnpkg/plugin-interactive-tools"
66

7-
yarnPath: .yarn/releases/yarn-3.1.1.cjs
7+
yarnPath: .yarn/releases/yarn-3.2.2.cjs

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
### Work in progress
1+
### Work in progress [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-ready--to--code-908a85?logo=gitpod)](https://github.com/ts-plus/stdlib)

gitpod.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tasks:
2+
- init: yarn && yarn build
3+
github:
4+
prebuilds:
5+
addCheck: true
6+
vscode:
7+
extensions:
8+
- dbaeumer.vscode-eslint

package.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@
2929
"org:babel": "cd $INIT_CWD && babel",
3030
"org:madge": "cd $INIT_CWD && madge"
3131
},
32-
"packageManager": "yarn@3.1.1",
32+
"packageManager": "yarn@3.2.2",
3333
"devDependencies": {
34-
"@babel/cli": "^7.17.10",
35-
"@babel/core": "^7.18.5",
36-
"@babel/plugin-transform-modules-commonjs": "^7.18.2",
37-
"@changesets/changelog-github": "^0.4.5",
38-
"@changesets/cli": "^2.23.0",
34+
"@babel/cli": "^7.18.9",
35+
"@babel/core": "^7.18.9",
36+
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
37+
"@changesets/changelog-github": "^0.4.6",
38+
"@changesets/cli": "^2.24.1",
3939
"@effect-ts/build-utils": "0.40.3",
4040
"@effect-ts/core": "^0.60.2",
4141
"@repo-tooling/eslint-plugin-dprint": "^0.0.4",
42-
"@tsplus/installer": "^0.0.119",
43-
"@types/node": "^18.0.0",
42+
"@tsplus/installer": "0.0.128",
43+
"@types/node": "^18.6.2",
4444
"@types/rimraf": "^3.0.2",
45-
"@typescript-eslint/eslint-plugin": "^5.29.0",
46-
"@typescript-eslint/parser": "^5.29.0",
45+
"@typescript-eslint/eslint-plugin": "^5.31.0",
46+
"@typescript-eslint/parser": "^5.31.0",
4747
"babel-plugin-annotate-pure-calls": "^0.4.0",
4848
"babel-plugin-replace-import-extension": "^1.1.3",
49-
"c8": "^7.11.3",
50-
"concurrently": "^7.2.2",
49+
"c8": "^7.12.0",
50+
"concurrently": "^7.3.0",
5151
"cpx": "^1.5.0",
52-
"eslint": "^8.18.0",
53-
"eslint-import-resolver-typescript": "^2.7.1",
52+
"eslint": "^8.20.0",
53+
"eslint-import-resolver-typescript": "^3.3.0",
5454
"eslint-plugin-codegen": "0.16.1",
5555
"eslint-plugin-import": "^2.26.0",
5656
"eslint-plugin-simple-import-sort": "^7.0.0",
@@ -60,8 +60,8 @@
6060
"rimraf": "^3.0.2",
6161
"typescript": "^4.7.4",
6262
"ultra-runner": "^3.10.5",
63-
"vite": "^2.9.12",
64-
"vitest": "0.15.2"
63+
"vite": "^3.0.3",
64+
"vitest": "0.19.1"
6565
},
6666
"resolutions": {
6767
"eslint-plugin-codegen": "patch:eslint-plugin-codegen@npm:0.16.1#.yarn/patches/eslint-plugin-codegen-npm-0.16.1-87770191cd"
File renamed without changes.

packages/runtime/_src/global.ts

+4
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ import { Guard } from "@tsplus/runtime/Guard"
3737
* @tsplus global
3838
*/
3939
import { Make } from "@tsplus/runtime/Make"
40+
/**
41+
* @tsplus global
42+
*/
43+
import { Result } from "@tsplus/runtime/Result"
File renamed without changes.

packages/stdlib/_examples/associative.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const VotesSumAssociative: Associative<Votes> = Associative(zip_)
5858
type VoteData = HashMap<Topic, Votes>
5959
/**
6060
* @tsplus type Example/VoteMap
61-
* @tsplus companion Example/VoteMap/Ops
61+
* @tsplus companion Example/VoteMap.Ops
6262
*/
6363
export class VoteMap implements Hash, Equals {
6464
constructor(readonly map: VoteData) {}
@@ -71,19 +71,19 @@ export class VoteMap implements Hash, Equals {
7171
}
7272

7373
/**
74-
* @tsplus static Example/VoteMap/Ops __call
74+
* @tsplus static Example/VoteMap.Ops __call
7575
*/
7676
export const makeVoteMap = (map: VoteData) => new VoteMap(map)
7777

7878
/**
79-
* @tsplus static Example/VoteMap/Ops isVoteMap
79+
* @tsplus static Example/VoteMap.Ops isVoteMap
8080
*/
8181
export function isVoteMap(t: unknown): t is VoteMap {
8282
return typeof t === "object" && t instanceof VoteMap
8383
}
8484

8585
/**
86-
* @tsplus static Example/VoteMap/Ops AssociativeSum
86+
* @tsplus static Example/VoteMap.Ops AssociativeSum
8787
*/
8888
export const VoteMapSumAssociative: Associative<VoteMap> = pipe(
8989
HashMap.getAssociative<Topic, Votes>(Votes.SumAssociative),

packages/stdlib/_src/collections/Chunk/append.ts

+4-10
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,9 @@ import { concreteChunkId } from "@tsplus/stdlib/collections/Chunk/definition"
33
/**
44
* Appends a value to a chunk.
55
*
6-
* @tsplus fluent Chunk append
6+
* @tsplus static Chunk.Aspects append
7+
* @tsplus pipeable Chunk append
78
*/
8-
export function append_<A, A1>(self: Chunk<A>, a: A1): Chunk<A | A1> {
9-
return concreteChunkId(self)._append(a)
9+
export function append<A1>(a: A1) {
10+
return <A>(self: Chunk<A>): Chunk<A | A1> => concreteChunkId(self)._append(a)
1011
}
11-
12-
/**
13-
* Appends a value to a chunk.
14-
*
15-
* @tsplus static Chunk/Aspects append
16-
*/
17-
export const append = Pipeable(append_)

packages/stdlib/_src/collections/Chunk/builder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Builder
33
*
4-
* @tsplus static Chunk/Ops builder
4+
* @tsplus static Chunk.Ops builder
55
*/
66
export function builder<A>() {
77
return new ChunkBuilder<A>(Chunk.empty())

packages/stdlib/_src/collections/Chunk/collect.ts

+18-22
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,28 @@ import { ArrTypeId, concreteChunk } from "@tsplus/stdlib/collections/Chunk/defin
33
/**
44
* Returns a filtered, mapped subset of the elements of this chunk.
55
*
6-
* @tsplus fluent Chunk collect
6+
* @tsplus static Chunk.Aspects collect
7+
* @tsplus pipeable Chunk collect
78
*/
8-
export function collect_<A, B>(self: Chunk<A>, f: (a: A) => Maybe<B>): Chunk<B> {
9-
concreteChunk(self)
9+
export function collect<A, B>(f: (a: A) => Maybe<B>) {
10+
return (self: Chunk<A>): Chunk<B> => {
11+
concreteChunk(self)
1012

11-
switch (self._typeId) {
12-
case ArrTypeId: {
13-
const array = self._arrayLike()
14-
let dest = Chunk.empty<B>()
15-
for (let i = 0; i < array.length; i++) {
16-
const rhs = f(array[i]!)
17-
if (rhs.isSome()) {
18-
dest = dest.append(rhs.value)
13+
switch (self._typeId) {
14+
case ArrTypeId: {
15+
const array = self._arrayLike()
16+
let dest = Chunk.empty<B>()
17+
for (let i = 0; i < array.length; i++) {
18+
const rhs = f(array[i]!)
19+
if (rhs.isSome()) {
20+
dest = dest.append(rhs.value)
21+
}
1922
}
23+
return dest
24+
}
25+
default: {
26+
return self._materialize().collect(f)
2027
}
21-
return dest
22-
}
23-
default: {
24-
return collect_(self._materialize(), f)
2528
}
2629
}
2730
}
28-
29-
/**
30-
* Returns a filtered, mapped subset of the elements of this chunk.
31-
*
32-
* @tsplus static Chunk/Aspects collect
33-
*/
34-
export const collect = Pipeable(collect_)

packages/stdlib/_src/collections/Chunk/collectWhile.ts

+23-28
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,33 @@ import { ArrTypeId, concreteChunk, SingletonTypeId } from "@tsplus/stdlib/collec
44
* Transforms all elements of the chunk for as long as the specified partial
55
* function is defined.
66
*
7-
* @tsplus fluent Chunk collectWhile
7+
* @tsplus static Chunk.Aspects collectWhile
8+
* @tsplus pipeable Chunk collectWhile
89
*/
9-
export function collectWhile_<A, B>(self: Chunk<A>, f: (a: A) => Maybe<B>): Chunk<B> {
10-
concreteChunk(self)
10+
export function collectWhile<A, B>(f: (a: A) => Maybe<B>) {
11+
return (self: Chunk<A>): Chunk<B> => {
12+
concreteChunk(self)
1113

12-
switch (self._typeId) {
13-
case SingletonTypeId: {
14-
return f(self.a).fold(() => Chunk.empty(), Chunk.single)
15-
}
16-
case ArrTypeId: {
17-
const array = self._arrayLike()
18-
let dest = Chunk.empty<B>()
19-
for (let i = 0; i < array.length; i++) {
20-
const rhs = f(array[i]!)
21-
if (rhs.isSome()) {
22-
dest = dest.append(rhs.value)
23-
} else {
24-
return dest
14+
switch (self._typeId) {
15+
case SingletonTypeId: {
16+
return f(self.a).fold(() => Chunk.empty(), Chunk.single)
17+
}
18+
case ArrTypeId: {
19+
const array = self._arrayLike()
20+
let dest = Chunk.empty<B>()
21+
for (let i = 0; i < array.length; i++) {
22+
const rhs = f(array[i]!)
23+
if (rhs.isSome()) {
24+
dest = dest.append(rhs.value)
25+
} else {
26+
return dest
27+
}
2528
}
29+
return dest
30+
}
31+
default: {
32+
return self._materialize().collectWhile(f)
2633
}
27-
return dest
28-
}
29-
default: {
30-
return collectWhile_(self._materialize(), f)
3134
}
3235
}
3336
}
34-
35-
/**
36-
* Transforms all elements of the chunk for as long as the specified partial
37-
* function is defined.
38-
*
39-
* @tsplus static Chunk/Aspects collectWhile
40-
*/
41-
export const collectWhile = Pipeable(collectWhile_)

packages/stdlib/_src/collections/Chunk/collectWithIndex.ts

+18-25
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,28 @@ import { ArrTypeId, concreteChunk } from "@tsplus/stdlib/collections/Chunk/defin
33
/**
44
* Returns a filtered, mapped subset of the elements of this chunk.
55
*
6-
* @tsplus fluent Chunk collectWithIndex
6+
* @tsplus static Chunk.Aspects collectWithIndex
7+
* @tsplus pipeable Chunk collectWithIndex
78
*/
8-
export function collectWithIndex_<A, B>(
9-
self: Chunk<A>,
10-
f: (index: number, a: A) => Maybe<B>
11-
): Chunk<B> {
12-
concreteChunk(self)
9+
export function collectWithIndex<A, B>(f: (index: number, a: A) => Maybe<B>) {
10+
return (self: Chunk<A>): Chunk<B> => {
11+
concreteChunk(self)
1312

14-
switch (self._typeId) {
15-
case ArrTypeId: {
16-
const array = self._arrayLike()
17-
let dest = Chunk.empty<B>()
18-
for (let i = 0; i < array.length; i++) {
19-
const rhs = f(i, array[i]!)
20-
if (rhs.isSome()) {
21-
dest = dest.append(rhs.value)
13+
switch (self._typeId) {
14+
case ArrTypeId: {
15+
const array = self._arrayLike()
16+
let dest = Chunk.empty<B>()
17+
for (let i = 0; i < array.length; i++) {
18+
const rhs = f(i, array[i]!)
19+
if (rhs.isSome()) {
20+
dest = dest.append(rhs.value)
21+
}
2222
}
23+
return dest
24+
}
25+
default: {
26+
return self._materialize().collectWithIndex(f)
2327
}
24-
return dest
25-
}
26-
default: {
27-
return collectWithIndex_(self._materialize(), f)
2828
}
2929
}
3030
}
31-
32-
/**
33-
* Returns a filtered, mapped subset of the elements of this chunk.
34-
*
35-
* @tsplus static Chunk/Aspects collectWithIndex
36-
*/
37-
export const collectWithIndex = Pipeable(collectWithIndex_)

packages/stdlib/_src/collections/Chunk/compactF.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @tsplus static Chunk/Ops compactF
2+
* @tsplus static Chunk.Ops compactF
33
*/
44
export const compactF = Witherable.implementCompactF<Chunk.HKT>()(
55
<FR, FE, A, B, G extends HKT>(_: {

packages/stdlib/_src/collections/Chunk/compactWithIndexF.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @tsplus static Chunk/Ops compactWithIndexF
2+
* @tsplus static Chunk.Ops compactWithIndexF
33
*/
44
export const compactWithIndexF = WitherableWithIndex.implementCompactWithIndexF<number, Chunk.HKT>()(
55
<FR, FE, A, B, G extends HKT>(_: {

packages/stdlib/_src/collections/Chunk/concat.ts

+5-11
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@ import { concreteChunkId } from "@tsplus/stdlib/collections/Chunk/definition"
33
/**
44
* Concatenates two chunks.
55
*
6-
* @tsplus operator Chunk +
7-
* @tsplus fluent Chunk concat
6+
* @tsplus pipeable-operator Chunk +
7+
* @tsplus static Chunk.Aspects concat
8+
* @tsplus pipeable Chunk concat
89
*/
9-
export function concat_<A, A1>(self: Chunk<A>, that: Chunk<A1>): Chunk<A | A1> {
10-
return concreteChunkId(self)._concat(concreteChunkId(that))
10+
export function concat<A, A1>(that: Chunk<A1>) {
11+
return (self: Chunk<A>): Chunk<A | A1> => concreteChunkId(self)._concat(concreteChunkId(that))
1112
}
12-
13-
/**
14-
* Concats chunks
15-
*
16-
* @tsplus static Chunk/Aspects concat
17-
*/
18-
export const concat = Pipeable(concat_)

0 commit comments

Comments
 (0)