@likec4/core 1.48.0 → 1.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md +1034 -0
  2. package/dist/_chunks/Builder.view-element.mjs +2 -3284
  3. package/dist/_chunks/LikeC4Model.d.mts +21 -25
  4. package/dist/_chunks/_types.d.mts +1 -5
  5. package/dist/_chunks/_types2.d.mts +2 -4
  6. package/dist/_chunks/assignTagColors.mjs +1 -24
  7. package/dist/_chunks/geometry.mjs +1 -335
  8. package/dist/_chunks/index.d.mts +1995 -131
  9. package/dist/_chunks/index2.d.mts +153 -892
  10. package/dist/_chunks/index3.d.mts +15 -13
  11. package/dist/_chunks/index4.d.mts +229 -3
  12. package/dist/_chunks/index5.d.mts +392 -30
  13. package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
  14. package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
  15. package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
  16. package/dist/_chunks/libs/bail.mjs +1 -14
  17. package/dist/_chunks/libs/ccount.mjs +1 -25
  18. package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
  19. package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
  20. package/dist/_chunks/libs/character-entities.mjs +2 -2136
  21. package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
  22. package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
  23. package/dist/_chunks/libs/defu.mjs +1 -42
  24. package/dist/_chunks/libs/devlop.mjs +1 -5
  25. package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
  26. package/dist/_chunks/libs/extend.mjs +1 -77
  27. package/dist/_chunks/libs/graphology-dag.mjs +1 -703
  28. package/dist/_chunks/libs/graphology.mjs +1 -4565
  29. package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
  30. package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
  31. package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
  32. package/dist/_chunks/libs/longest-streak.mjs +1 -30
  33. package/dist/_chunks/libs/markdown-table.mjs +2 -290
  34. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
  35. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
  36. package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
  37. package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
  38. package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
  39. package/dist/_chunks/libs/mnemonist.d.mts +1 -91
  40. package/dist/_chunks/libs/mnemonist.mjs +1 -1978
  41. package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
  42. package/dist/_chunks/libs/ohash.mjs +1 -0
  43. package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
  44. package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
  45. package/dist/_chunks/libs/remark-gfm.mjs +1 -36
  46. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
  47. package/dist/_chunks/libs/remark-parse.mjs +1 -39
  48. package/dist/_chunks/libs/remark-rehype.mjs +1 -171
  49. package/dist/_chunks/libs/remeda.mjs +2 -702
  50. package/dist/_chunks/libs/trough.mjs +1 -158
  51. package/dist/_chunks/libs/unified.mjs +1 -2212
  52. package/dist/_chunks/manual-layout.mjs +1 -0
  53. package/dist/_chunks/model.mjs +4 -1898
  54. package/dist/_chunks/rolldown-runtime.mjs +1 -42
  55. package/dist/_chunks/types.mjs +1 -0
  56. package/dist/_chunks/utils.mjs +1 -483
  57. package/dist/builder/index.d.mts +3 -6
  58. package/dist/builder/index.mjs +1 -662
  59. package/dist/compute-view/index.d.mts +85 -13
  60. package/dist/compute-view/index.mjs +2 -262
  61. package/dist/geometry/index.d.mts +2 -2
  62. package/dist/geometry/index.mjs +1 -3
  63. package/dist/index.d.mts +7 -13
  64. package/dist/index.mjs +1 -27
  65. package/dist/model/index.d.mts +4 -11
  66. package/dist/model/index.mjs +1 -11
  67. package/dist/styles/index.d.mts +2 -7
  68. package/dist/styles/index.mjs +1 -30
  69. package/dist/types/index.d.mts +3 -9
  70. package/dist/types/index.mjs +1 -15
  71. package/dist/utils/graphology/index.d.mts +1 -1
  72. package/dist/utils/graphology/index.mjs +1 -3
  73. package/dist/utils/index.d.mts +5 -10
  74. package/dist/utils/index.mjs +1 -17
  75. package/package.json +14 -13
  76. package/dist/_chunks/LikeC4Styles.mjs +0 -691
  77. package/dist/_chunks/RichText.d.mts +0 -84
  78. package/dist/_chunks/RichText.mjs +0 -148
  79. package/dist/_chunks/_aux.d.mts +0 -289
  80. package/dist/_chunks/_aux.mjs +0 -18
  81. package/dist/_chunks/calcDriftsFromSnapshot.mjs +0 -379
  82. package/dist/_chunks/connection.mjs +0 -0
  83. package/dist/_chunks/const.d.mts +0 -43
  84. package/dist/_chunks/const.mjs +0 -33
  85. package/dist/_chunks/expression-model.d.mts +0 -192
  86. package/dist/_chunks/expression-model.mjs +0 -103
  87. package/dist/_chunks/expression.d.mts +0 -347
  88. package/dist/_chunks/expression.mjs +0 -107
  89. package/dist/_chunks/find.d.mts +0 -82
  90. package/dist/_chunks/find.mjs +0 -646
  91. package/dist/_chunks/find2.d.mts +0 -78
  92. package/dist/_chunks/find2.mjs +0 -287
  93. package/dist/_chunks/fqnRef.d.mts +0 -58
  94. package/dist/_chunks/fqnRef.mjs +0 -41
  95. package/dist/_chunks/index6.d.mts +0 -43
  96. package/dist/_chunks/index7.d.mts +0 -268
  97. package/dist/_chunks/index8.d.mts +0 -144
  98. package/dist/_chunks/invariant.mjs +0 -18
  99. package/dist/_chunks/iterable.mjs +0 -146
  100. package/dist/_chunks/libs/graphology-types.d.mts +0 -601
  101. package/dist/_chunks/libs/graphology.d.mts +0 -6
  102. package/dist/_chunks/mnemonist.mjs +0 -0
  103. package/dist/_chunks/model2.mjs +0 -0
  104. package/dist/_chunks/relationships-view.mjs +0 -132
  105. package/dist/_chunks/scalar.d.mts +0 -109
  106. package/dist/_chunks/scalar.mjs +0 -84
  107. package/dist/compute-view/relationships-view/index.d.mts +0 -16
  108. package/dist/compute-view/relationships-view/index.mjs +0 -7
  109. package/dist/model/connection/deployment/index.d.mts +0 -12
  110. package/dist/model/connection/deployment/index.mjs +0 -9
  111. package/dist/model/connection/index.d.mts +0 -14
  112. package/dist/model/connection/index.mjs +0 -10
  113. package/dist/model/connection/model/index.d.mts +0 -12
  114. package/dist/model/connection/model/index.mjs +0 -8
  115. package/dist/types/RichText.d.mts +0 -3
  116. package/dist/types/RichText.mjs +0 -7
  117. package/dist/types/_aux.d.mts +0 -3
  118. package/dist/types/_aux.mjs +0 -3
  119. package/dist/types/expression-model.d.mts +0 -6
  120. package/dist/types/expression-model.mjs +0 -7
  121. package/dist/types/expression.d.mts +0 -5
  122. package/dist/types/expression.mjs +0 -7
  123. package/dist/types/fqnRef.d.mts +0 -4
  124. package/dist/types/fqnRef.mjs +0 -7
  125. package/dist/types/scalar.d.mts +0 -2
  126. package/dist/types/scalar.mjs +0 -7
  127. package/dist/utils/iterable/index.d.mts +0 -9
  128. package/dist/utils/iterable/index.mjs +0 -3
  129. package/dist/utils/mnemonist.d.mts +0 -2
  130. package/dist/utils/mnemonist.mjs +0 -12
