Skip to content

Commit eeae117

Browse files
IMax153mikearnaldi
authored andcommitted
feat(@tsplus/stdlib): add Differ data type
1 parent 478f4b9 commit eeae117

File tree

217 files changed

+1582
-193
lines changed

Some content is hidden

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

217 files changed

+1582
-193
lines changed

.changeset/modern-tips-sell.md

+5

.eslintrc.cjs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = {
3131
// The TypeScript configuration of dprint
3232
// See also https://dprint.dev/plugins/typescript/config/,
3333
"indentWidth": 2,
34+
"lineWidth": 100,
3435
"semiColons": "asi",
3536
"quoteStyle": "alwaysDouble",
3637
"trailingCommas": "never",

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
"@babel/core": "^7.18.10",
3636
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
3737
"@changesets/changelog-github": "^0.4.6",
38-
"@changesets/cli": "^2.24.1",
38+
"@changesets/cli": "^2.24.2",
3939
"@effect-ts/build-utils": "0.40.3",
4040
"@effect-ts/core": "^0.60.2",
4141
"@repo-tooling/eslint-plugin-dprint": "^0.0.4",
4242
"@tsplus/installer": "0.0.132",
43-
"@types/node": "^18.6.3",
43+
"@types/node": "^18.6.4",
4444
"@types/rimraf": "^3.0.2",
4545
"@typescript-eslint/eslint-plugin": "^5.32.0",
4646
"@typescript-eslint/parser": "^5.32.0",
+2-99
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,6 @@
11
// codegen:start {preset: barrel, include: ./Chunk/*.ts, prefix: "@tsplus/stdlib/collections"}
2-
export * from "@tsplus/stdlib/collections/Chunk/append"
3-
export * from "@tsplus/stdlib/collections/Chunk/buckets"
4-
export * from "@tsplus/stdlib/collections/Chunk/builder"
5-
export * from "@tsplus/stdlib/collections/Chunk/collect"
6-
export * from "@tsplus/stdlib/collections/Chunk/collectWhile"
7-
export * from "@tsplus/stdlib/collections/Chunk/collectWithIndex"
8-
export * from "@tsplus/stdlib/collections/Chunk/compact"
9-
export * from "@tsplus/stdlib/collections/Chunk/compactF"
10-
export * from "@tsplus/stdlib/collections/Chunk/compactWithIndexF"
11-
export * from "@tsplus/stdlib/collections/Chunk/concat"
12-
export * from "@tsplus/stdlib/collections/Chunk/dedupe"
132
export * from "@tsplus/stdlib/collections/Chunk/definition"
14-
export * from "@tsplus/stdlib/collections/Chunk/difference"
15-
export * from "@tsplus/stdlib/collections/Chunk/drop"
16-
export * from "@tsplus/stdlib/collections/Chunk/dropRight"
17-
export * from "@tsplus/stdlib/collections/Chunk/dropWhile"
18-
export * from "@tsplus/stdlib/collections/Chunk/elem"
19-
export * from "@tsplus/stdlib/collections/Chunk/empty"
20-
export * from "@tsplus/stdlib/collections/Chunk/equals"
21-
export * from "@tsplus/stdlib/collections/Chunk/exists"
22-
export * from "@tsplus/stdlib/collections/Chunk/extend"
23-
export * from "@tsplus/stdlib/collections/Chunk/fill"
24-
export * from "@tsplus/stdlib/collections/Chunk/filter"
25-
export * from "@tsplus/stdlib/collections/Chunk/filterWithIndex"
26-
export * from "@tsplus/stdlib/collections/Chunk/find"
27-
export * from "@tsplus/stdlib/collections/Chunk/findIndex"
28-
export * from "@tsplus/stdlib/collections/Chunk/findLast"
29-
export * from "@tsplus/stdlib/collections/Chunk/findLastIndex"
30-
export * from "@tsplus/stdlib/collections/Chunk/flatMap"
31-
export * from "@tsplus/stdlib/collections/Chunk/flatten"
32-
export * from "@tsplus/stdlib/collections/Chunk/forAll"
33-
export * from "@tsplus/stdlib/collections/Chunk/forAny"
34-
export * from "@tsplus/stdlib/collections/Chunk/forEach"
35-
export * from "@tsplus/stdlib/collections/Chunk/forEachF"
36-
export * from "@tsplus/stdlib/collections/Chunk/forEachWithIndexF"
37-
export * from "@tsplus/stdlib/collections/Chunk/get"
38-
export * from "@tsplus/stdlib/collections/Chunk/getAssociative"
39-
export * from "@tsplus/stdlib/collections/Chunk/getAssociativeIdentity"
40-
export * from "@tsplus/stdlib/collections/Chunk/getEquivalence"
41-
export * from "@tsplus/stdlib/collections/Chunk/getOrd"
42-
export * from "@tsplus/stdlib/collections/Chunk/getShow"
43-
export * from "@tsplus/stdlib/collections/Chunk/grouped"
44-
export * from "@tsplus/stdlib/collections/Chunk/head"
45-
export * from "@tsplus/stdlib/collections/Chunk/indexWhere"
46-
export * from "@tsplus/stdlib/collections/Chunk/indexWhereFrom"
473
export * from "@tsplus/stdlib/collections/Chunk/instances"
48-
export * from "@tsplus/stdlib/collections/Chunk/intersection"
49-
export * from "@tsplus/stdlib/collections/Chunk/isEmpty"
50-
export * from "@tsplus/stdlib/collections/Chunk/isNonEmpty"
51-
export * from "@tsplus/stdlib/collections/Chunk/join"
52-
export * from "@tsplus/stdlib/collections/Chunk/last"
53-
export * from "@tsplus/stdlib/collections/Chunk/make"
54-
export * from "@tsplus/stdlib/collections/Chunk/makeBy"
55-
export * from "@tsplus/stdlib/collections/Chunk/map"
56-
export * from "@tsplus/stdlib/collections/Chunk/mapAccum"
57-
export * from "@tsplus/stdlib/collections/Chunk/mapWithIndex"
58-
export * from "@tsplus/stdlib/collections/Chunk/materialize"
59-
export * from "@tsplus/stdlib/collections/Chunk/partition"
60-
export * from "@tsplus/stdlib/collections/Chunk/partitionMap"
61-
export * from "@tsplus/stdlib/collections/Chunk/partitionMapWithIndex"
62-
export * from "@tsplus/stdlib/collections/Chunk/partitionWithIndex"
63-
export * from "@tsplus/stdlib/collections/Chunk/prepend"
64-
export * from "@tsplus/stdlib/collections/Chunk/range"
65-
export * from "@tsplus/stdlib/collections/Chunk/reduce"
66-
export * from "@tsplus/stdlib/collections/Chunk/reduceRight"
67-
export * from "@tsplus/stdlib/collections/Chunk/reduceRightWithIndex"
68-
export * from "@tsplus/stdlib/collections/Chunk/reduceWhile"
69-
export * from "@tsplus/stdlib/collections/Chunk/reduceWithIndex"
70-
export * from "@tsplus/stdlib/collections/Chunk/reverse"
71-
export * from "@tsplus/stdlib/collections/Chunk/reverseBuckets"
72-
export * from "@tsplus/stdlib/collections/Chunk/separate"
73-
export * from "@tsplus/stdlib/collections/Chunk/separateF"
74-
export * from "@tsplus/stdlib/collections/Chunk/separateWithIndexF"
75-
export * from "@tsplus/stdlib/collections/Chunk/single"
76-
export * from "@tsplus/stdlib/collections/Chunk/size"
77-
export * from "@tsplus/stdlib/collections/Chunk/sort"
78-
export * from "@tsplus/stdlib/collections/Chunk/sortBy"
79-
export * from "@tsplus/stdlib/collections/Chunk/split"
80-
export * from "@tsplus/stdlib/collections/Chunk/splitAt"
81-
export * from "@tsplus/stdlib/collections/Chunk/splitWhere"
82-
export * from "@tsplus/stdlib/collections/Chunk/tail"
83-
export * from "@tsplus/stdlib/collections/Chunk/take"
84-
export * from "@tsplus/stdlib/collections/Chunk/takeRight"
85-
export * from "@tsplus/stdlib/collections/Chunk/takeWhile"
86-
export * from "@tsplus/stdlib/collections/Chunk/toArrayLike"
87-
export * from "@tsplus/stdlib/collections/Chunk/toCollection"
88-
export * from "@tsplus/stdlib/collections/Chunk/unfold"
89-
export * from "@tsplus/stdlib/collections/Chunk/union"
90-
export * from "@tsplus/stdlib/collections/Chunk/uniq"
91-
export * from "@tsplus/stdlib/collections/Chunk/unit"
92-
export * from "@tsplus/stdlib/collections/Chunk/unsafeGet"
93-
export * from "@tsplus/stdlib/collections/Chunk/unsafeHead"
94-
export * from "@tsplus/stdlib/collections/Chunk/unsafeLast"
95-
export * from "@tsplus/stdlib/collections/Chunk/unsafeTail"
96-
export * from "@tsplus/stdlib/collections/Chunk/unzip"
97-
export * from "@tsplus/stdlib/collections/Chunk/zip"
98-
export * from "@tsplus/stdlib/collections/Chunk/zipAll"
99-
export * from "@tsplus/stdlib/collections/Chunk/zipAllWith"
100-
export * from "@tsplus/stdlib/collections/Chunk/zipWith"
101-
export * from "@tsplus/stdlib/collections/Chunk/zipWithIndex"
102-
export * from "@tsplus/stdlib/collections/Chunk/zipWithIndexOffset"
4+
export * from "@tsplus/stdlib/collections/Chunk/operations"
5+
export * from "@tsplus/stdlib/collections/Chunk/patch"
1036
// codegen:end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// codegen:start {preset: barrel, include: ./operations/*.ts, prefix: "@tsplus/stdlib/collections/Chunk"}
2+
export * from "@tsplus/stdlib/collections/Chunk/operations/append"
3+
export * from "@tsplus/stdlib/collections/Chunk/operations/buckets"
4+
export * from "@tsplus/stdlib/collections/Chunk/operations/builder"
5+
export * from "@tsplus/stdlib/collections/Chunk/operations/collect"
6+
export * from "@tsplus/stdlib/collections/Chunk/operations/collectWhile"
7+
export * from "@tsplus/stdlib/collections/Chunk/operations/collectWithIndex"
8+
export * from "@tsplus/stdlib/collections/Chunk/operations/compact"
9+
export * from "@tsplus/stdlib/collections/Chunk/operations/compactF"
10+
export * from "@tsplus/stdlib/collections/Chunk/operations/compactWithIndexF"
11+
export * from "@tsplus/stdlib/collections/Chunk/operations/concat"
12+
export * from "@tsplus/stdlib/collections/Chunk/operations/dedupe"
13+
export * from "@tsplus/stdlib/collections/Chunk/operations/difference"
14+
export * from "@tsplus/stdlib/collections/Chunk/operations/drop"
15+
export * from "@tsplus/stdlib/collections/Chunk/operations/dropRight"
16+
export * from "@tsplus/stdlib/collections/Chunk/operations/dropWhile"
17+
export * from "@tsplus/stdlib/collections/Chunk/operations/elem"
18+
export * from "@tsplus/stdlib/collections/Chunk/operations/empty"
19+
export * from "@tsplus/stdlib/collections/Chunk/operations/equals"
20+
export * from "@tsplus/stdlib/collections/Chunk/operations/exists"
21+
export * from "@tsplus/stdlib/collections/Chunk/operations/extend"
22+
export * from "@tsplus/stdlib/collections/Chunk/operations/fill"
23+
export * from "@tsplus/stdlib/collections/Chunk/operations/filter"
24+
export * from "@tsplus/stdlib/collections/Chunk/operations/filterWithIndex"
25+
export * from "@tsplus/stdlib/collections/Chunk/operations/find"
26+
export * from "@tsplus/stdlib/collections/Chunk/operations/findIndex"
27+
export * from "@tsplus/stdlib/collections/Chunk/operations/findLast"
28+
export * from "@tsplus/stdlib/collections/Chunk/operations/findLastIndex"
29+
export * from "@tsplus/stdlib/collections/Chunk/operations/flatMap"
30+
export * from "@tsplus/stdlib/collections/Chunk/operations/flatten"
31+
export * from "@tsplus/stdlib/collections/Chunk/operations/forAll"
32+
export * from "@tsplus/stdlib/collections/Chunk/operations/forAny"
33+
export * from "@tsplus/stdlib/collections/Chunk/operations/forEach"
34+
export * from "@tsplus/stdlib/collections/Chunk/operations/forEachF"
35+
export * from "@tsplus/stdlib/collections/Chunk/operations/forEachWithIndexF"
36+
export * from "@tsplus/stdlib/collections/Chunk/operations/get"
37+
export * from "@tsplus/stdlib/collections/Chunk/operations/getAssociative"
38+
export * from "@tsplus/stdlib/collections/Chunk/operations/getAssociativeIdentity"
39+
export * from "@tsplus/stdlib/collections/Chunk/operations/getEquivalence"
40+
export * from "@tsplus/stdlib/collections/Chunk/operations/getOrd"
41+
export * from "@tsplus/stdlib/collections/Chunk/operations/getShow"
42+
export * from "@tsplus/stdlib/collections/Chunk/operations/grouped"
43+
export * from "@tsplus/stdlib/collections/Chunk/operations/head"
44+
export * from "@tsplus/stdlib/collections/Chunk/operations/indexWhere"
45+
export * from "@tsplus/stdlib/collections/Chunk/operations/indexWhereFrom"
46+
export * from "@tsplus/stdlib/collections/Chunk/operations/intersection"
47+
export * from "@tsplus/stdlib/collections/Chunk/operations/isEmpty"
48+
export * from "@tsplus/stdlib/collections/Chunk/operations/isNonEmpty"
49+
export * from "@tsplus/stdlib/collections/Chunk/operations/join"
50+
export * from "@tsplus/stdlib/collections/Chunk/operations/last"
51+
export * from "@tsplus/stdlib/collections/Chunk/operations/make"
52+
export * from "@tsplus/stdlib/collections/Chunk/operations/makeBy"
53+
export * from "@tsplus/stdlib/collections/Chunk/operations/map"
54+
export * from "@tsplus/stdlib/collections/Chunk/operations/mapAccum"
55+
export * from "@tsplus/stdlib/collections/Chunk/operations/mapWithIndex"
56+
export * from "@tsplus/stdlib/collections/Chunk/operations/materialize"
57+
export * from "@tsplus/stdlib/collections/Chunk/operations/partition"
58+
export * from "@tsplus/stdlib/collections/Chunk/operations/partitionMap"
59+
export * from "@tsplus/stdlib/collections/Chunk/operations/partitionMapWithIndex"
60+
export * from "@tsplus/stdlib/collections/Chunk/operations/partitionWithIndex"
61+
export * from "@tsplus/stdlib/collections/Chunk/operations/prepend"
62+
export * from "@tsplus/stdlib/collections/Chunk/operations/range"
63+
export * from "@tsplus/stdlib/collections/Chunk/operations/reduce"
64+
export * from "@tsplus/stdlib/collections/Chunk/operations/reduceRight"
65+
export * from "@tsplus/stdlib/collections/Chunk/operations/reduceRightWithIndex"
66+
export * from "@tsplus/stdlib/collections/Chunk/operations/reduceWhile"
67+
export * from "@tsplus/stdlib/collections/Chunk/operations/reduceWithIndex"
68+
export * from "@tsplus/stdlib/collections/Chunk/operations/reverse"
69+
export * from "@tsplus/stdlib/collections/Chunk/operations/reverseBuckets"
70+
export * from "@tsplus/stdlib/collections/Chunk/operations/separate"
71+
export * from "@tsplus/stdlib/collections/Chunk/operations/separateF"
72+
export * from "@tsplus/stdlib/collections/Chunk/operations/separateWithIndexF"
73+
export * from "@tsplus/stdlib/collections/Chunk/operations/single"
74+
export * from "@tsplus/stdlib/collections/Chunk/operations/size"
75+
export * from "@tsplus/stdlib/collections/Chunk/operations/sort"
76+
export * from "@tsplus/stdlib/collections/Chunk/operations/sortBy"
77+
export * from "@tsplus/stdlib/collections/Chunk/operations/split"
78+
export * from "@tsplus/stdlib/collections/Chunk/operations/splitAt"
79+
export * from "@tsplus/stdlib/collections/Chunk/operations/splitWhere"
80+
export * from "@tsplus/stdlib/collections/Chunk/operations/tail"
81+
export * from "@tsplus/stdlib/collections/Chunk/operations/take"
82+
export * from "@tsplus/stdlib/collections/Chunk/operations/takeRight"
83+
export * from "@tsplus/stdlib/collections/Chunk/operations/takeWhile"
84+
export * from "@tsplus/stdlib/collections/Chunk/operations/toArrayLike"
85+
export * from "@tsplus/stdlib/collections/Chunk/operations/toCollection"
86+
export * from "@tsplus/stdlib/collections/Chunk/operations/unfold"
87+
export * from "@tsplus/stdlib/collections/Chunk/operations/union"
88+
export * from "@tsplus/stdlib/collections/Chunk/operations/uniq"
89+
export * from "@tsplus/stdlib/collections/Chunk/operations/unit"
90+
export * from "@tsplus/stdlib/collections/Chunk/operations/unsafeGet"
91+
export * from "@tsplus/stdlib/collections/Chunk/operations/unsafeHead"
92+
export * from "@tsplus/stdlib/collections/Chunk/operations/unsafeLast"
93+
export * from "@tsplus/stdlib/collections/Chunk/operations/unsafeTail"
94+
export * from "@tsplus/stdlib/collections/Chunk/operations/unzip"
95+
export * from "@tsplus/stdlib/collections/Chunk/operations/zip"
96+
export * from "@tsplus/stdlib/collections/Chunk/operations/zipAll"
97+
export * from "@tsplus/stdlib/collections/Chunk/operations/zipAllWith"
98+
export * from "@tsplus/stdlib/collections/Chunk/operations/zipWith"
99+
export * from "@tsplus/stdlib/collections/Chunk/operations/zipWithIndex"
100+
export * from "@tsplus/stdlib/collections/Chunk/operations/zipWithIndexOffset"
101+
// codegen:end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// codegen:start {preset: barrel, include: ./patch/*.ts, prefix: "@tsplus/stdlib/collections/Chunk"}
2+
export * from "@tsplus/stdlib/collections/Chunk/patch/definition"
3+
export * from "@tsplus/stdlib/collections/Chunk/patch/operations"
4+
// codegen:end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
export const ChunkPatchSym = Symbol.for("@Differ.Chunk.Patch")
2+
export type ChunkPatchSym = typeof ChunkPatchSym
3+
4+
export const ChunkPatchValueSym = Symbol.for("@Differ.Chunk.Patch.Value")
5+
export type ChunkPatchValueSym = typeof ChunkPatchValueSym
6+
7+
export const ChunkPatchPatchSym = Symbol.for("@Differ.Chunk.Patch.Patch")
8+
export type ChunkPatchPatchSym = typeof ChunkPatchPatchSym
9+
10+
/**
11+
* A patch which describes updates to a chunk of values.
12+
*
13+
* @tsplus type Differ.Chunk.Patch
14+
*/
15+
export interface ChunkPatch<in out Value, in out Patch> {
16+
readonly [ChunkPatchSym]: ChunkPatchSym
17+
readonly [ChunkPatchValueSym]: (_: Value) => Value
18+
readonly [ChunkPatchPatchSym]: (_: Patch) => Patch
19+
}
20+
21+
/**
22+
* @tsplus type Differ.Chunk.Patch.Ops
23+
*/
24+
export interface ChunkPatchOps {
25+
readonly $: ChunkPatchAspects
26+
}
27+
/**
28+
* @tsplus static Differ.Ops Chunk
29+
*/
30+
export const ChunkPatch: ChunkPatchOps = {
31+
$: {}
32+
}
33+
34+
/**
35+
* @tsplus type Differ.Chunk.Patch.Aspects
36+
*/
37+
export interface ChunkPatchAspects {}
38+
39+
/**
40+
* @tsplus unify Differ.Chunk.Patch
41+
*/
42+
export function unifyChunkPatch<X extends ChunkPatch<any, any>>(self: X): ChunkPatch<
43+
[X] extends [{ [ChunkPatchValueSym]: (_: infer Value) => infer Value }] ? Value : never,
44+
[X] extends [{ [ChunkPatchPatchSym]: (_: infer Patch) => infer Patch }] ? Patch : never
45+
> {
46+
return self
47+
}
48+
49+
export abstract class BaseChunkPatch<Value, Patch> implements ChunkPatch<Value, Patch> {
50+
readonly [ChunkPatchSym]: ChunkPatchSym = ChunkPatchSym
51+
readonly [ChunkPatchValueSym]!: (_: Value) => Value
52+
readonly [ChunkPatchPatchSym]!: (_: Patch) => Patch
53+
}
54+
55+
export class AppendChunkPatch<Value, Patch> extends BaseChunkPatch<Value, Patch> {
56+
readonly _tag = "Append"
57+
constructor(readonly values: Chunk<Value>) {
58+
super()
59+
}
60+
}
61+
62+
export class SliceChunkPatch<Value, Patch> extends BaseChunkPatch<Value, Patch> {
63+
readonly _tag = "Slice"
64+
constructor(readonly from: number, readonly until: number) {
65+
super()
66+
}
67+
}
68+
69+
export class UpdateChunkPatch<Value, Patch> extends BaseChunkPatch<Value, Patch> {
70+
readonly _tag = "Update"
71+
constructor(readonly index: number, readonly patch: Patch) {
72+
super()
73+
}
74+
}
75+
76+
export class AndThenChunkPatch<Value, Patch> extends BaseChunkPatch<Value, Patch> {
77+
readonly _tag = "AndThen"
78+
constructor(readonly first: ChunkPatch<Value, Patch>, readonly second: ChunkPatch<Value, Patch>) {
79+
super()
80+
}
81+
}
82+
83+
export class EmptyChunkPatch<Value, Patch> extends BaseChunkPatch<Value, Patch> {
84+
readonly _tag = "Empty"
85+
}
86+
87+
export type ChunkPatchInstruction =
88+
| AppendChunkPatch<any, any>
89+
| SliceChunkPatch<any, any>
90+
| UpdateChunkPatch<any, any>
91+
| AndThenChunkPatch<any, any>
92+
| EmptyChunkPatch<any, any>
93+
94+
/**
95+
* @tsplus macro identity
96+
*/
97+
export function chunkPatchInstruction<Value, Patch>(
98+
self: ChunkPatch<Value, Patch>
99+
): ChunkPatchInstruction {
100+
// @ts-expect-error
101+
return self
102+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// codegen:start {preset: barrel, include: ./operations/*.ts, prefix: "@tsplus/stdlib/collections/Chunk/patch"}
2+
export * from "@tsplus/stdlib/collections/Chunk/patch/operations/apply"
3+
export * from "@tsplus/stdlib/collections/Chunk/patch/operations/combine"
4+
export * from "@tsplus/stdlib/collections/Chunk/patch/operations/diff"
5+
export * from "@tsplus/stdlib/collections/Chunk/patch/operations/emptyPatch"
6+
// codegen:end

0 commit comments

Comments
 (0)