@likec4/core 1.48.0 → 1.49.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.
- package/dist/THIRD-PARTY-LICENSES.md +1012 -0
- package/dist/_chunks/Builder.view-element.mjs +2 -3284
- package/dist/_chunks/LikeC4Model.d.mts +21 -25
- package/dist/_chunks/RichText.mjs +1 -148
- package/dist/_chunks/_types.d.mts +1 -5
- package/dist/_chunks/_types2.d.mts +2 -4
- package/dist/_chunks/assignTagColors.mjs +1 -24
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +1 -379
- package/dist/_chunks/guards.d.mts +2026 -0
- package/dist/_chunks/guards.mjs +4 -0
- package/dist/_chunks/index.d.mts +255 -136
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
- package/dist/_chunks/libs/bail.mjs +1 -14
- package/dist/_chunks/libs/ccount.mjs +1 -25
- package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
- package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
- package/dist/_chunks/libs/character-entities.mjs +2 -2136
- package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
- package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
- package/dist/_chunks/libs/defu.mjs +1 -42
- package/dist/_chunks/libs/devlop.mjs +1 -5
- package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
- package/dist/_chunks/libs/extend.mjs +1 -77
- package/dist/_chunks/libs/graphology-dag.mjs +1 -703
- package/dist/_chunks/libs/graphology.mjs +1 -4565
- package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
- package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
- package/dist/_chunks/libs/longest-streak.mjs +1 -30
- package/dist/_chunks/libs/markdown-table.mjs +2 -290
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
- package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
- package/dist/_chunks/libs/mnemonist.d.mts +1 -91
- package/dist/_chunks/libs/mnemonist.mjs +1 -1978
- package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
- package/dist/_chunks/libs/ohash.mjs +1 -0
- package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
- package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
- package/dist/_chunks/libs/remark-gfm.mjs +1 -36
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
- package/dist/_chunks/libs/remark-parse.mjs +1 -39
- package/dist/_chunks/libs/remark-rehype.mjs +1 -171
- package/dist/_chunks/libs/remeda.mjs +1 -702
- package/dist/_chunks/libs/trough.mjs +1 -158
- package/dist/_chunks/libs/unified.mjs +1 -2212
- package/dist/_chunks/rolldown-runtime.mjs +1 -42
- package/dist/_chunks/{index3.d.mts → theme.d.mts} +15 -13
- package/dist/_chunks/{index7.d.mts → to-text.d.mts} +165 -29
- package/dist/_chunks/to-text.mjs +1 -0
- package/dist/_chunks/vector.d.mts +198 -0
- package/dist/_chunks/vector.mjs +1 -0
- package/dist/builder/index.d.mts +2 -8
- package/dist/builder/index.mjs +1 -662
- package/dist/compute-view/index.d.mts +86 -15
- package/dist/compute-view/index.mjs +2 -262
- package/dist/geometry/index.d.mts +2 -2
- package/dist/geometry/index.mjs +1 -3
- package/dist/index.d.mts +9 -13
- package/dist/index.mjs +1 -27
- package/dist/model/index.d.mts +4 -14
- package/dist/model/index.mjs +1 -11
- package/dist/styles/index.d.mts +2 -8
- package/dist/styles/index.mjs +1 -30
- package/dist/types/index.d.mts +3 -9
- package/dist/types/index.mjs +1 -15
- package/dist/utils/graphology/index.d.mts +1 -1
- package/dist/utils/graphology/index.mjs +1 -3
- package/dist/utils/index.d.mts +4 -11
- package/dist/utils/index.mjs +1 -17
- package/package.json +13 -12
- package/dist/_chunks/LikeC4Styles.mjs +0 -691
- package/dist/_chunks/RichText.d.mts +0 -84
- package/dist/_chunks/_aux.d.mts +0 -289
- package/dist/_chunks/_aux.mjs +0 -18
- package/dist/_chunks/connection.mjs +0 -0
- package/dist/_chunks/const.d.mts +0 -43
- package/dist/_chunks/const.mjs +0 -33
- package/dist/_chunks/expression-model.d.mts +0 -192
- package/dist/_chunks/expression-model.mjs +0 -103
- package/dist/_chunks/expression.d.mts +0 -347
- package/dist/_chunks/expression.mjs +0 -107
- package/dist/_chunks/find.d.mts +0 -82
- package/dist/_chunks/find.mjs +0 -646
- package/dist/_chunks/find2.d.mts +0 -78
- package/dist/_chunks/find2.mjs +0 -287
- package/dist/_chunks/fqnRef.d.mts +0 -58
- package/dist/_chunks/fqnRef.mjs +0 -41
- package/dist/_chunks/geometry.mjs +0 -335
- package/dist/_chunks/index2.d.mts +0 -937
- package/dist/_chunks/index4.d.mts +0 -62
- package/dist/_chunks/index5.d.mts +0 -42
- package/dist/_chunks/index6.d.mts +0 -43
- package/dist/_chunks/index8.d.mts +0 -144
- package/dist/_chunks/invariant.mjs +0 -18
- package/dist/_chunks/iterable.mjs +0 -146
- package/dist/_chunks/libs/graphology-types.d.mts +0 -601
- package/dist/_chunks/libs/graphology.d.mts +0 -6
- package/dist/_chunks/mnemonist.d.mts +0 -1
- package/dist/_chunks/mnemonist.mjs +0 -0
- package/dist/_chunks/model.mjs +0 -1898
- package/dist/_chunks/model2.mjs +0 -0
- package/dist/_chunks/relationships-view.mjs +0 -132
- package/dist/_chunks/scalar.d.mts +0 -109
- package/dist/_chunks/scalar.mjs +0 -84
- package/dist/_chunks/utils.mjs +0 -483
- package/dist/compute-view/relationships-view/index.d.mts +0 -16
- package/dist/compute-view/relationships-view/index.mjs +0 -7
- package/dist/model/connection/deployment/index.d.mts +0 -12
- package/dist/model/connection/deployment/index.mjs +0 -9
- package/dist/model/connection/index.d.mts +0 -14
- package/dist/model/connection/index.mjs +0 -10
- package/dist/model/connection/model/index.d.mts +0 -12
- package/dist/model/connection/model/index.mjs +0 -8
- package/dist/types/RichText.d.mts +0 -3
- package/dist/types/RichText.mjs +0 -7
- package/dist/types/_aux.d.mts +0 -3
- package/dist/types/_aux.mjs +0 -3
- package/dist/types/expression-model.d.mts +0 -6
- package/dist/types/expression-model.mjs +0 -7
- package/dist/types/expression.d.mts +0 -5
- package/dist/types/expression.mjs +0 -7
- package/dist/types/fqnRef.d.mts +0 -4
- package/dist/types/fqnRef.mjs +0 -7
- package/dist/types/scalar.d.mts +0 -2
- package/dist/types/scalar.mjs +0 -7
- package/dist/utils/iterable/index.d.mts +0 -9
- package/dist/utils/iterable/index.mjs +0 -3
- package/dist/utils/mnemonist.d.mts +0 -2
- package/dist/utils/mnemonist.mjs +0 -12
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Dt as ReorderedArray, yt as IterableContainer } from "./_aux.mjs";
|
|
2
|
-
import { n as Connection } from "./const.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/model/connection/ops.d.ts
|
|
5
|
-
/**
|
|
6
|
-
* Check if connection is nested inside another connection
|
|
7
|
-
* (i.e. between descendants)
|
|
8
|
-
*/
|
|
9
|
-
declare function isNestedConnection<T extends {
|
|
10
|
-
id: string;
|
|
11
|
-
}>(parent: WithSourceTarget<NoInfer<T>>): (nested: WithSourceTarget<T>) => boolean;
|
|
12
|
-
declare function isNestedConnection<T extends {
|
|
13
|
-
id: string;
|
|
14
|
-
}>(nested: WithSourceTarget<T>, parent: WithSourceTarget<T>): boolean;
|
|
15
|
-
type ConnectionElemId = Connection<{
|
|
16
|
-
readonly id: string;
|
|
17
|
-
}, any>;
|
|
18
|
-
declare function findDeepestNestedConnection<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): C | null;
|
|
19
|
-
declare function sortDeepestFirst<C extends ConnectionElemId>(connections: ReadonlyArray<C>): C[];
|
|
20
|
-
type WithBoundary = {
|
|
21
|
-
id: string;
|
|
22
|
-
boundary: null | {
|
|
23
|
-
id: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
declare function sortConnectionsByBoundaryHierarchy(sort?: 'asc' | 'desc'): <T extends WithBoundary, A extends IterableContainer<T>>(array: A) => ReorderedArray<A>;
|
|
27
|
-
declare function sortConnectionsByBoundaryHierarchy<T extends WithBoundary, A extends IterableContainer<T>>(array: A, sort?: 'asc' | 'desc'): ReorderedArray<A>;
|
|
28
|
-
/**
|
|
29
|
-
* Find connections that includes given connection (i.e between it's ancestors)
|
|
30
|
-
*/
|
|
31
|
-
declare function findAscendingConnections<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): Array<C>;
|
|
32
|
-
/**
|
|
33
|
-
* Find connections that given connection includes (i.e between it's descendants)
|
|
34
|
-
*/
|
|
35
|
-
declare function findDescendantConnections<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): Array<C>;
|
|
36
|
-
declare function mergeConnections<C extends IterableContainer<Connection<any, any>>>(connections: C): Array<C[number]>;
|
|
37
|
-
/**
|
|
38
|
-
* Excludes the values existing in `other` array.
|
|
39
|
-
* The output maintains the same order as the input.
|
|
40
|
-
*/
|
|
41
|
-
declare function differenceConnections<C extends Connection<any, any>>(source: Iterable<C>, exclude: Iterable<C>): C[];
|
|
42
|
-
type WithSourceTarget<T = unknown> = {
|
|
43
|
-
source: T;
|
|
44
|
-
target: T;
|
|
45
|
-
};
|
|
46
|
-
declare function hasSameSourceTarget<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
|
|
47
|
-
declare function hasSameSourceTarget<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
|
|
48
|
-
declare function hasSameSource<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
|
|
49
|
-
declare function hasSameSource<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
|
|
50
|
-
declare function hasSameTarget<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
|
|
51
|
-
declare function hasSameTarget<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
|
|
52
|
-
type WithId<T> = {
|
|
53
|
-
id: T;
|
|
54
|
-
};
|
|
55
|
-
declare function isOutgoing<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
|
|
56
|
-
declare function isOutgoing<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean;
|
|
57
|
-
declare function isIncoming<T extends string>(target: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
|
|
58
|
-
declare function isIncoming<T extends string>(a: WithSourceTarget<WithId<T>>, target: WithId<T>): boolean;
|
|
59
|
-
declare function isAnyInOut<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
|
|
60
|
-
declare function isAnyInOut<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean;
|
|
61
|
-
//#endregion
|
|
62
|
-
export { hasSameSource as a, isAnyInOut as c, isOutgoing as d, mergeConnections as f, findDescendantConnections as i, isIncoming as l, sortDeepestFirst as m, findAscendingConnections as n, hasSameSourceTarget as o, sortConnectionsByBoundaryHierarchy as p, findDeepestNestedConnection as r, hasSameTarget as s, differenceConnections as t, isNestedConnection as u };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { n as Any } from "./_aux.mjs";
|
|
2
|
-
import { C as ElementModel, S as NodeModel, T as RelationshipModel, a as DeploymentNodeModel, c as NestedElementOfDeployedInstanceModel, i as DeploymentElementModel, r as DeployedInstanceModel, s as DeploymentRelationModel, w as AnyRelationshipModel, x as EdgeModel, y as LikeC4ViewModel } from "./LikeC4Model.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/model/guards.d.ts
|
|
5
|
-
type AnyModel<A extends Any> = DeploymentNodeModel<A> | DeployedInstanceModel<A> | DeploymentRelationModel<A> | AnyRelationshipModel<A> | NestedElementOfDeployedInstanceModel<A> | ElementModel<A> | RelationshipModel<A> | LikeC4ViewModel<A> | NodeModel<A> | EdgeModel<A>;
|
|
6
|
-
declare function isDeploymentNodeModel<M extends Any>(model: AnyModel<M>): model is DeploymentNodeModel<M>;
|
|
7
|
-
declare function isDeployedInstanceModel<M extends Any>(model: AnyModel<M>): model is DeployedInstanceModel<M>;
|
|
8
|
-
declare function isDeploymentElementModel<M extends Any>(model: AnyModel<M>): model is DeploymentElementModel<M>;
|
|
9
|
-
declare function isNestedElementOfDeployedInstanceModel<M extends Any>(model: AnyModel<M>): model is NestedElementOfDeployedInstanceModel<M>;
|
|
10
|
-
declare function isDeploymentRelationModel<M extends Any>(x: AnyModel<M>): x is DeploymentRelationModel<M>;
|
|
11
|
-
declare function isRelationModel<M extends Any>(x: AnyModel<M>): x is RelationshipModel<M>;
|
|
12
|
-
declare function isElementModel<M extends Any>(element: AnyModel<M>): element is ElementModel<M>;
|
|
13
|
-
declare function isLikeC4ViewModel<M extends Any>(view: AnyModel<M>): view is LikeC4ViewModel<M>;
|
|
14
|
-
declare function isNodeModel<M extends Any>(node: AnyModel<M>): node is NodeModel<M>;
|
|
15
|
-
declare function isEdgeModel<M extends Any>(edge: AnyModel<M>): edge is EdgeModel<M>;
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/model/utils/view-title-path.d.ts
|
|
18
|
-
declare const VIEW_FOLDERS_SEPARATOR = "/";
|
|
19
|
-
/**
|
|
20
|
-
* Normalizes view path by removing spaces from segments, removing empty segments,
|
|
21
|
-
* and removing leading/trailing slashes
|
|
22
|
-
* @example
|
|
23
|
-
* normalizeViewPath('One / Tw o / Thre e') === 'One/Tw o/Thre e'
|
|
24
|
-
*/
|
|
25
|
-
declare const normalizeViewPath: (title: string) => string;
|
|
26
|
-
/**
|
|
27
|
-
* Returns view group path if it is used as a path
|
|
28
|
-
* Returns empty string if it is not a path
|
|
29
|
-
* @example
|
|
30
|
-
* getViewFolderPath('One / Tw o / Thre e') === 'One/Tw o'
|
|
31
|
-
* getViewFolderPath('One') === ''
|
|
32
|
-
*/
|
|
33
|
-
declare const getViewFolderPath: (title: string) => string | null;
|
|
34
|
-
/**
|
|
35
|
-
* Returns view title if it is used as a path
|
|
36
|
-
* @example
|
|
37
|
-
* getViewTitleFromPath('One / Tw o / Thre e') === 'Thre e'
|
|
38
|
-
* getViewTitleFromPath('One') === 'One'
|
|
39
|
-
*/
|
|
40
|
-
declare const extractViewTitleFromPath: (title: string) => string;
|
|
41
|
-
//#endregion
|
|
42
|
-
export { isDeployedInstanceModel as a, isDeploymentRelationModel as c, isLikeC4ViewModel as d, isNestedElementOfDeployedInstanceModel as f, normalizeViewPath as i, isEdgeModel as l, isRelationModel as m, extractViewTitleFromPath as n, isDeploymentElementModel as o, isNodeModel as p, getViewFolderPath as r, isDeploymentNodeModel as s, VIEW_FOLDERS_SEPARATOR as t, isElementModel as u };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { G as Unknown, Y as ViewId, n as Any, p as ElementId } from "./_aux.mjs";
|
|
2
|
-
import { C as ElementModel, T as RelationshipModel, n as LikeC4Model } from "./LikeC4Model.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/compute-view/relationships-view/_types.d.ts
|
|
5
|
-
type RelationshipsViewData<M extends Any = Unknown> = {
|
|
6
|
-
incomers: ReadonlySet<ElementModel<M>>;
|
|
7
|
-
incoming: ReadonlySet<RelationshipModel<M>>;
|
|
8
|
-
subjects: ReadonlySet<ElementModel<M>>;
|
|
9
|
-
outgoing: ReadonlySet<RelationshipModel<M>>;
|
|
10
|
-
outgoers: ReadonlySet<ElementModel<M>>;
|
|
11
|
-
};
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/compute-view/relationships-view/compute.d.ts
|
|
14
|
-
declare function computeRelationshipsView<M extends Any>(subjectId: ElementId<M>, likec4model: LikeC4Model<M>, scopeViewId: ViewId<M> | null, scope?: 'global' | 'view'): RelationshipsViewData<M>;
|
|
15
|
-
//#endregion
|
|
16
|
-
//#region src/compute-view/relationships-view/utils.d.ts
|
|
17
|
-
declare function treeFromElements<M extends Any>(elements: Iterable<ElementModel<M>>): {
|
|
18
|
-
sorted: readonly ElementModel<M>[];
|
|
19
|
-
byId: (id: ElementId<M>) => ElementModel<M>;
|
|
20
|
-
root: ReadonlySet<ElementModel<M>>;
|
|
21
|
-
parent: (el: ElementModel<M>) => ElementModel<M> | null;
|
|
22
|
-
children: (el: ElementModel<M>) => ReadonlyArray<ElementModel<M>>;
|
|
23
|
-
/**
|
|
24
|
-
* Flattens the tree structure by removing redundant hierarchy levels.
|
|
25
|
-
* @example
|
|
26
|
-
* A
|
|
27
|
-
* └── B
|
|
28
|
-
* ├── C
|
|
29
|
-
* │ └── D
|
|
30
|
-
* │ └── E
|
|
31
|
-
* └── F
|
|
32
|
-
* └── G
|
|
33
|
-
* becomes
|
|
34
|
-
* A
|
|
35
|
-
* ├── C
|
|
36
|
-
* │ └── E
|
|
37
|
-
* └── F
|
|
38
|
-
* └── G
|
|
39
|
-
*/
|
|
40
|
-
flatten: () => Set<ElementModel<M>>;
|
|
41
|
-
};
|
|
42
|
-
//#endregion
|
|
43
|
-
export { computeRelationshipsView as n, RelationshipsViewData as r, treeFromElements as t };
|
|
@@ -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 };
|