@@ -1,268 +0,0 @@
1
- import { Dt as ReorderedArray, wt as NonEmptyArray, yt as IterableContainer } from "./_aux.mjs";
2
- import { s as Fqn } from "./scalar.mjs";
3
- import { SetNonNullable, SetRequired } from "type-fest";
4
-
5
- //#region src/utils/invariant.d.ts
6
- declare function nonNullable<T>(value: T, message?: string | (() => string)): NonNullable<T>;
7
- declare function invariant(condition: any, message?: string): asserts condition;
8
- declare function nonexhaustive(value: never): never;
9
- //#endregion
10
- //#region src/utils/common-head.d.ts
11
- /**
12
- * Common head of two arrays
13
- *
14
- * @param equals - Equality function, defaults to `Object.is`
15
- */
16
- declare function commonHead<T>(sources: ReadonlyArray<T>, targets: ReadonlyArray<T>, equals?: (a: T, b: T) => boolean): T[];
17
- //#endregion
18
- //#region src/utils/compare-natural.d.ts
19
- declare function compareNatural(a: string | undefined, b: string | undefined): -1 | 0 | 1;
20
- /**
21
- * Compares two strings lexicographically first, then hierarchically based on their depth.\
22
- * From parent nodes to leaves
23
- *
24
- * @example
25
- * const lines = [
26
- * 'b.c',
27
- * 'b',
28
- * 'a.b.c',
29
- * ]
30
- * lines.sort(compareNaturalHierarchically('.'))
31
- * // [
32
- * // 'a.b.c',
33
- * // 'b',
34
- * // 'b.c',
35
- * // ]
36
- */
37
- declare function compareNaturalHierarchically(separator?: string, deepestFirst?: boolean): (a: string | undefined, b: string | undefined) => number;
38
- //#endregion
39
- //#region src/utils/fqn.d.ts
40
- declare function parentFqn<E extends string>(fqn: E): E | null;
41
- declare function nameFromFqn<E extends string>(fqn: E): string;
42
- /**
43
- * Check if one element is an ancestor of another
44
- * Composable version
45
- * @signature
46
- * isAncestor(another)(ancestor)
47
- */
48
- declare function isAncestor<A extends string | {
49
- id: string;
50
- }>(another: NoInfer<A>): (ancestor: A) => boolean;
51
- /**
52
- * Check if one element is an ancestor of another
53
- * @signature
54
- * isAncestor(ancestor, another)
55
- */
56
- declare function isAncestor<A extends string | {
57
- id: string;
58
- }>(ancestor: A, another: A): boolean;
59
- declare function isSameHierarchy<T extends string>(one: NoInfer<T> | WithId<NoInfer<T>>): (another: T | WithId<T>) => boolean;
60
- declare function isSameHierarchy<T extends string>(one: T | WithId<T>, another: T | WithId<T>): boolean;
61
- type WithId<T = string> = {
62
- id: T;
63
- };
64
- declare function isDescendantOf<T extends string>(ancestor: WithId<T>): (descedant: WithId<T>) => boolean;
65
- declare function isDescendantOf<T extends string>(descedant: WithId<T>, ancestor: WithId<T>): boolean;
66
- /**
67
- * How deep in the hierarchy the element is.
68
- * Root element has depth 1
69
- */
70
- declare function hierarchyLevel<E extends string | {
71
- id: Fqn;
72
- }>(elementOfFqn: E): number;
73
- /**
74
- * Calculate the distance as number of steps from one element to another, i.e.
75
- * going up to the common ancestor, then going down to the other element.
76
- * Sibling distance is always 1
77
- *
78
- * Can be used for hierarchical clustering
79
- */
80
- declare function hierarchyDistance<E extends string | {
81
- id: Fqn;
82
- }>(one: E, another: E): number;
83
- declare function commonAncestor<E extends string>(first: E, second: E): E | null;
84
- /**
85
- * Get all ancestor elements (i.e. parent, parent’s parent, etc.)
86
- * going up from parent to the root
87
- */
88
- declare function ancestorsFqn<Id extends string>(fqn: Id): Id[];
89
- /**
90
- * Compares two fully qualified names (fqns) hierarchically based on their depth.
91
- * From parent nodes to leaves
92
- *
93
- * @param {string} a - The first fqn to compare.
94
- * @param {string} b - The second fqn to compare.
95
- * @returns {number} - 0 if the fqns have the same depth.
96
- * - Positive number if a is deeper than b.
97
- * - Negative number if b is deeper than a.
98
- */
99
- declare function compareFqnHierarchically<T extends string = string>(a: T, b: T): -1 | 0 | 1;
100
- declare function compareByFqnHierarchically<T extends {
101
- id: string;
102
- }>(a: T, b: T): -1 | 0 | 1;
103
- /**
104
- * Sorts an array of objects hierarchically based on their fully qualified names (FQN).
105
- * Objects are sorted by the number of segments in their FQN (defined by dot-separated ID).
106
- *
107
- * @typeParam T - Object type that contains an 'id' string property
108
- * @typeParam A - Type extending IterableContainer of T
109
- *
110
- * @param array - Array of objects to be sorted
111
- * @returns A new array with items sorted by their FQN hierarchy depth (number of segments)
112
- *
113
- * @example
114
- * ```ts
115
- * const items = [
116
- * { id: "a.b.c" },
117
- * { id: "a" },
118
- * { id: "a.b" }
119
- * ];
120
- * sortByFqnHierarchically(items);
121
- * // Result: [
122
- * // { id: "a" },
123
- * // { id: "a.b" },
124
- * // { id: "a.b.c" }
125
- * // ]
126
- * ```
127
- */
128
- declare function sortByFqnHierarchically<T extends {
129
- id: string;
130
- }, A extends IterableContainer<T>>(array: A): ReorderedArray<A>;
131
- /**
132
- * Keeps initial order of the elements, but ensures that parents are before children
133
- */
134
- declare function sortParentsFirst<T extends {
135
- id: string;
136
- }, A extends IterableContainer<T>>(array: A): ReorderedArray<A>;
137
- /**
138
- * Sorts an array of objects naturally by their fully qualified name (FQN) identifier.
139
- *
140
- * @template T - Type of objects containing an 'id' string property
141
- * @template A - Type extending IterableContainer of T
142
- *
143
- * @param first - Optional. Either the array to sort or the sort direction ('asc'|'desc')
144
- * @param sort - Optional. The sort direction ('asc'|'desc'). Defaults to 'asc' if not specified
145
- *
146
- * @example
147
- * // As a function that returns a sorting function
148
- * const sorted = sortNaturalByFqn('desc')(myArray);
149
- *
150
- * // Direct array sorting
151
- * const sorted = sortNaturalByFqn(myArray, 'desc');
152
- */
153
- declare function sortNaturalByFqn(sort?: 'asc' | 'desc'): <I extends WithId<string>, A extends IterableContainer<I>>(array: A) => ReorderedArray<A>;
154
- declare function sortNaturalByFqn<A extends IterableContainer<WithId>>(array: A, sort?: 'asc' | 'desc'): ReorderedArray<A>;
155
- //#endregion
156
- //#region src/utils/getOrCreate.d.ts
157
- declare function getOrCreate<K, V>(map: Map<K, V>, key: K, create: (key: K) => V): V;
158
- declare function getOrCreate<K extends WeakKey, V>(map: WeakMap<K, V>, key: K, create: (key: K) => V): V;
159
- //#endregion
160
- //#region src/utils/guards.d.ts
161
- declare function isString(value: unknown): value is string;
162
- declare function isNonEmptyArray<A>(arr: ArrayLike<A> | undefined): arr is NonEmptyArray<A>;
163
- declare function hasProp<T extends object, P extends keyof T & string>(value: T, path: P): value is SetRequired<SetNonNullable<T, P>, P>;
164
- type Guard<N = unknown> = (n: unknown) => n is N;
165
- type Guarded<G> = G extends Guard<infer N> ? N : never;
166
- /**
167
- * Creates a type guard that checks if a value matches any of the provided predicates.
168
- *
169
- * @template Predicates - A non-empty array of guard functions
170
- * @param predicates - The guard functions to test against
171
- * @returns A type guard function that returns true if the value matches any of the predicates
172
- *
173
- * @example
174
- * ```typescript
175
- * const isStringOrNumber = isAnyOf(isString, isNumber);
176
- *
177
- * if (isStringOrNumber(value)) {
178
- * // value is now typed as string | number
179
- * console.log(value);
180
- * }
181
- * ```
182
- */
183
- declare function isAnyOf<const Predicates extends NonEmptyArray<Guard>>(...predicates: Predicates): (value: unknown) => value is Guarded<Predicates[number]>;
184
- //#endregion
185
- //#region src/utils/memoize-prop.d.ts
186
- /**
187
- * Saves the value returned by fn() in a hidden property tag of obj object, so next time memoizeProp() is called,
188
- * that value will be returned, and fn won't be called.
189
- *
190
- * @example
191
- * ```ts
192
- * class Model {
193
- * // using same Symbol
194
- * get computed1() {
195
- * return memoizeProp(this, Symbol.for('computed1'), () => doOnce())
196
- * }
197
- * // using string
198
- * get computed2() {
199
- * return memoizeProp(this, 'computed2', () => doOnce())
200
- * }
201
- *
202
- * }
203
- * ```
204
- */
205
- declare function memoizeProp<Tag extends symbol | string, Res>(obj: object, tag: Tag, fn: () => Res): Res;
206
- //#endregion
207
- //#region src/utils/promises.d.ts
208
- declare function delay(): Promise<string>;
209
- declare function delay(ms: number): Promise<string>;
210
- declare function delay(randomFrom: number, randomTo: number): Promise<string>;
211
- declare function promiseNextTick(): Promise<void>;
212
- declare function onNextTick(fn: () => Promise<void> | void): void;
213
- //#endregion
214
- //#region src/utils/relations.d.ts
215
- type RelationshipLike = {
216
- source: {
217
- id: string;
218
- };
219
- target: {
220
- id: string;
221
- };
222
- };
223
- /**
224
- * Compares two relations hierarchically.
225
- * From the most general (implicit) to the most specific (deepest in the tree)
226
- */
227
- declare const compareRelations: <T extends RelationshipLike>(a: T, b: T) => number;
228
- //#endregion
229
- //#region src/utils/set.d.ts
230
- /**
231
- * Returns new set as a union of given sets
232
- * Keeps order of elements
233
- */
234
- declare function union<T>(...sets: ReadonlySet<T>[]): Set<T>;
235
- /**
236
- * Returns new set as an intersection of all sets
237
- * Keeps order from the first set
238
- */
239
- declare function intersection<T>(first: ReadonlySet<T>, ...sets: NonEmptyArray<ReadonlySet<NoInfer<T>>>): Set<T>;
240
- /**
241
- * Returns new set as a difference of two sets (A-B)
242
- * Keeps order from the first set
243
- */
244
- declare function difference<T>(a: ReadonlySet<T>, b: ReadonlySet<NoInfer<T>>): Set<T>;
245
- declare function equals<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean;
246
- declare function symmetricDifference<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): Set<T>;
247
- //#endregion
248
- //#region src/utils/object-hash.d.ts
249
- declare function objectHash(value: any): string;
250
- //#endregion
251
- //#region src/utils/string-hash.d.ts
252
- /**
253
- * @see https://gist.github.com/victor-homyakov/bcb7d7911e4a388b1c810f8c3ce17bcf
254
- */
255
- declare function stringHash(str: string): string;
256
- //#endregion
257
- //#region src/utils/markdown/to-html.d.ts
258
- declare function markdownToHtml(markdown: string): string;
259
- //#endregion
260
- //#region src/utils/markdown/to-text.d.ts
261
- /**
262
- * Converts markdown to plain text, removing any markdown formatting.
263
- * @param markdown - The markdown to convert.
264
- * @returns The plain text.
265
- */
266
- declare function markdownToText(markdown: string): string;
267
- //#endregion
268
- export { parentFqn as A, compareFqnHierarchically as C, isDescendantOf as D, isAncestor as E, compareNaturalHierarchically as F, commonHead as I, invariant as L, sortNaturalByFqn as M, sortParentsFirst as N, isSameHierarchy as O, compareNatural as P, nonNullable as R, compareByFqnHierarchically as S, hierarchyLevel as T, isNonEmptyArray as _, difference as a, ancestorsFqn as b, symmetricDifference as c, delay as d, onNextTick as f, isAnyOf as g, hasProp as h, objectHash as i, sortByFqnHierarchically as j, nameFromFqn as k, union as l, memoizeProp as m, markdownToHtml as n, equals as o, promiseNextTick as p, stringHash as r, intersection as s, markdownToText as t, compareRelations as u, isString as v, hierarchyDistance as w, commonAncestor as x, getOrCreate as y, nonexhaustive as z };
@@ -1,144 +0,0 @@
1
- import { bt as IteratorLike } from "./_aux.mjs";
2
-
3
- //#region src/utils/iterable/_types.d.ts
4
- declare function isIterable<T, I extends Iterable<T>>(something: I | unknown): something is Iterable<T>;
5
- //#endregion
6
- //#region src/utils/iterable/filter.d.ts
7
- /**
8
- * Filters an iterable based on a predicate.
9
- * Composabel first version of `ifilter`.
10
- * @signature
11
- * ifilter(predicate)(data)
12
- */
13
- declare function ifilter<T, S extends T>(predicate: (v: T) => v is S): (iterable: Iterable<T>) => IteratorLike<S>;
14
- declare function ifilter<T>(predicate: (v: T) => boolean): (iterable: Iterable<T>) => IteratorLike<T>;
15
- /**
16
- * Filters an iterable based on a predicate.
17
- * Data first version of `ifilter`.
18
- * @signature
19
- * ifilter(data, predicate)
20
- * @example
21
- * ifilter(new Set([1, 2, 3]), x => x % 2 === 1) // => Iterable<[1, 3]>
22
- */
23
- declare function ifilter<T, S extends T>(iterable: Iterable<T>, predicate: (v: T) => v is S): IteratorLike<S>;
24
- declare function ifilter<T>(iterable: Iterable<T>, predicate: (v: T) => boolean): IteratorLike<T>;
25
- //#endregion
26
- //#region src/utils/iterable/find.d.ts
27
- /**
28
- * Finds the first element in the iterable that satisfies the predicate.
29
- * Composable first version of `find`.
30
- * @signature
31
- * ifind(predicate)(data)
32
- */
33
- declare function ifind<T, S extends T>(predicate: (item: T) => item is S): (iterable: Iterable<T>) => S | undefined;
34
- declare function ifind<T>(predicate: (item: T) => boolean): (iterable: Iterable<T>) => T | undefined;
35
- /**
36
- * Finds the first element in the iterable that satisfies the predicate.
37
- * Data first version of `find`.
38
- * @signature
39
- * ifind(data, predicate)
40
- */
41
- declare function ifind<T, S extends T>(iterable: Iterable<T>, predicate: (item: T) => item is S): S | undefined;
42
- declare function ifind<T>(iterable: Iterable<T>, predicate: (item: T) => boolean): T | undefined;
43
- //#endregion
44
- //#region src/utils/iterable/first.d.ts
45
- /**
46
- * Takes the first N elements from an iterable.
47
- * Composable first version of `ifirst`.
48
- * @signature
49
- * ifirst(count)(data)
50
- */
51
- declare function ifirst<T>(count: number): (iterable: Iterable<T>) => IteratorLike<T>;
52
- /**
53
- * Takes the first N elements from an iterable.
54
- * Data first version of `ifirst`.
55
- * @signature
56
- * ifirst(data, count)
57
- * @example
58
- * ifirst([1, 2, 3, 4, 5], 3) // => Iterable<[1, 2, 3]>
59
- */
60
- declare function ifirst<T>(iterable: Iterable<T>, count: number): IteratorLike<T>;
61
- //#endregion
62
- //#region src/utils/iterable/flat.d.ts
63
- declare function iflat(): <T>(iterable: Iterable<IteratorLike<T>>) => IteratorLike<T>;
64
- declare function iflat<T>(iterable: Iterable<IteratorLike<T>>): IteratorLike<T>;
65
- //#endregion
66
- //#region src/utils/iterable/flatMap.d.ts
67
- type FlatMapFunction<T, S> = (item: T) => Iterable<S>;
68
- /**
69
- * Maps an iterable using a mapper function and flattens the result by one level.
70
- * Composable first version of `iflatMap`.
71
- * @signature
72
- * iflatMap(mapper)(data)
73
- */
74
- declare function iflatMap<T, S>(mapper: FlatMapFunction<T, S>): (iterable: Iterable<T>) => IteratorLike<S>;
75
- /**
76
- * Maps an iterable using a mapper function and flattens the result by one level.
77
- * Data first version of `iflatMap`.
78
- * @signature
79
- * iflatMap(data, mapper)
80
- */
81
- declare function iflatMap<T, S>(iterable: Iterable<T>, mapper: FlatMapFunction<T, S>): IteratorLike<S>;
82
- //#endregion
83
- //#region src/utils/iterable/head.d.ts
84
- declare function ihead<T>(): (iterable: Iterable<T>) => T | undefined;
85
- /**
86
- * Finds the first element in the iterable that satisfies the predicate.
87
- * Data first version of `find`.
88
- * @signature
89
- * ifind(data, predicate)
90
- */
91
- declare function ihead<T>(iterable: Iterable<T>): T | undefined;
92
- //#endregion
93
- //#region src/utils/iterable/map.d.ts
94
- type MapFunction<T, S> = (item: T) => S;
95
- /**
96
- * Maps an iterable using a mapper function.
97
- * Composable first version of `imap`.
98
- * @signature
99
- * imap(mapper)(data)
100
- */
101
- declare function imap<T, S>(mapper: MapFunction<T, S>): (iterable: Iterable<T>) => IteratorLike<S>;
102
- /**
103
- * Maps an iterable using a mapper function.
104
- * Data first version of `imap`.
105
- * @signature
106
- * imap(data, mapper)
107
- */
108
- declare function imap<T, S>(iterable: Iterable<T>, mapper: MapFunction<T, S>): IteratorLike<S>;
109
- //#endregion
110
- //#region src/utils/iterable/reduce.d.ts
111
- declare function ireduce<T, R>(reducer: (acc: R, item: T) => R, initialValue: R): (iterable: Iterable<T>) => R;
112
- declare function ireduce<T, R>(iterable: Iterable<T>, reducer: (acc: R, item: T) => R, initialValue: R): R;
113
- //#endregion
114
- //#region src/utils/iterable/some.d.ts
115
- /**
116
- * Checks if at least one element in the iterable satisfies the predicate.
117
- * Composable first version of `some`.
118
- * @signature
119
- * isome(predicate)(data)
120
- */
121
- declare function isome<T>(predicate: (item: T) => boolean): (iterable: Iterable<T>) => boolean;
122
- /**
123
- * Checks if at least one element in the iterable satisfies the predicate.
124
- * Data first version of `some`.
125
- * @signature
126
- * isome(data, predicate)
127
- */
128
- declare function isome<T>(iterable: Iterable<T>, predicate: (item: T) => boolean): boolean;
129
- //#endregion
130
- //#region src/utils/iterable/to.d.ts
131
- declare function toArray(): <T>(iterable: Iterable<T> | ArrayLike<T>) => T[];
132
- declare function toArray<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
133
- declare function toSet(): <T>(iterable: Iterable<T>) => Set<T>;
134
- declare function toSet<T>(iterable: Iterable<T>): Set<T>;
135
- //#endregion
136
- //#region src/utils/iterable/unique.d.ts
137
- /**
138
- * Returns an iterable that yields only unique values.
139
- * It uses a Set to keep track of the values.
140
- */
141
- declare function iunique(): <T>(iterable: Iterable<T>) => IteratorLike<T>;
142
- declare function iunique<T>(iterable: Iterable<T>): IteratorLike<T>;
143
- //#endregion
144
- export { ireduce as a, iflatMap as c, ifind as d, ifilter as f, isome as i, iflat as l, toArray as n, imap as o, isIterable as p, toSet as r, ihead as s, iunique as t, ifirst as u };
@@ -1,18 +0,0 @@
1
- //#region src/utils/invariant.ts
2
- function nonNullable(value, message) {
3
- if (typeof value === "undefined" || value == null) {
4
- const msg = typeof message === "function" ? message() : message;
5
- throw new Error(msg ?? `Expected defined value, but received ${value}`);
6
- }
7
- return value;
8
- }
9
- function invariant(condition, message) {
10
- if (condition) return;
11
- throw new Error(message ?? "Invariant failed");
12
- }
13
- function nonexhaustive(value) {
14
- throw new Error(`NonExhaustive value: ${value}`);
15
- }
16
-
17
- //#endregion
18
- export { nonNullable as n, nonexhaustive as r, invariant as t };
@@ -1,146 +0,0 @@
1
- import { L as e$2, N as e, P as e$1 } from "./libs/remeda.mjs";
2
- import { t as invariant } from "./invariant.mjs";
3
-
4
- //#region src/utils/iterable/_types.ts
5
- function isIterable(something) {
6
- return e(something) && typeof something === "object" && Symbol.iterator in something;
7
- }
8
-
9
- //#endregion
10
- //#region src/utils/iterable/filter.ts
11
- function ifilter(arg1, arg2) {
12
- const pred = arg2 ?? arg1;
13
- invariant(e$1(pred));
14
- function* _filter(iter) {
15
- for (const value of iter) if (pred(value)) yield value;
16
- }
17
- if (!arg2) return _filter;
18
- return _filter(arg1);
19
- }
20
-
21
- //#endregion
22
- //#region src/utils/iterable/find.ts
23
- function ifind(arg1, arg2) {
24
- const pred = arg2 ?? arg1;
25
- invariant(e$1(pred));
26
- function _find(iter) {
27
- for (const value of iter) if (pred(value)) return value;
28
- }
29
- if (!arg2) return _find;
30
- return _find(arg1);
31
- }
32
-
33
- //#endregion
34
- //#region src/utils/iterable/first.ts
35
- function ifirst(arg1, arg2) {
36
- const count = arg2 ?? arg1;
37
- invariant(typeof count === "number" && count >= 0, "Count must be a non-negative number");
38
- function* _first(iter) {
39
- let taken = 0;
40
- for (const value of iter) {
41
- if (taken >= count) break;
42
- yield value;
43
- taken++;
44
- }
45
- }
46
- if (arg2 === void 0) return (iterable) => _first(iterable);
47
- return _first(arg1);
48
- }
49
-
50
- //#endregion
51
- //#region src/utils/iterable/flat.ts
52
- function iflat(iterable) {
53
- return iterable ? _iflat(iterable) : _iflat;
54
- }
55
- function* _iflat(iterable) {
56
- for (const inner of iterable) yield* inner;
57
- }
58
-
59
- //#endregion
60
- //#region src/utils/iterable/flatMap.ts
61
- function iflatMap(arg1, arg2) {
62
- const mapper = arg2 ?? arg1;
63
- invariant(e$1(mapper));
64
- function* _flatMap(iter) {
65
- for (const value of iter) yield* mapper(value);
66
- }
67
- if (!arg2) return _flatMap;
68
- return _flatMap(arg1);
69
- }
70
-
71
- //#endregion
72
- //#region src/utils/iterable/head.ts
73
- function ihead(iterable) {
74
- if (!iterable) return _head;
75
- return _head(iterable);
76
- }
77
- function _head(iter) {
78
- const { value } = iter[Symbol.iterator]().next();
79
- return value;
80
- }
81
-
82
- //#endregion
83
- //#region src/utils/iterable/map.ts
84
- function imap(arg1, arg2) {
85
- const mapper = arg2 ?? arg1;
86
- invariant(e$1(mapper));
87
- function* _map(iter) {
88
- for (const value of iter) yield mapper(value);
89
- }
90
- if (!arg2) return _map;
91
- return _map(arg1);
92
- }
93
-
94
- //#endregion
95
- //#region src/utils/iterable/reduce.ts
96
- function ireduce(arg1, arg2, arg3) {
97
- const reducer = e$2(arg3) ? arg2 : arg1;
98
- const initialValue = arg3 ?? arg2;
99
- invariant(e$1(reducer));
100
- function _reduce(iter) {
101
- let acc = initialValue;
102
- for (const value of iter) acc = reducer(acc, value);
103
- return acc;
104
- }
105
- return e$2(arg3) ? _reduce(arg1) : _reduce;
106
- }
107
-
108
- //#endregion
109
- //#region src/utils/iterable/some.ts
110
- function isome(arg1, arg2) {
111
- const pred = arg2 ?? arg1;
112
- invariant(e$1(pred));
113
- function _some(iter) {
114
- for (const value of iter) if (pred(value)) return true;
115
- return false;
116
- }
117
- if (!arg2) return _some;
118
- return _some(arg1);
119
- }
120
-
121
- //#endregion
122
- //#region src/utils/iterable/to.ts
123
- function toArray(iterable) {
124
- if (iterable) return Array.from(iterable);
125
- return (it) => Array.from(it);
126
- }
127
- function toSet(iterable) {
128
- if (iterable) return new Set(iterable);
129
- return (it) => new Set(it);
130
- }
131
-
132
- //#endregion
133
- //#region src/utils/iterable/unique.ts
134
- function iunique(iterable) {
135
- return iterable ? _iunique(iterable) : _iunique;
136
- }
137
- function* _iunique(iterable) {
138
- const seen = /* @__PURE__ */ new Set();
139
- for (const item of iterable) if (!seen.has(item)) {
140
- seen.add(item);
141
- yield item;
142
- }
143
- }
144
-
145
- //#endregion
146
- export { ireduce as a, iflatMap as c, ifind as d, ifilter as f, isome as i, iflat as l, toArray as n, imap as o, isIterable as p, toSet as r, ihead as s, iunique as t, ifirst as u };