@likec4/core 1.23.1 → 1.24.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 (72) hide show
  1. package/dist/builder/index.d.mts +3 -3
  2. package/dist/builder/index.d.ts +3 -3
  3. package/dist/builder/index.mjs +2 -2
  4. package/dist/compute-view/index.d.mts +4 -4
  5. package/dist/compute-view/index.d.ts +4 -4
  6. package/dist/compute-view/index.mjs +4 -4
  7. package/dist/index.d.mts +7 -8
  8. package/dist/index.d.ts +7 -8
  9. package/dist/index.mjs +4 -4
  10. package/dist/model/index.d.mts +5 -5
  11. package/dist/model/index.d.ts +5 -5
  12. package/dist/model/index.mjs +1 -1
  13. package/dist/shared/{core.3xeQpJ_K.d.cts → core.3L0y_SNW.d.mts} +2 -2
  14. package/dist/shared/{core.QP35c488.d.cts → core.Bhx0OGK8.d.mts} +1 -1
  15. package/dist/shared/{core.QP35c488.d.mts → core.Bhx0OGK8.d.ts} +1 -1
  16. package/dist/shared/{core.DsDq-blc.d.ts → core.BreLKHbT.d.mts} +1 -2
  17. package/dist/shared/{core.DQCc-Jxk.d.ts → core.BsAIrb_r.d.ts} +1 -1
  18. package/dist/shared/{core.GIZxdz4M.mjs → core.C92OYZca.mjs} +1 -1
  19. package/dist/shared/{core.CJaCUZQ9.d.mts → core.C9UbC1nX.d.ts} +1 -2
  20. package/dist/shared/{core.s6UB2oA0.d.ts → core.DBToPQ3n.d.ts} +2 -2
  21. package/dist/shared/{core.1pNr6Ryk.d.ts → core.DbfQeUKm.d.mts} +5 -4
  22. package/dist/shared/core.FFJhmauw.mjs +2078 -0
  23. package/dist/shared/{core.BYs5deiY.d.cts → core.RiWsY3jz.d.mts} +1 -1
  24. package/dist/shared/{core.uGbvOLGK.mjs → core.gWObeLn9.mjs} +28 -9
  25. package/dist/shared/{core.DKJ2y3NP.d.mts → core.k4jahJ8j.d.ts} +5 -4
  26. package/dist/types/index.d.mts +4 -4
  27. package/dist/types/index.d.ts +4 -4
  28. package/dist/types/index.mjs +1 -1
  29. package/dist/utils/index.d.mts +46 -4
  30. package/dist/utils/index.d.ts +46 -4
  31. package/dist/utils/index.mjs +2 -2
  32. package/package.json +3 -27
  33. package/src/compute-view/deployment-view/clean-connections.ts +1 -1
  34. package/src/compute-view/deployment-view/stages/stage-final.ts +1 -1
  35. package/src/compute-view/element-view/compute.ts +1 -1
  36. package/src/compute-view/element-view/memory/memory.ts +1 -1
  37. package/src/compute-view/memory/ops.ts +1 -1
  38. package/src/compute-view/relationships-view/layout.ts +1 -1
  39. package/src/compute-view/relationships-view/utils.ts +1 -1
  40. package/src/model/DeploymentElementModel.ts +4 -6
  41. package/src/model/DeploymentModel.ts +1 -1
  42. package/src/model/LikeC4Model.ts +22 -1
  43. package/src/model/view/LikeC4ViewModel.ts +5 -6
  44. package/src/types/deployments.ts +0 -1
  45. package/src/types/index.ts +1 -1
  46. package/src/types/theme.ts +1 -1
  47. package/src/utils/index.ts +7 -1
  48. package/src/utils/mnemonist.ts +7 -0
  49. package/src/utils/set.ts +5 -3
  50. package/dist/builder/index.cjs +0 -887
  51. package/dist/builder/index.d.cts +0 -509
  52. package/dist/compute-view/index.cjs +0 -86
  53. package/dist/compute-view/index.d.cts +0 -23
  54. package/dist/index.cjs +0 -3857
  55. package/dist/index.d.cts +0 -146
  56. package/dist/model/index.cjs +0 -40
  57. package/dist/model/index.d.cts +0 -259
  58. package/dist/shared/core.BHQYwEvc.d.mts +0 -12
  59. package/dist/shared/core.BS_nXBsP.d.cts +0 -858
  60. package/dist/shared/core.BYiA0A6H.cjs +0 -39
  61. package/dist/shared/core.CEJQrbXY.cjs +0 -441
  62. package/dist/shared/core.D0KD4FiT.d.mts +0 -127
  63. package/dist/shared/core.DEzbhxsA.cjs +0 -14874
  64. package/dist/shared/core.DUbKSpjd.cjs +0 -26
  65. package/dist/shared/core.DqmAHWZs.cjs +0 -7501
  66. package/dist/shared/core.OjOfEBRQ.d.cts +0 -731
  67. package/dist/shared/core.QP35c488.d.ts +0 -185
  68. package/dist/shared/core.f1tiPwpd.mjs +0 -14819
  69. package/dist/types/index.cjs +0 -110
  70. package/dist/types/index.d.cts +0 -72
  71. package/dist/utils/index.cjs +0 -99
  72. package/dist/utils/index.d.cts +0 -340
