@likec4/core 1.32.2 → 1.34.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/builder/index.d.mts +6 -4
- package/dist/builder/index.mjs +45 -13
- package/dist/compute-view/index.d.mts +6 -4
- package/dist/compute-view/index.mjs +33 -10
- package/dist/compute-view/relationships-view/index.d.mts +6 -4
- package/dist/compute-view/relationships-view/index.mjs +6 -3
- package/dist/index.d.mts +9 -138
- package/dist/index.mjs +31 -3712
- package/dist/model/connection/deployment/index.d.mts +10 -0
- package/dist/model/connection/deployment/index.mjs +18 -0
- package/dist/model/connection/index.d.mts +70 -0
- package/dist/model/connection/index.mjs +23 -0
- package/dist/model/connection/model/index.d.mts +10 -0
- package/dist/model/connection/model/index.mjs +11 -0
- package/dist/model/index.d.mts +14 -256
- package/dist/model/index.mjs +27 -5
- package/dist/shared/{core.cbA9VZ02.mjs → core.4SpVCM9m.mjs} +31 -1073
- package/dist/shared/{core.BuO4ncfY.d.mts → core.668kXpZq.d.mts} +42 -52
- package/dist/shared/core.8KM0D6va.mjs +33 -0
- package/dist/shared/core.B0oEIXqd.mjs +47 -0
- package/dist/shared/core.BH9nN-_I.mjs +22 -0
- package/dist/shared/core.BMCb0wJI.mjs +177 -0
- package/dist/shared/core.BTnf14gD.mjs +331 -0
- package/dist/shared/core.BgvIuGGU.mjs +3 -0
- package/dist/shared/core.BoyJPEen.mjs +21 -0
- package/dist/shared/{core.CUYDgv2-.mjs → core.Br7Fab9l.mjs} +12 -15
- package/dist/shared/{core.BrCnZFTn.mjs → core.Btl47GOn.mjs} +3 -3
- package/dist/shared/core.ByrmCl9I.mjs +5 -0
- package/dist/shared/core.C80Z37Eu.mjs +29 -0
- package/dist/shared/{core.Pf5I9o0e.d.mts → core.CF82MWyh.d.mts} +1 -1
- package/dist/shared/core.CJSFKrYf.d.mts +83 -0
- package/dist/shared/{core.rmvsy0n3.mjs → core.C_C-3c1S.mjs} +5 -198
- package/dist/shared/{core.DoK86JEe.mjs → core.CpwrZi3D.mjs} +2 -73
- package/dist/shared/{core.CpXlRyE5.mjs → core.CtKXPqN_.mjs} +5 -36
- package/dist/shared/core.CxGKeL-L.mjs +144 -0
- package/dist/shared/core.CzdwsPmY.d.mts +69 -0
- package/dist/shared/core.D3xEWj5B.d.mts +41 -0
- package/dist/shared/{core.Cy9smucx.mjs → core.D4npX2q8.mjs} +1 -3
- package/dist/shared/core.D56nCp7e.mjs +168 -0
- package/dist/shared/core.D5qVzkws.mjs +724 -0
- package/dist/shared/{core.CBxTtXMi.d.mts → core.DAj3LuFH.d.mts} +58 -57
- package/dist/shared/{core.Bk7wEZFG.mjs → core.DXRAwwDB.mjs} +3 -2
- package/dist/shared/core.DcS-0zys.mjs +10 -0
- package/dist/shared/core.Di7__sMg.d.mts +87 -0
- package/dist/shared/{core.DaAyklhe.d.mts → core.DrS4Bf4y.d.mts} +31 -22
- package/dist/shared/core.DsMrjY2q.mjs +34 -0
- package/dist/shared/core.DuSLYTG6.d.mts +57 -0
- package/dist/shared/{core.Bdz6fBF1.d.mts → core.IWLie-Ma.d.mts} +92 -81
- package/dist/shared/{core.CBpKAlhj.mjs → core.PqNe5WxQ.mjs} +96 -56
- package/dist/shared/core.XptQjhMA.mjs +1295 -0
- package/dist/shared/core.zLlww-07.mjs +3 -0
- package/dist/theme/index.d.mts +134 -0
- package/dist/theme/index.mjs +3709 -0
- package/dist/types/_aux.d.mts +4 -0
- package/dist/types/index.d.mts +9 -5
- package/dist/types/index.mjs +17 -146
- package/dist/utils/index.d.mts +15 -100
- package/dist/utils/index.mjs +25 -1315
- package/dist/utils/iterable/index.d.mts +100 -0
- package/dist/utils/iterable/index.mjs +24 -0
- package/package.json +29 -13
- package/src/builder/Builder.ts +13 -4
- package/src/builder/__snapshots__/Builder-style1.spec.ts.snap +0 -13
- package/src/builder/__snapshots__/Builder-style2.compute-model.json5 +2 -6
- package/src/builder/__snapshots__/Builder-style2.spec.ts.snap +0 -7
- package/src/compute-view/deployment-view/__test__/fixture.ts +15 -5
- package/src/compute-view/deployment-view/utils.ts +13 -13
- package/src/compute-view/dynamic-view/compute.ts +2 -1
- package/src/compute-view/element-view/__test__/__snapshots__/legacy.spec.ts.snap +2 -2
- package/src/compute-view/relationships-view/layout.ts +1 -1
- package/src/compute-view/utils/applyCustomElementProperties.ts +8 -0
- package/src/compute-view/utils/applyCustomRelationProperties.ts +2 -0
- package/src/compute-view/utils/buildComputedNodes.ts +4 -3
- package/src/compute-view/utils/merge-props-from-relationships.ts +6 -5
- package/src/compute-view/utils/view-hash.ts +24 -3
- package/src/model/DeploymentElementModel.ts +21 -17
- package/src/model/DeploymentModel.ts +1 -1
- package/src/model/ElementModel.ts +15 -5
- package/src/model/LikeC4Model.ts +1 -1
- package/src/model/RelationModel.ts +20 -17
- package/src/model/index.ts +2 -0
- package/src/model/types.ts +2 -1
- package/src/model/view/EdgeModel.ts +4 -3
- package/src/model/view/LikeC4ViewModel.ts +6 -1
- package/src/model/view/NodeModel.ts +5 -3
- package/src/theme/index.ts +12 -5
- package/src/types/RichText.ts +200 -0
- package/src/types/expression-model.ts +2 -2
- package/src/types/expression.ts +2 -2
- package/src/types/fqnRef.ts +2 -2
- package/src/types/global.ts +1 -1
- package/src/types/index.ts +4 -2
- package/src/types/model-data.ts +2 -2
- package/src/types/model-deployment.ts +6 -5
- package/src/types/model-dump.ts +1 -1
- package/src/types/model-logical.ts +5 -5
- package/src/types/model-spec.ts +2 -2
- package/src/types/operators.ts +2 -2
- package/src/types/scalar.ts +47 -2
- package/src/types/view-common.ts +3 -3
- package/src/types/view-computed.ts +4 -6
- package/src/types/view-layouted.ts +11 -2
- package/src/types/view-parsed.deployment.ts +1 -1
- package/src/types/view-parsed.dynamic.ts +2 -2
- package/src/types/view-parsed.element.ts +2 -2
- package/src/types/view.ts +2 -2
- package/src/utils/index.ts +4 -9
- package/src/utils/markdown/index.ts +2 -0
- package/src/utils/markdown/to-html.ts +32 -0
- package/src/utils/markdown/to-text.ts +14 -0
- package/dist/types/aux.d.mts +0 -3
- /package/dist/types/{aux.mjs → _aux.mjs} +0 -0
- /package/src/types/{aux.ts → _aux.ts} +0 -0
|
@@ -1,60 +1,48 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Tagged } from 'type-fest';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
3
|
+
type ProjectId<T = string> = Tagged<T, 'ProjectID'>;
|
|
4
|
+
type MarkdownOrString = {
|
|
5
|
+
txt: string;
|
|
6
|
+
md?: never;
|
|
7
|
+
} | {
|
|
8
|
+
md: string;
|
|
9
|
+
txt?: never;
|
|
10
|
+
};
|
|
11
11
|
/**
|
|
12
|
+
* Converts a MarkdownOrString object or a plain string into a simple string representation.
|
|
13
|
+
* This utility function handles different types of text content and normalizes them to a string format.
|
|
14
|
+
*
|
|
15
|
+
* @param value - The content to be flattened.
|
|
16
|
+
* Can be one of:
|
|
17
|
+
* - A plain string
|
|
18
|
+
* - A MarkdownOrString object with either txt or md property
|
|
19
|
+
* - undefined or null
|
|
20
|
+
*
|
|
21
|
+
* @returns The string content contained within the input value.
|
|
22
|
+
* - Returns the input directly if it's already a string
|
|
23
|
+
* - Returns the txt property if available in a MarkdownOrString object
|
|
24
|
+
* - Falls back to the md property if txt is not available
|
|
25
|
+
* - Returns null if:
|
|
26
|
+
* - The input is null or undefined
|
|
27
|
+
* - The resulting string value is empty, whitespace, or null
|
|
28
|
+
*
|
|
12
29
|
* @example
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* }
|
|
17
|
-
* type Variant2 = {
|
|
18
|
-
* b: number
|
|
19
|
-
* }
|
|
30
|
+
* // String input
|
|
31
|
+
* flattenMarkdownOrString("Hello world") // Returns: "Hello world"
|
|
32
|
+
* flattenMarkdownOrString(" ") // Returns: null
|
|
20
33
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* }>
|
|
34
|
+
* // MarkdownOrString with txt property
|
|
35
|
+
* flattenMarkdownOrString({ txt: "Plain text" }) // Returns: "Plain text"
|
|
36
|
+
* flattenMarkdownOrString({ txt: " " }) // Returns: null
|
|
25
37
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* a: 'one',
|
|
29
|
-
* b: 1
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
type ExclusiveUnion<Expressions, All = AllNever<Expressions>> = Expressions extends object ? {
|
|
34
|
-
[Name in keyof Expressions]: Simplify<Omit<All, keyof Expressions[Name]> & Expressions[Name]>;
|
|
35
|
-
}[keyof Expressions] : never;
|
|
36
|
-
/**
|
|
37
|
-
* Copy from https://github.com/remeda/remeda/blob/main/src/internal/types/NTuple.ts
|
|
38
|
-
* An array with *exactly* N elements in it.
|
|
38
|
+
* // MarkdownOrString with md property
|
|
39
|
+
* flattenMarkdownOrString({ md: "**Bold markdown**" }) // Returns: "**Bold markdown**"
|
|
39
40
|
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* recursion. None of these have protections because this is an internal type!
|
|
41
|
+
* // Null input
|
|
42
|
+
* flattenMarkdownOrString(null) // Returns: null
|
|
43
43
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
type Predicate<T> = (x: T) => boolean;
|
|
47
|
-
interface Link {
|
|
48
|
-
title?: string;
|
|
49
|
-
url: string;
|
|
50
|
-
relative?: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Coalesce `V` to a string if it is `any`
|
|
54
|
-
*/
|
|
55
|
-
type Coalesce<V extends string, OrIfAny = string> = IsAny<V> extends true ? OrIfAny : V;
|
|
56
|
-
|
|
57
|
-
type ProjectId<T = string> = Tagged<T, 'ProjectID'>;
|
|
44
|
+
declare function flattenMarkdownOrString(value: MarkdownOrString | string): string;
|
|
45
|
+
declare function flattenMarkdownOrString(value: MarkdownOrString | string | undefined | null): string | null;
|
|
58
46
|
type BuiltInIcon = 'none' | `${'aws' | 'azure' | 'gcp' | 'tech'}:${string}`;
|
|
59
47
|
type Icon = Tagged<string, 'Icon'> | BuiltInIcon;
|
|
60
48
|
type IconUrl = Icon;
|
|
@@ -123,6 +111,7 @@ declare const scalar_GlobalFqn: typeof GlobalFqn;
|
|
|
123
111
|
type scalar_GroupElementKind = GroupElementKind;
|
|
124
112
|
type scalar_Icon = Icon;
|
|
125
113
|
type scalar_IconUrl = IconUrl;
|
|
114
|
+
type scalar_MarkdownOrString = MarkdownOrString;
|
|
126
115
|
declare const scalar_NodeId: typeof NodeId;
|
|
127
116
|
type scalar_ProjectId<T = string> = ProjectId<T>;
|
|
128
117
|
declare const scalar_RelationId: typeof RelationId;
|
|
@@ -134,13 +123,14 @@ declare const scalar_StepEdgeKind: typeof StepEdgeKind;
|
|
|
134
123
|
type scalar_Tag<T = string> = Tag<T>;
|
|
135
124
|
declare const scalar_ViewId: typeof ViewId;
|
|
136
125
|
declare const scalar_extractStep: typeof extractStep;
|
|
126
|
+
declare const scalar_flattenMarkdownOrString: typeof flattenMarkdownOrString;
|
|
137
127
|
declare const scalar_isGlobalFqn: typeof isGlobalFqn;
|
|
138
128
|
declare const scalar_isGroupElementKind: typeof isGroupElementKind;
|
|
139
129
|
declare const scalar_isStepEdgeId: typeof isStepEdgeId;
|
|
140
130
|
declare const scalar_splitGlobalFqn: typeof splitGlobalFqn;
|
|
141
131
|
declare const scalar_stepEdgeId: typeof stepEdgeId;
|
|
142
132
|
declare namespace scalar {
|
|
143
|
-
export { type scalar_AnyFqn as AnyFqn, type scalar_BuiltInIcon as BuiltInIcon, scalar_DeploymentFqn as DeploymentFqn, type scalar_DeploymentKind as DeploymentKind, scalar_EdgeId as EdgeId, type scalar_ElementKind as ElementKind, scalar_Fqn as Fqn, scalar_GlobalFqn as GlobalFqn, type scalar_GroupElementKind as GroupElementKind, type scalar_Icon as Icon, type scalar_IconUrl as IconUrl, scalar_NodeId as NodeId, type scalar_ProjectId as ProjectId, scalar_RelationId as RelationId, type scalar_RelationKind as RelationKind, type scalar_RelationshipKind as RelationshipKind, type scalar_StepEdgeId as StepEdgeId, type scalar_StepEdgeIdLiteral as StepEdgeIdLiteral, scalar_StepEdgeKind as StepEdgeKind, type scalar_Tag as Tag, scalar_ViewId as ViewId, scalar_extractStep as extractStep, scalar_isGlobalFqn as isGlobalFqn, scalar_isGroupElementKind as isGroupElementKind, scalar_isStepEdgeId as isStepEdgeId, scalar_splitGlobalFqn as splitGlobalFqn, scalar_stepEdgeId as stepEdgeId };
|
|
133
|
+
export { type scalar_AnyFqn as AnyFqn, type scalar_BuiltInIcon as BuiltInIcon, scalar_DeploymentFqn as DeploymentFqn, type scalar_DeploymentKind as DeploymentKind, scalar_EdgeId as EdgeId, type scalar_ElementKind as ElementKind, scalar_Fqn as Fqn, scalar_GlobalFqn as GlobalFqn, type scalar_GroupElementKind as GroupElementKind, type scalar_Icon as Icon, type scalar_IconUrl as IconUrl, type scalar_MarkdownOrString as MarkdownOrString, scalar_NodeId as NodeId, type scalar_ProjectId as ProjectId, scalar_RelationId as RelationId, type scalar_RelationKind as RelationKind, type scalar_RelationshipKind as RelationshipKind, type scalar_StepEdgeId as StepEdgeId, type scalar_StepEdgeIdLiteral as StepEdgeIdLiteral, scalar_StepEdgeKind as StepEdgeKind, type scalar_Tag as Tag, scalar_ViewId as ViewId, scalar_extractStep as extractStep, scalar_flattenMarkdownOrString as flattenMarkdownOrString, scalar_isGlobalFqn as isGlobalFqn, scalar_isGroupElementKind as isGroupElementKind, scalar_isStepEdgeId as isStepEdgeId, scalar_splitGlobalFqn as splitGlobalFqn, scalar_stepEdgeId as stepEdgeId };
|
|
144
134
|
}
|
|
145
135
|
|
|
146
|
-
export { type AnyFqn as A, type BuiltInIcon as B,
|
|
136
|
+
export { type AnyFqn as A, type BuiltInIcon as B, DeploymentFqn as D, type ElementKind as E, Fqn as F, GroupElementKind as G, type Icon as I, type MarkdownOrString as M, NodeId as N, type ProjectId as P, type RelationKind as R, type StepEdgeIdLiteral as S, type Tag as T, ViewId as V, type IconUrl as a, type DeploymentKind as b, type RelationshipKind as c, RelationId as d, GlobalFqn as e, flattenMarkdownOrString as f, isGlobalFqn as g, splitGlobalFqn as h, isGroupElementKind as i, EdgeId as j, type StepEdgeId as k, stepEdgeId as l, StepEdgeKind as m, isStepEdgeId as n, extractStep as o, scalar as s };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function n(e){return e!==void 0}
|
|
2
|
+
|
|
3
|
+
function l(n){return n!=null}
|
|
4
|
+
|
|
5
|
+
function isIterable(something) {
|
|
6
|
+
return l(something) && typeof something === "object" && Symbol.iterator in something;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function iflat(iterable) {
|
|
10
|
+
return iterable ? _iflat(iterable) : _iflat;
|
|
11
|
+
}
|
|
12
|
+
function* _iflat(iterable) {
|
|
13
|
+
for (const inner of iterable) {
|
|
14
|
+
yield* inner;
|
|
15
|
+
}
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function iunique(iterable) {
|
|
20
|
+
return iterable ? _iunique(iterable) : _iunique;
|
|
21
|
+
}
|
|
22
|
+
function* _iunique(iterable) {
|
|
23
|
+
const seen = /* @__PURE__ */ new Set();
|
|
24
|
+
for (const item of iterable) {
|
|
25
|
+
if (!seen.has(item)) {
|
|
26
|
+
seen.add(item);
|
|
27
|
+
yield item;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { isIterable as a, iunique as b, iflat as i, l, n };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import rehypeRaw from 'rehype-raw';
|
|
2
|
+
import rehypeSanitize from 'rehype-sanitize';
|
|
3
|
+
import rehypeStringify from 'rehype-stringify';
|
|
4
|
+
import remarkGfm from 'remark-gfm';
|
|
5
|
+
import remarkParse from 'remark-parse';
|
|
6
|
+
import remarkRehype from 'remark-rehype';
|
|
7
|
+
import { unified } from 'unified';
|
|
8
|
+
import { fromMarkdown } from 'mdast-util-from-markdown';
|
|
9
|
+
import { toString } from 'mdast-util-to-string';
|
|
10
|
+
|
|
11
|
+
function memoizeProp(obj, tag, fn) {
|
|
12
|
+
const tagSymbol = typeof tag === "symbol" ? tag : Symbol.for(tag);
|
|
13
|
+
if (!obj.hasOwnProperty(tagSymbol)) {
|
|
14
|
+
Object.defineProperty(obj, tagSymbol, {
|
|
15
|
+
enumerable: false,
|
|
16
|
+
writable: false,
|
|
17
|
+
value: fn()
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return obj[tagSymbol];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function remark() {
|
|
24
|
+
return unified().use(remarkParse).use(remarkGfm).use(remarkRehype, {
|
|
25
|
+
// Tight paragraphs prevent extra newlines
|
|
26
|
+
allowDangerousHtml: true,
|
|
27
|
+
clobberPrefix: "",
|
|
28
|
+
tableCellPadding: false,
|
|
29
|
+
tight: true
|
|
30
|
+
}).use(rehypeRaw).use(rehypeSanitize).use(rehypeStringify, {
|
|
31
|
+
// Prevent extra closing newlines
|
|
32
|
+
closeSelfClosing: true,
|
|
33
|
+
tightSelfClosing: true
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function markdownToHtml(markdown) {
|
|
37
|
+
return String(remark().processSync(markdown.trim())).trim();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function markdownToText(markdown) {
|
|
41
|
+
return toString(fromMarkdown(markdown), {
|
|
42
|
+
includeHtml: false,
|
|
43
|
+
includeImageAlt: false
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { markdownToHtml as a, markdownToText as b, memoizeProp as m };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { i as invariant } from './core.D4npX2q8.mjs';
|
|
2
|
+
|
|
3
|
+
function t(n){return typeof n=="function"}
|
|
4
|
+
|
|
5
|
+
function ifilter(arg1, arg2) {
|
|
6
|
+
const pred = arg2 ?? arg1;
|
|
7
|
+
invariant(t(pred));
|
|
8
|
+
function* _filter(iter) {
|
|
9
|
+
for (const value of iter) {
|
|
10
|
+
if (pred(value)) {
|
|
11
|
+
yield value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!arg2) {
|
|
17
|
+
return _filter;
|
|
18
|
+
}
|
|
19
|
+
return _filter(arg1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { ifilter as i, t };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { r as getDefaultExportFromCjs } from './core.C_C-3c1S.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mnemonist DefaultMap
|
|
5
|
+
* =====================
|
|
6
|
+
*
|
|
7
|
+
* JavaScript implementation of a default map that will return a constructed
|
|
8
|
+
* value any time one tries to access an inexisting key. It's quite similar
|
|
9
|
+
* to python's defaultdict.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var defaultMap;
|
|
13
|
+
var hasRequiredDefaultMap;
|
|
14
|
+
|
|
15
|
+
function requireDefaultMap () {
|
|
16
|
+
if (hasRequiredDefaultMap) return defaultMap;
|
|
17
|
+
hasRequiredDefaultMap = 1;
|
|
18
|
+
/**
|
|
19
|
+
* DefaultMap.
|
|
20
|
+
*
|
|
21
|
+
* @constructor
|
|
22
|
+
*/
|
|
23
|
+
function DefaultMap(factory) {
|
|
24
|
+
if (typeof factory !== 'function')
|
|
25
|
+
throw new Error('mnemonist/DefaultMap.constructor: expecting a function.');
|
|
26
|
+
|
|
27
|
+
this.items = new Map();
|
|
28
|
+
this.factory = factory;
|
|
29
|
+
this.size = 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Method used to clear the structure.
|
|
34
|
+
*
|
|
35
|
+
* @return {undefined}
|
|
36
|
+
*/
|
|
37
|
+
DefaultMap.prototype.clear = function() {
|
|
38
|
+
|
|
39
|
+
// Properties
|
|
40
|
+
this.items.clear();
|
|
41
|
+
this.size = 0;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Method used to get the value set for given key. If the key does not exist,
|
|
46
|
+
* the value will be created using the provided factory.
|
|
47
|
+
*
|
|
48
|
+
* @param {any} key - Target key.
|
|
49
|
+
* @return {any}
|
|
50
|
+
*/
|
|
51
|
+
DefaultMap.prototype.get = function(key) {
|
|
52
|
+
var value = this.items.get(key);
|
|
53
|
+
|
|
54
|
+
if (typeof value === 'undefined') {
|
|
55
|
+
value = this.factory(key, this.size);
|
|
56
|
+
this.items.set(key, value);
|
|
57
|
+
this.size++;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return value;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Method used to get the value set for given key. If the key does not exist,
|
|
65
|
+
* a value won't be created.
|
|
66
|
+
*
|
|
67
|
+
* @param {any} key - Target key.
|
|
68
|
+
* @return {any}
|
|
69
|
+
*/
|
|
70
|
+
DefaultMap.prototype.peek = function(key) {
|
|
71
|
+
return this.items.get(key);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Method used to set a value for given key.
|
|
76
|
+
*
|
|
77
|
+
* @param {any} key - Target key.
|
|
78
|
+
* @param {any} value - Value.
|
|
79
|
+
* @return {DefaultMap}
|
|
80
|
+
*/
|
|
81
|
+
DefaultMap.prototype.set = function(key, value) {
|
|
82
|
+
this.items.set(key, value);
|
|
83
|
+
this.size = this.items.size;
|
|
84
|
+
|
|
85
|
+
return this;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Method used to test the existence of a key in the map.
|
|
90
|
+
*
|
|
91
|
+
* @param {any} key - Target key.
|
|
92
|
+
* @return {boolean}
|
|
93
|
+
*/
|
|
94
|
+
DefaultMap.prototype.has = function(key) {
|
|
95
|
+
return this.items.has(key);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Method used to delete target key.
|
|
100
|
+
*
|
|
101
|
+
* @param {any} key - Target key.
|
|
102
|
+
* @return {boolean}
|
|
103
|
+
*/
|
|
104
|
+
DefaultMap.prototype.delete = function(key) {
|
|
105
|
+
var deleted = this.items.delete(key);
|
|
106
|
+
|
|
107
|
+
this.size = this.items.size;
|
|
108
|
+
|
|
109
|
+
return deleted;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Method used to iterate over each of the key/value pairs.
|
|
114
|
+
*
|
|
115
|
+
* @param {function} callback - Function to call for each item.
|
|
116
|
+
* @param {object} scope - Optional scope.
|
|
117
|
+
* @return {undefined}
|
|
118
|
+
*/
|
|
119
|
+
DefaultMap.prototype.forEach = function(callback, scope) {
|
|
120
|
+
scope = arguments.length > 1 ? scope : this;
|
|
121
|
+
|
|
122
|
+
this.items.forEach(callback, scope);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Iterators.
|
|
127
|
+
*/
|
|
128
|
+
DefaultMap.prototype.entries = function() {
|
|
129
|
+
return this.items.entries();
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
DefaultMap.prototype.keys = function() {
|
|
133
|
+
return this.items.keys();
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
DefaultMap.prototype.values = function() {
|
|
137
|
+
return this.items.values();
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Attaching the #.entries method to Symbol.iterator if possible.
|
|
142
|
+
*/
|
|
143
|
+
if (typeof Symbol !== 'undefined')
|
|
144
|
+
DefaultMap.prototype[Symbol.iterator] = DefaultMap.prototype.entries;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Convenience known methods.
|
|
148
|
+
*/
|
|
149
|
+
DefaultMap.prototype.inspect = function() {
|
|
150
|
+
return this.items;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
if (typeof Symbol !== 'undefined')
|
|
154
|
+
DefaultMap.prototype[Symbol.for('nodejs.util.inspect.custom')] = DefaultMap.prototype.inspect;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Typical factories.
|
|
158
|
+
*/
|
|
159
|
+
DefaultMap.autoIncrement = function() {
|
|
160
|
+
var i = 0;
|
|
161
|
+
|
|
162
|
+
return function() {
|
|
163
|
+
return i++;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Exporting.
|
|
169
|
+
*/
|
|
170
|
+
defaultMap = DefaultMap;
|
|
171
|
+
return defaultMap;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
var defaultMapExports = /*@__PURE__*/ requireDefaultMap();
|
|
175
|
+
const DefaultMap = /*@__PURE__*/getDefaultExportFromCjs(defaultMapExports);
|
|
176
|
+
|
|
177
|
+
export { DefaultMap as D };
|