@@ -1,110 +0,0 @@
1
- 'use strict';
2
-
3
- const view = require('../shared/core.CEJQrbXY.cjs');
4
-
5
- const ThemeColors = [
6
- "amber",
7
- "blue",
8
- "gray",
9
- "slate",
10
- "green",
11
- "indigo",
12
- "muted",
13
- "primary",
14
- "red",
15
- "secondary",
16
- "sky"
17
- ];
18
- function isThemeColor(color) {
19
- return color in ThemeColors;
20
- }
21
-
22
- exports.AsFqn = view.AsFqn;
23
- exports.BorderStyles = view.BorderStyles;
24
- Object.defineProperty(exports, "ComputedNode", {
25
- enumerable: true,
26
- get: function () { return view.ComputedNode; }
27
- });
28
- Object.defineProperty(exports, "ComputedView", {
29
- enumerable: true,
30
- get: function () { return view.ComputedView; }
31
- });
32
- exports.DefaultArrowType = view.DefaultArrowType;
33
- exports.DefaultElementShape = view.DefaultElementShape;
34
- exports.DefaultLineStyle = view.DefaultLineStyle;
35
- exports.DefaultPaddingSize = view.DefaultPaddingSize;
36
- exports.DefaultRelationshipColor = view.DefaultRelationshipColor;
37
- exports.DefaultShapeSize = view.DefaultShapeSize;
38
- exports.DefaultTextSize = view.DefaultTextSize;
39
- exports.DefaultThemeColor = view.DefaultThemeColor;
40
- Object.defineProperty(exports, "DeploymentElement", {
41
- enumerable: true,
42
- get: function () { return view.DeploymentElement; }
43
- });
44
- Object.defineProperty(exports, "DiagramNode", {
45
- enumerable: true,
46
- get: function () { return view.DiagramNode; }
47
- });
48
- Object.defineProperty(exports, "ElementKind", {
49
- enumerable: true,
50
- get: function () { return view.ElementKind; }
51
- });
52
- exports.ElementShapes = view.ElementShapes;
53
- Object.defineProperty(exports, "ExpressionV2", {
54
- enumerable: true,
55
- get: function () { return view.ExpressionV2; }
56
- });
57
- Object.defineProperty(exports, "FqnExpr", {
58
- enumerable: true,
59
- get: function () { return view.FqnExpr; }
60
- });
61
- Object.defineProperty(exports, "FqnRef", {
62
- enumerable: true,
63
- get: function () { return view.FqnRef; }
64
- });
65
- Object.defineProperty(exports, "RelationExpr", {
66
- enumerable: true,
67
- get: function () { return view.RelationExpr; }
68
- });
69
- exports.extractStep = view.extractStep;
70
- exports.getBBoxCenter = view.getBBoxCenter;
71
- exports.getParallelStepsPrefix = view.getParallelStepsPrefix;
72
- exports.isAndOperator = view.isAndOperator;
73
- exports.isAutoLayoutDirection = view.isAutoLayoutDirection;
74
- exports.isCustomElement = view.isCustomElement;
75
- exports.isCustomRelationExpr = view.isCustomRelationExpr;
76
- exports.isDeploymentView = view.isDeploymentView;
77
- exports.isDynamicView = view.isDynamicView;
78
- exports.isDynamicViewParallelSteps = view.isDynamicViewParallelSteps;
79
- exports.isElement = view.isElement;
80
- exports.isElementKindExpr = view.isElementKindExpr;
81
- exports.isElementPredicateExpr = view.isElementPredicateExpr;
82
- exports.isElementRef = view.isElementRef;
83
- exports.isElementTagExpr = view.isElementTagExpr;
84
- exports.isElementView = view.isElementView;
85
- exports.isElementWhere = view.isElementWhere;
86
- exports.isExpandedElementExpr = view.isExpandedElementExpr;
87
- exports.isExtendsElementView = view.isExtendsElementView;
88
- exports.isInOut = view.isInOut;
89
- exports.isIncoming = view.isIncoming;
90
- exports.isKindEqual = view.isKindEqual;
91
- exports.isNotOperator = view.isNotOperator;
92
- exports.isOrOperator = view.isOrOperator;
93
- exports.isOutgoing = view.isOutgoing;
94
- exports.isRelation = view.isRelation;
95
- exports.isRelationExpression = view.isRelationExpression;
96
- exports.isRelationPredicateExpr = view.isRelationPredicateExpr;
97
- exports.isRelationWhere = view.isRelationWhere;
98
- exports.isScopedElementView = view.isScopedElementView;
99
- exports.isStepEdgeId = view.isStepEdgeId;
100
- exports.isTagEqual = view.isTagEqual;
101
- exports.isViewRuleAutoLayout = view.isViewRuleAutoLayout;
102
- exports.isViewRuleGlobalPredicateRef = view.isViewRuleGlobalPredicateRef;
103
- exports.isViewRuleGlobalStyle = view.isViewRuleGlobalStyle;
104
- exports.isViewRuleGroup = view.isViewRuleGroup;
105
- exports.isViewRulePredicate = view.isViewRulePredicate;
106
- exports.isViewRuleStyle = view.isViewRuleStyle;
107
- exports.isWildcard = view.isWildcard;
108
- exports.stepEdgeId = view.stepEdgeId;
109
- exports.whereOperatorAsPredicate = view.whereOperatorAsPredicate;
110
- exports.isThemeColor = isThemeColor;
@@ -1,72 +0,0 @@
1
- import { X as XYPoint, N as NonEmptyArray, P as Point, k as BorderStyle, o as ElementShape, M as ThemeColor, F as Fqn } from '../shared/core.QP35c488.cjs';
2
- export { A as AsFqn, B as BorderStyles, v as Color, w as ColorLiteral, C as CustomColor, D as DefaultElementShape, e as DefaultPaddingSize, f as DefaultShapeSize, g as DefaultTextSize, h as DefaultThemeColor, l as Element, i as ElementKind, m as ElementKindSpecification, n as ElementKindSpecificationStyle, j as ElementShapes, p as ElementStyle, y as ElementThemeColorValues, x as ElementThemeColors, E as ExclusiveUnion, H as HexColorLiteral, I as IconUrl, a as IteratorLike, K as KeysOf, L as LikeC4Theme, q as Link, c as NTuple, b as NonEmptyReadonlyArray, d as Predicate, z as RelationshipThemeColorValues, R as RelationshipThemeColors, S as ShapeSize, G as SpacingSize, r as Tag, s as TagSpec, J as TextSize, T as ThemeColorValues, t as TypedElement, u as isThemeColor } from '../shared/core.QP35c488.cjs';
3
- import { bk as ViewId, aW as BBox, bl as ViewManualLayout, aT as AutoLayoutDirection } from '../shared/core.BS_nXBsP.cjs';
4
- export { as as AbstractRelation, ag as AndOperator, a5 as AnyParsedLikeC4Model, aU as BasicElementView, aV as BasicView, aX as ComputedDeploymentView, aY as ComputedDynamicView, aZ as ComputedEdge, a_ as ComputedElementView, C as ComputedLikeC4Model, az as ComputedNode, a as ComputedView, a$ as CustomColorDefinitions, A as CustomElementExpr, B as CustomRelationExpr, ap as DefaultArrowType, aq as DefaultLineStyle, ar as DefaultRelationshipColor, b as DeployedInstance, D as DeploymentElement, c as DeploymentElementStyle, d as DeploymentNode, f as DeploymentNodeKind, g as DeploymentNodeKindSpecification, h as DeploymentRef, i as DeploymentRelation, b0 as DeploymentView, b1 as DeploymentViewRule, b2 as DeploymentViewRulePredicate, b3 as DeploymentViewRuleStyle, b4 as DiagramEdge, aA as DiagramNode, b5 as DiagramView, E as DirectRelationExpr, b6 as DynamicView, b7 as DynamicViewIncludeRule, b8 as DynamicViewParallelSteps, b9 as DynamicViewRule, ba as DynamicViewStep, bb as DynamicViewStepOrParallel, bc as EdgeId, F as ElementExpression, G as ElementKindExpr, bw as ElementNotation, H as ElementPredicateExpression, I as ElementRefExpr, J as ElementTagExpr, bd as ElementView, K as ElementWhereExpr, ah as EqualOperator, M as ExpandedElementExpr, N as Expression, X as ExpressionV2, be as ExtendsElementView, ai as Filterable, Y as FqnExpr, Z as FqnRef, a6 as GenericLikeC4Model, $ as GlobalDynamicPredicates, a0 as GlobalPredicateId, a1 as GlobalPredicates, a2 as GlobalStyleID, a3 as GlobalStyles, Q as InOutExpr, O as IncomingExpr, aj as KindEqual, a7 as LayoutedLikeC4Model, a8 as LikeC4ModelDump, L as LikeC4View, a4 as ModelGlobals, at as ModelRelation, bf as NodeId, R as NonWilcard, ak as NotOperator, al as OperatorPredicate, am as OrOperator, S as OutgoingExpr, a9 as ParsedLikeC4Model, P as PredicateSelector, _ as RelationExpr, T as RelationExpression, au as RelationId, U as RelationPredicateExpression, V as RelationWhereExpr, av as RelationshipArrowType, aw as RelationshipKind, ax as RelationshipKindSpecification, ay as RelationshipLineType, bg as ScopedElementView, bh as StepEdgeId, bi as StepEdgeIdLiteral, an as TagEqual, bj as ViewAutoLayout, bm as ViewRule, bn as ViewRuleAutoLayout, bo as ViewRuleGlobalPredicateRef, bp as ViewRuleGlobalStyle, bq as ViewRuleGroup, br as ViewRulePredicate, bs as ViewRuleStyle, bt as ViewRuleStyleOrGlobalRef, bu as ViewWithHash, bv as ViewWithNotation, ao as WhereOperator, W as WildcardExpr, aB as extractStep, aC as getBBoxCenter, aD as getParallelStepsPrefix, aa as isAndOperator, aE as isAutoLayoutDirection, j as isCustomElement, k as isCustomRelationExpr, aF as isDeploymentView, aG as isDynamicView, aH as isDynamicViewParallelSteps, l as isElement, m as isElementKindExpr, n as isElementPredicateExpr, o as isElementRef, p as isElementTagExpr, aI as isElementView, q as isElementWhere, r as isExpandedElementExpr, aJ as isExtendsElementView, t as isInOut, s as isIncoming, ab as isKindEqual, ac as isNotOperator, ad as isOrOperator, u as isOutgoing, v as isRelation, w as isRelationExpression, x as isRelationPredicateExpr, y as isRelationWhere, aK as isScopedElementView, aL as isStepEdgeId, ae as isTagEqual, aM as isViewRuleAutoLayout, aN as isViewRuleGlobalPredicateRef, aO as isViewRuleGlobalStyle, aP as isViewRuleGroup, aQ as isViewRulePredicate, aR as isViewRuleStyle, z as isWildcard, aS as stepEdgeId, af as whereOperatorAsPredicate } from '../shared/core.BS_nXBsP.cjs';
5
- import 'type-fest';
6
-
7
- /**
8
- * OverviewGraph is a graph representation of all views in a model
9
- */
10
- declare namespace OverviewGraph {
11
- type Node = {
12
- id: string;
13
- type: 'folder' | 'file';
14
- path: string;
15
- label: string;
16
- parentId: string | null;
17
- position: XYPoint;
18
- width: number;
19
- height: number;
20
- } | {
21
- id: string;
22
- type: 'view';
23
- viewId: ViewId;
24
- label: string;
25
- parentId: string | null;
26
- position: XYPoint;
27
- width: number;
28
- height: number;
29
- };
30
- /**
31
- * Edge represents a navigational link from one view to another
32
- */
33
- type Edge = {
34
- id: string;
35
- source: string;
36
- target: string;
37
- points: NonEmptyArray<Point>;
38
- };
39
- }
40
- interface OverviewGraph {
41
- nodes: OverviewGraph.Node[];
42
- edges: OverviewGraph.Edge[];
43
- bounds: BBox;
44
- }
45
-
46
- declare namespace ViewChange {
47
- interface ChangeElementStyle {
48
- op: 'change-element-style';
49
- style: {
50
- border?: BorderStyle;
51
- opacity?: number;
52
- shape?: ElementShape;
53
- color?: ThemeColor;
54
- };
55
- targets: NonEmptyArray<Fqn>;
56
- }
57
- interface SaveManualLayout {
58
- op: 'save-manual-layout';
59
- layout: ViewManualLayout;
60
- }
61
- interface ChangeAutoLayout {
62
- op: 'change-autolayout';
63
- layout: {
64
- direction: AutoLayoutDirection;
65
- nodeSep?: number | null;
66
- rankSep?: number | null;
67
- };
68
- }
69
- }
70
- type ViewChange = ViewChange.ChangeElementStyle | ViewChange.SaveManualLayout | ViewChange.ChangeAutoLayout;
71
-
72
- export { AutoLayoutDirection, BBox, BorderStyle, ElementShape, Fqn, NonEmptyArray, OverviewGraph, Point, ThemeColor, ViewChange, ViewId, ViewManualLayout, XYPoint };
@@ -1,99 +0,0 @@
1
- 'use strict';
2
-
3
- const object_hash = require('../shared/core.DEzbhxsA.cjs');
4
- const chunkWIMGWYZL = require('../shared/core.DUbKSpjd.cjs');
5
-
6
- function o(r,n){let e=Math.ceil(r),t=Math.floor(n);if(t<e)throw new RangeError(`randomInteger: The range [${r.toString()},${n.toString()}] contains no integer`);return Math.floor(Math.random()*(t-e+1)+e)}
7
-
8
- function ireduce(arg1, arg2, arg3) {
9
- const reducer = object_hash.n(arg3) ? arg2 : arg1;
10
- const initialValue = arg3 ?? arg2;
11
- chunkWIMGWYZL.invariant(object_hash.t$1(reducer));
12
- function _reduce(iter) {
13
- let acc = initialValue;
14
- for (const value of iter) {
15
- acc = reducer(acc, value);
16
- }
17
- return acc;
18
- }
19
- return object_hash.n(arg3) ? _reduce(arg1) : _reduce;
20
- }
21
-
22
- const DELAY = "LIKEC4_DELAY";
23
- function delay(...args) {
24
- let ms = 100;
25
- if (args.length === 2) {
26
- ms = o(args[0], args[1]);
27
- } else if (args.length === 1) {
28
- ms = args[0];
29
- }
30
- return new Promise((resolve) => {
31
- setTimeout(() => {
32
- resolve(DELAY);
33
- }, ms ?? 100);
34
- });
35
- }
36
-
37
- const compareRelations = (a, b) => {
38
- const parentA = object_hash.commonAncestor(a.source, a.target);
39
- const parentB = object_hash.commonAncestor(b.source, b.target);
40
- if (parentA && !parentB) {
41
- return 1;
42
- }
43
- if (!parentA && parentB) {
44
- return -1;
45
- }
46
- const compareParents = parentA && parentB ? object_hash.compareFqnHierarchically(parentA, parentB) : 0;
47
- if (compareParents !== 0) {
48
- return compareParents;
49
- }
50
- const compareSource = object_hash.compareFqnHierarchically(a.source, b.source);
51
- if (compareSource !== 0) {
52
- return compareSource;
53
- }
54
- return object_hash.compareFqnHierarchically(a.target, b.target);
55
- };
56
-
57
- exports.DefaultMap = object_hash.DefaultMap;
58
- exports.LinkedList = object_hash.linkedList;
59
- exports.Queue = object_hash.queue;
60
- exports.Stack = object_hash.Stack;
61
- exports.ancestorsFqn = object_hash.ancestorsFqn;
62
- exports.commonAncestor = object_hash.commonAncestor;
63
- exports.commonHead = object_hash.commonHead;
64
- exports.compareByFqnHierarchically = object_hash.compareByFqnHierarchically;
65
- exports.compareFqnHierarchically = object_hash.compareFqnHierarchically;
66
- exports.compareNatural = object_hash.compareNatural;
67
- exports.difference = object_hash.difference;
68
- exports.equalsSet = object_hash.equals;
69
- exports.getOrCreate = object_hash.getOrCreate;
70
- exports.hasAtLeast = object_hash.i;
71
- exports.hierarchyDistance = object_hash.hierarchyDistance;
72
- exports.hierarchyLevel = object_hash.hierarchyLevel;
73
- exports.ifilter = object_hash.ifilter;
74
- exports.ifind = object_hash.ifind;
75
- exports.iflat = object_hash.iflat;
76
- exports.imap = object_hash.imap;
77
- exports.intersection = object_hash.intersection;
78
- exports.isAncestor = object_hash.isAncestor;
79
- exports.isDescendantOf = object_hash.isDescendantOf;
80
- exports.isIterable = object_hash.isIterable;
81
- exports.isNonEmptyArray = object_hash.isNonEmptyArray;
82
- exports.isSameHierarchy = object_hash.isSameHierarchy;
83
- exports.isString = object_hash.isString;
84
- exports.isome = object_hash.isome;
85
- exports.iunique = object_hash.iunique;
86
- exports.nameFromFqn = object_hash.nameFromFqn;
87
- exports.objectHash = object_hash.objectHash;
88
- exports.parentFqn = object_hash.parentFqn;
89
- exports.sortByFqnHierarchically = object_hash.sortByFqnHierarchically;
90
- exports.sortNaturalByFqn = object_hash.sortNaturalByFqn;
91
- exports.sortParentsFirst = object_hash.sortParentsFirst;
92
- exports.stringHash = object_hash.stringHash;
93
- exports.symmetricDifference = object_hash.symmetricDifference;
94
- exports.toArray = object_hash.toArray;
95
- exports.toSet = object_hash.toSet;
96
- exports.union = object_hash.union;
97
- exports.compareRelations = compareRelations;
98
- exports.delay = delay;
99
- exports.ireduce = ireduce;
@@ -1,340 +0,0 @@
1
- export { I as IterableContainer, R as ReorderedArray, a as ancestorsFqn, c as commonAncestor, b as compareByFqnHierarchically, d as compareFqnHierarchically, h as hierarchyDistance, e as hierarchyLevel, i as isAncestor, f as isDescendantOf, g as isSameHierarchy, n as nameFromFqn, p as parentFqn, s as sortByFqnHierarchically, j as sortNaturalByFqn, k as sortParentsFirst } from '../shared/core.BYs5deiY.cjs';
2
- import { N as NonEmptyArray, a as IteratorLike } from '../shared/core.QP35c488.cjs';
3
- export { default as objectHash } from '/home/runner/work/likec4/likec4/node_modules/.pnpm/@types+object-hash@3.0.6/node_modules/@types/object-hash/index.d.ts';
4
- import { IsNumericLiteral } from 'type-fest';
5
-
6
- /**
7
- * Mnemonist DefaultMap Typings
8
- * =============================
9
- */
10
- declare class DefaultMap<K, V> implements Iterable<[K, V]> {
11
-
12
- // Members
13
- size: number;
14
-
15
- // Constructor
16
- constructor(factory: (key: K, index: number) => V);
17
-
18
- // Methods
19
- clear(): void;
20
- set(key: K, value: V): this;
21
- delete(key: K): boolean;
22
- has(key: K): boolean;
23
- get(key: K): V;
24
- peek(key: K): V | undefined;
25
- forEach(callback: (value: V, key: K, map: this) => void, scope?: any): void;
26
- keys(): IterableIterator<K>;
27
- values(): IterableIterator<V>;
28
- entries(): IterableIterator<[K, V]>;
29
- [Symbol.iterator](): IterableIterator<[K, V]>;
30
- inspect(): any;
31
-
32
- // Statics
33
- static autoIncrement(): number;
34
- }
35
-
36
- /**
37
- * Mnemonist LinkedList Typings
38
- * =============================
39
- */
40
- declare class LinkedList<T> implements Iterable<T> {
41
-
42
- // Members
43
- size: number;
44
-
45
- // Constructor
46
- constructor();
47
-
48
- // Methods
49
- clear(): void;
50
- first(): T | undefined;
51
- last(): T | undefined;
52
- peek(): T | undefined;
53
- push(value: T): number;
54
- shift(): T | undefined;
55
- unshift(value: T): number;
56
- forEach(callback: (value: T, index: number, list: this) => void, scope?: any): void;
57
- toArray(): Array<T>;
58
- values(): IterableIterator<T>;
59
- entries(): IterableIterator<[number, T]>;
60
- [Symbol.iterator](): IterableIterator<T>;
61
- toString(): string;
62
- toJSON(): Array<T>;
63
- inspect(): any;
64
-
65
- // Statics
66
- static from<I>(iterable: Iterable<I> | {[key: string]: I}): LinkedList<I>;
67
- }
68
-
69
- /**
70
- * Mnemonist Queue Typings
71
- * ========================
72
- */
73
- declare class Queue<T> implements Iterable<T> {
74
-
75
- // Members
76
- size: number;
77
-
78
- // Constructor
79
- constructor();
80
-
81
- // Methods
82
- clear(): void;
83
- enqueue(item: T): number;
84
- dequeue(): T | undefined;
85
- peek(): T | undefined;
86
- forEach(callback: (item: T, index: number, queue: this) => void, scope?: any): void;
87
- toArray(): Array<T>;
88
- values(): IterableIterator<T>;
89
- entries(): IterableIterator<[number, T]>;
90
- [Symbol.iterator](): IterableIterator<T>;
91
- toString(): string;
92
- toJSON(): Array<T>;
93
- inspect(): any;
94
-
95
- // Statics
96
- static from<I>(iterable: Iterable<I> | {[key: string]: I}): Queue<I>;
97
- static of<I>(...items: Array<I>): Queue<I>;
98
- }
99
-
100
- /**
101
- * Mnemonist Stack Typings
102
- * ========================
103
- */
104
- declare class Stack<T> implements Iterable<T> {
105
-
106
- // Members
107
- size: number;
108
-
109
- // Constructor
110
- constructor();
111
-
112
- // Methods
113
- clear(): void;
114
- push(item: T): number;
115
- pop(): T | undefined;
116
- peek(): T | undefined;
117
- forEach(callback: (item: T, index: number, stack: this) => void, scope?: any): void;
118
- toArray(): Array<T>;
119
- values(): IterableIterator<T>;
120
- entries(): IterableIterator<[number, T]>;
121
- [Symbol.iterator](): IterableIterator<T>;
122
- toString(): string;
123
- toJSON(): Array<T>;
124
- inspect(): any;
125
-
126
- // Statics
127
- static from<I>(iterable: Iterable<I> | {[key: string]: I}): Stack<I>;
128
- static of<I>(...items: Array<I>): Stack<I>;
129
- }
130
-
131
- /**
132
- * Common head of two arrays
133
- *
134
- * @param equals - Equality function, defaults to `Object.is`
135
- */
136
- declare function commonHead<T>(sources: ReadonlyArray<T>, targets: ReadonlyArray<T>, equals?: (a: T, b: T) => boolean): T[];
137
-
138
- declare function compareNatural(a: string | undefined, b: string | undefined): -1 | 0 | 1;
139
-
140
- declare function getOrCreate<K, V>(map: Map<K, V>, key: K, create: (key: K) => V): V;
141
-
142
- /**
143
- * This should only be used for defining generics which extend any kind of JS
144
- * array under the hood, this includes arrays *AND* tuples (of the form [x, y],
145
- * and of the form [x, ...y[]], etc...), and their readonly equivalent. This
146
- * allows us to be more inclusive to what functions can process.
147
- *
148
- * @example
149
- * function map<T extends IterableContainer>(items: T) { ... }
150
- *
151
- * We would've named this `ArrayLike`, but that's already used by typescript...
152
- * @see This was inspired by the type-definition of Promise.all (https://github.com/microsoft/TypeScript/blob/1df5717b120cddd325deab8b0f2b2c3eecaf2b01/src/lib/es2015.promise.d.ts#L21)
153
- */
154
- type IterableContainer<T = unknown> = ReadonlyArray<T> | readonly [];
155
-
156
- type ArraySetRequired<T extends IterableContainer, Min extends number, Iteration extends ReadonlyArray<unknown> = []> = number extends Min ? never : Iteration["length"] extends Min ? T : T extends readonly [] ? never : T extends [infer Head, ...infer Rest] ? [
157
- Head,
158
- ...ArraySetRequired<Rest, Min, [unknown, ...Iteration]>
159
- ] : T extends readonly [infer Head, ...infer Rest] ? readonly [
160
- Head,
161
- ...ArraySetRequired<Rest, Min, [unknown, ...Iteration]>
162
- ] : T extends Array<infer Item> ? [
163
- Item,
164
- ...ArraySetRequired<T, Min, [unknown, ...Iteration]>
165
- ] : T extends ReadonlyArray<infer Item> ? readonly [
166
- Item,
167
- ...ArraySetRequired<T, Min, [unknown, ...Iteration]>
168
- ] : never;
169
- /**
170
- * Checks if the given array has at least the defined number of elements. When
171
- * the minimum used is a literal (e.g. `3`) the output is refined accordingly so
172
- * that those indices are defined when accessing the array even when using
173
- * typescript's 'noUncheckedIndexAccess'.
174
- *
175
- * @param data - The input array.
176
- * @param minimum - The minimum number of elements the array must have.
177
- * @returns True if the array's length is *at least* `minimum`. When `minimum`
178
- * is a literal value, the output is narrowed to ensure the first items are
179
- * guaranteed.
180
- * @signature
181
- * R.hasAtLeast(data, minimum)
182
- * @example
183
- * R.hasAtLeast([], 4); // => false
184
- *
185
- * const data: number[] = [1,2,3,4];
186
- * R.hasAtLeast(data, 1); // => true
187
- * data[0]; // 1, with type `number`
188
- * @dataFirst
189
- * @category Array
190
- */
191
- declare function hasAtLeast<T extends IterableContainer, N extends number>(data: IterableContainer | T, minimum: IsNumericLiteral<N> extends true ? N : never): data is ArraySetRequired<T, N>;
192
- declare function hasAtLeast(data: IterableContainer, minimum: number): boolean;
193
- /**
194
- * Checks if the given array has at least the defined number of elements. When
195
- * the minimum used is a literal (e.g. `3`) the output is refined accordingly so
196
- * that those indices are defined when accessing the array even when using
197
- * typescript's 'noUncheckedIndexAccess'.
198
- *
199
- * @param minimum - The minimum number of elements the array must have.
200
- * @returns True if the array's length is *at least* `minimum`. When `minimum`
201
- * is a literal value, the output is narrowed to ensure the first items are
202
- * guaranteed.
203
- * @signature
204
- * R.hasAtLeast(minimum)(data)
205
- * @example
206
- * R.pipe([], R.hasAtLeast(4)); // => false
207
- *
208
- * const data = [[1,2], [3], [4,5]];
209
- * R.pipe(
210
- * data,
211
- * R.filter(R.hasAtLeast(2)),
212
- * R.map(([, second]) => second),
213
- * ); // => [2,5], with type `number[]`
214
- * @dataLast
215
- * @category Array
216
- */
217
- declare function hasAtLeast<N extends number>(minimum: IsNumericLiteral<N> extends true ? N : never): <T extends IterableContainer>(data: IterableContainer | T) => data is ArraySetRequired<T, N>;
218
- declare function hasAtLeast(minimum: number): (data: IterableContainer) => boolean;
219
-
220
- declare function isString(value: unknown): value is string;
221
- declare function isNonEmptyArray<A>(arr: ArrayLike<A> | undefined): arr is NonEmptyArray<A>;
222
-
223
- declare function isIterable<T, I extends Iterable<T>>(something: I | unknown): something is Iterable<T>;
224
-
225
- /**
226
- * Filters an iterable based on a predicate.
227
- * Composabel first version of `ifilter`.
228
- * @signature
229
- * ifilter(predicate)(data)
230
- */
231
- declare function ifilter<T, S extends T>(predicate: (v: T) => v is S): (iterable: Iterable<T>) => IteratorLike<S>;
232
- declare function ifilter<T>(predicate: (v: T) => boolean): (iterable: Iterable<T>) => IteratorLike<T>;
233
- /**
234
- * Filters an iterable based on a predicate.
235
- * Data first version of `ifilter`.
236
- * @signature
237
- * ifilter(data, predicate)
238
- * @example
239
- * ifilter(new Set([1, 2, 3]), x => x % 2 === 1) // => Iterable<[1, 3]>
240
- */
241
- declare function ifilter<T, S extends T>(iterable: Iterable<T>, predicate: (v: T) => v is S): IteratorLike<S>;
242
- declare function ifilter<T>(iterable: Iterable<T>, predicate: (v: T) => boolean): IteratorLike<T>;
243
-
244
- /**
245
- * Finds the first element in the iterable that satisfies the predicate.
246
- * Composable first version of `find`.
247
- * @signature
248
- * ifind(predicate)(data)
249
- */
250
- declare function ifind<T>(predicate: (item: T) => boolean): (iterable: Iterable<T>) => T | undefined;
251
- /**
252
- * Finds the first element in the iterable that satisfies the predicate.
253
- * Data first version of `find`.
254
- * @signature
255
- * ifind(data, predicate)
256
- */
257
- declare function ifind<T>(iterable: Iterable<T>, predicate: (item: T) => boolean): T | undefined;
258
-
259
- declare function iflat(): <T>(iterable: Iterable<IteratorLike<T>>) => IteratorLike<T>;
260
- declare function iflat<T>(iterable: Iterable<IteratorLike<T>>): IteratorLike<T>;
261
-
262
- type MapFunction<T, S> = (item: T) => S;
263
- /**
264
- * Maps an iterable using a mapper function.
265
- * Composable first version of `imap`.
266
- * @signature
267
- * imap(mapper)(data)
268
- */
269
- declare function imap<T, S>(mapper: MapFunction<T, S>): (iterable: Iterable<T>) => IteratorLike<S>;
270
- /**
271
- * Maps an iterable using a mapper function.
272
- * Data first version of `imap`.
273
- * @signature
274
- * imap(data, mapper)
275
- */
276
- declare function imap<T, S>(iterable: Iterable<T>, mapper: MapFunction<T, S>): IteratorLike<S>;
277
-
278
- declare function ireduce<T, R>(reducer: (acc: R, item: T) => R, initialValue: R): (iterable: Iterable<T>) => R;
279
- declare function ireduce<T, R>(iterable: Iterable<T>, reducer: (acc: R, item: T) => R, initialValue: R): R;
280
-
281
- /**
282
- * Checks if at least one element in the iterable satisfies the predicate.
283
- * Composable first version of `some`.
284
- * @signature
285
- * isome(predicate)(data)
286
- */
287
- declare function isome<T>(predicate: (item: T) => boolean): (iterable: Iterable<T>) => boolean;
288
- /**
289
- * Checks if at least one element in the iterable satisfies the predicate.
290
- * Data first version of `some`.
291
- * @signature
292
- * isome(data, predicate)
293
- */
294
- declare function isome<T>(iterable: Iterable<T>, predicate: (item: T) => boolean): boolean;
295
-
296
- declare function toArray(): <T>(iterable: Iterable<T> | ArrayLike<T>) => T[];
297
- declare function toArray<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
298
- declare function toSet(): <T>(iterable: Iterable<T>) => Set<T>;
299
- declare function toSet<T>(iterable: Iterable<T>): Set<T>;
300
-
301
- /**
302
- * Returns an iterable that yields only unique values.
303
- * It uses a Set to keep track of the values.
304
- */
305
- declare function iunique(): <T>(iterable: Iterable<T>) => IteratorLike<T>;
306
- declare function iunique<T>(iterable: Iterable<T>): IteratorLike<T>;
307
-
308
- declare function delay(): Promise<string>;
309
- declare function delay(ms: number): Promise<string>;
310
- declare function delay(randomFrom: number, randomTo: number): Promise<string>;
311
-
312
- /**
313
- * Compares two relations hierarchically.
314
- * From the most general (implicit) to the most specific.
315
- */
316
- declare const compareRelations: <T extends {
317
- source: string;
318
- target: string;
319
- }>(a: T, b: T) => number;
320
-
321
- /**
322
- * Returns new set as a union of given sets
323
- * Keeps order of elements
324
- */
325
- declare function union<T>(...sets: ReadonlySet<T>[]): Set<T>;
326
- /**
327
- * Returns new set as an intersection of all sets
328
- * Keeps order from the first set
329
- */
330
- declare function intersection<T>(first: ReadonlySet<T>, ...sets: NonEmptyArray<ReadonlySet<NoInfer<T>>>): Set<T>;
331
- declare function difference<T>(a: ReadonlySet<T>, b: ReadonlySet<NoInfer<T>>): Set<T>;
332
- declare function equals<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): boolean;
333
- declare function symmetricDifference<T>(a: ReadonlySet<T>, b: ReadonlySet<T>): Set<T>;
334
-
335
- /**
336
- * @see https://gist.github.com/victor-homyakov/bcb7d7911e4a388b1c810f8c3ce17bcf
337
- */
338
- declare function stringHash(str: string): string;
339
-
340
- export { DefaultMap, LinkedList, Queue, Stack, commonHead, compareNatural, compareRelations, delay, difference, equals as equalsSet, getOrCreate, hasAtLeast, ifilter, ifind, iflat, imap, intersection, ireduce, isIterable, isNonEmptyArray, isString, isome, iunique, stringHash, symmetricDifference, toArray, toSet, union };