@storybook/cli 10.0.0-beta.3 → 10.0.0-beta.5
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/_node-chunks/{block-dependencies-versions-ECFHKRTC.js → block-dependencies-versions-NVV2Y4QD.js} +11 -12
- package/dist/_node-chunks/{block-experimental-addon-test-H3PGBGKX.js → block-experimental-addon-test-WT5WRY4O.js} +9 -9
- package/dist/_node-chunks/{block-major-version-3ZY3MRTH.js → block-major-version-WMZ2DR67.js} +9 -9
- package/dist/_node-chunks/{block-node-version-V43RSSN2.js → block-node-version-CVG4O5KM.js} +9 -9
- package/dist/_node-chunks/{block-webpack5-frameworks-B72WCNZS.js → block-webpack5-frameworks-XHQHPWL5.js} +11 -12
- package/dist/_node-chunks/{chunk-Q34DTK4O.js → chunk-5S2DUO4Y.js} +7 -7
- package/dist/_node-chunks/{chunk-42LUW6OW.js → chunk-G7PQMQCF.js} +6 -6
- package/dist/_node-chunks/{chunk-MX3I2NJD.js → chunk-JT5AXC2V.js} +7 -7
- package/dist/_node-chunks/{chunk-QXLXOJ2F.js → chunk-JZ5J2OQH.js} +7 -7
- package/dist/_node-chunks/{chunk-J26XVIEI.js → chunk-YEGSIZDZ.js} +84 -227
- package/dist/_node-chunks/{globby-G7I6RDHZ.js → globby-KA6WL2LK.js} +8 -8
- package/dist/_node-chunks/{p-limit-EQE3ITLA.js → p-limit-QM3TBYML.js} +76 -10
- package/dist/_node-chunks/{run-7HHVXZYG.js → run-F43VY34Q.js} +41 -25
- package/dist/bin/index.js +7 -7
- package/package.json +8 -8
- package/dist/_node-chunks/chunk-QHB4E557.js +0 -87
|
@@ -1,20 +1,86 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_48ba0y5fih6 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_48ba0y5fih6 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_48ba0y5fih6 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_48ba0y5fih6.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_48ba0y5fih6.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_48ba0y5fih6.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
|
-
import {
|
|
13
|
-
Queue
|
|
14
|
-
} from "./chunk-QHB4E557.js";
|
|
15
12
|
import {
|
|
16
13
|
__name
|
|
17
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-G7PQMQCF.js";
|
|
15
|
+
|
|
16
|
+
// ../../node_modules/yocto-queue/index.js
|
|
17
|
+
var Node = class {
|
|
18
|
+
static {
|
|
19
|
+
__name(this, "Node");
|
|
20
|
+
}
|
|
21
|
+
value;
|
|
22
|
+
next;
|
|
23
|
+
constructor(value) {
|
|
24
|
+
this.value = value;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
var Queue = class {
|
|
28
|
+
static {
|
|
29
|
+
__name(this, "Queue");
|
|
30
|
+
}
|
|
31
|
+
#head;
|
|
32
|
+
#tail;
|
|
33
|
+
#size;
|
|
34
|
+
constructor() {
|
|
35
|
+
this.clear();
|
|
36
|
+
}
|
|
37
|
+
enqueue(value) {
|
|
38
|
+
const node = new Node(value);
|
|
39
|
+
if (this.#head) {
|
|
40
|
+
this.#tail.next = node;
|
|
41
|
+
this.#tail = node;
|
|
42
|
+
} else {
|
|
43
|
+
this.#head = node;
|
|
44
|
+
this.#tail = node;
|
|
45
|
+
}
|
|
46
|
+
this.#size++;
|
|
47
|
+
}
|
|
48
|
+
dequeue() {
|
|
49
|
+
const current = this.#head;
|
|
50
|
+
if (!current) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.#head = this.#head.next;
|
|
54
|
+
this.#size--;
|
|
55
|
+
return current.value;
|
|
56
|
+
}
|
|
57
|
+
peek() {
|
|
58
|
+
if (!this.#head) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
return this.#head.value;
|
|
62
|
+
}
|
|
63
|
+
clear() {
|
|
64
|
+
this.#head = void 0;
|
|
65
|
+
this.#tail = void 0;
|
|
66
|
+
this.#size = 0;
|
|
67
|
+
}
|
|
68
|
+
get size() {
|
|
69
|
+
return this.#size;
|
|
70
|
+
}
|
|
71
|
+
*[Symbol.iterator]() {
|
|
72
|
+
let current = this.#head;
|
|
73
|
+
while (current) {
|
|
74
|
+
yield current.value;
|
|
75
|
+
current = current.next;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
*drain() {
|
|
79
|
+
while (this.#head) {
|
|
80
|
+
yield this.dequeue();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
18
84
|
|
|
19
85
|
// ../../node_modules/p-limit/index.js
|
|
20
86
|
function pLimit(concurrency) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_48ba0y5fih6 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_48ba0y5fih6 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_48ba0y5fih6 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_48ba0y5fih6.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_48ba0y5fih6.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_48ba0y5fih6.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -19,20 +19,19 @@ import {
|
|
|
19
19
|
shortenPath,
|
|
20
20
|
updateMainConfig,
|
|
21
21
|
upgradeStorybookDependencies
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-YEGSIZDZ.js";
|
|
23
23
|
import {
|
|
24
24
|
slash
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-5S2DUO4Y.js";
|
|
26
26
|
import {
|
|
27
27
|
require_semver
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import "./chunk-QHB4E557.js";
|
|
28
|
+
} from "./chunk-JT5AXC2V.js";
|
|
30
29
|
import {
|
|
31
30
|
__commonJS,
|
|
32
31
|
__name,
|
|
33
32
|
__require,
|
|
34
33
|
__toESM
|
|
35
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-G7PQMQCF.js";
|
|
36
35
|
|
|
37
36
|
// ../../node_modules/envinfo/dist/envinfo.js
|
|
38
37
|
var require_envinfo = __commonJS({
|
|
@@ -4848,10 +4847,11 @@ import { program } from "commander";
|
|
|
4848
4847
|
// ../../node_modules/leven/index.js
|
|
4849
4848
|
var array = [];
|
|
4850
4849
|
var characterCodeCache = [];
|
|
4851
|
-
function leven(first, second) {
|
|
4850
|
+
function leven(first, second, options) {
|
|
4852
4851
|
if (first === second) {
|
|
4853
4852
|
return 0;
|
|
4854
4853
|
}
|
|
4854
|
+
const maxDistance = options?.maxDistance;
|
|
4855
4855
|
const swap = first;
|
|
4856
4856
|
if (first.length > second.length) {
|
|
4857
4857
|
first = second;
|
|
@@ -4869,8 +4869,11 @@ function leven(first, second) {
|
|
|
4869
4869
|
}
|
|
4870
4870
|
firstLength -= start;
|
|
4871
4871
|
secondLength -= start;
|
|
4872
|
+
if (maxDistance !== void 0 && secondLength - firstLength > maxDistance) {
|
|
4873
|
+
return maxDistance;
|
|
4874
|
+
}
|
|
4872
4875
|
if (firstLength === 0) {
|
|
4873
|
-
return secondLength;
|
|
4876
|
+
return maxDistance !== void 0 && secondLength > maxDistance ? maxDistance : secondLength;
|
|
4874
4877
|
}
|
|
4875
4878
|
let bCharacterCode;
|
|
4876
4879
|
let result;
|
|
@@ -4891,8 +4894,21 @@ function leven(first, second) {
|
|
|
4891
4894
|
temporary = array[index];
|
|
4892
4895
|
result = array[index] = temporary > result ? temporary2 > result ? result + 1 : temporary2 : temporary2 > temporary ? temporary + 1 : temporary2;
|
|
4893
4896
|
}
|
|
4897
|
+
if (maxDistance !== void 0) {
|
|
4898
|
+
let rowMinimum = result;
|
|
4899
|
+
for (index = 0; index < firstLength; index++) {
|
|
4900
|
+
if (array[index] < rowMinimum) {
|
|
4901
|
+
rowMinimum = array[index];
|
|
4902
|
+
}
|
|
4903
|
+
}
|
|
4904
|
+
if (rowMinimum > maxDistance) {
|
|
4905
|
+
return maxDistance;
|
|
4906
|
+
}
|
|
4907
|
+
}
|
|
4894
4908
|
}
|
|
4895
|
-
|
|
4909
|
+
array.length = firstLength;
|
|
4910
|
+
characterCodeCache.length = firstLength;
|
|
4911
|
+
return maxDistance !== void 0 && result > maxDistance ? maxDistance : result;
|
|
4896
4912
|
}
|
|
4897
4913
|
__name(leven, "leven");
|
|
4898
4914
|
|
|
@@ -4900,7 +4916,7 @@ __name(leven, "leven");
|
|
|
4900
4916
|
var import_picocolors17 = __toESM(require_picocolors(), 1);
|
|
4901
4917
|
|
|
4902
4918
|
// package.json
|
|
4903
|
-
var version = "10.0.0-beta.
|
|
4919
|
+
var version = "10.0.0-beta.5";
|
|
4904
4920
|
|
|
4905
4921
|
// src/add.ts
|
|
4906
4922
|
var import_semver = __toESM(require_semver(), 1);
|
|
@@ -6065,7 +6081,7 @@ async function runCodemod(globPattern = "**/*.stories.*", transform, { dryRun =
|
|
|
6065
6081
|
let modifiedCount = 0;
|
|
6066
6082
|
let unmodifiedCount = 0;
|
|
6067
6083
|
let errorCount = 0;
|
|
6068
|
-
const { globby } = await import("./globby-
|
|
6084
|
+
const { globby } = await import("./globby-KA6WL2LK.js");
|
|
6069
6085
|
const files = await globby(slash(globPattern), {
|
|
6070
6086
|
followSymbolicLinks: true,
|
|
6071
6087
|
ignore: ["**/node_modules/**", "**/dist/**", "**/storybook-static/**", "**/build/**"]
|
|
@@ -6079,7 +6095,7 @@ Please try a different pattern.
|
|
|
6079
6095
|
throw new Error("No files matched");
|
|
6080
6096
|
}
|
|
6081
6097
|
try {
|
|
6082
|
-
const pLimit = (await import("./p-limit-
|
|
6098
|
+
const pLimit = (await import("./p-limit-QM3TBYML.js")).default;
|
|
6083
6099
|
const limit = pLimit(maxConcurrentTasks);
|
|
6084
6100
|
await Promise.all(
|
|
6085
6101
|
files.map(
|
|
@@ -7017,7 +7033,7 @@ var addonA11yParameters = {
|
|
|
7017
7033
|
}
|
|
7018
7034
|
}
|
|
7019
7035
|
}
|
|
7020
|
-
const { default: pLimit } = await import("./p-limit-
|
|
7036
|
+
const { default: pLimit } = await import("./p-limit-QM3TBYML.js");
|
|
7021
7037
|
const limit = pLimit(10);
|
|
7022
7038
|
await Promise.all(
|
|
7023
7039
|
storyFilesToUpdate.map(
|
|
@@ -7263,7 +7279,7 @@ function transformPackageJson(content) {
|
|
|
7263
7279
|
__name(transformPackageJson, "transformPackageJson");
|
|
7264
7280
|
var transformPackageJsonFiles = /* @__PURE__ */ __name(async (files, dryRun) => {
|
|
7265
7281
|
const errors = [];
|
|
7266
|
-
const { default: pLimit } = await import("./p-limit-
|
|
7282
|
+
const { default: pLimit } = await import("./p-limit-QM3TBYML.js");
|
|
7267
7283
|
const limit = pLimit(10);
|
|
7268
7284
|
await Promise.all(
|
|
7269
7285
|
files.map(
|
|
@@ -7325,7 +7341,7 @@ var consolidatedImports = {
|
|
|
7325
7341
|
dryRun
|
|
7326
7342
|
);
|
|
7327
7343
|
errors.push(...packageJsonErrors);
|
|
7328
|
-
const { globby } = await import("./globby-
|
|
7344
|
+
const { globby } = await import("./globby-KA6WL2LK.js");
|
|
7329
7345
|
const configFiles = await globby([`${configDir}/**/*`]);
|
|
7330
7346
|
const importErrors = await transformImportFiles(
|
|
7331
7347
|
[...storiesPaths, ...configFiles].filter(Boolean),
|
|
@@ -7867,7 +7883,7 @@ var replaceImports = /* @__PURE__ */ __name((source, renderer, framework) => {
|
|
|
7867
7883
|
}, "replaceImports");
|
|
7868
7884
|
var transformSourceFiles = /* @__PURE__ */ __name(async (files, renderer, framework, dryRun) => {
|
|
7869
7885
|
const errors = [];
|
|
7870
|
-
const { default: pLimit } = await import("./p-limit-
|
|
7886
|
+
const { default: pLimit } = await import("./p-limit-QM3TBYML.js");
|
|
7871
7887
|
const limit = pLimit(10);
|
|
7872
7888
|
await Promise.all(
|
|
7873
7889
|
files.map(
|
|
@@ -7969,7 +7985,7 @@ var rendererToFramework = {
|
|
|
7969
7985
|
}
|
|
7970
7986
|
logger12.debug(`
|
|
7971
7987
|
Migrating ${rendererPackage} to ${selectedFramework}`);
|
|
7972
|
-
const { globby } = await import("./globby-
|
|
7988
|
+
const { globby } = await import("./globby-KA6WL2LK.js");
|
|
7973
7989
|
const configFiles = await globby([`${configDir}/**/*`]);
|
|
7974
7990
|
await transformSourceFiles(
|
|
7975
7991
|
[...storiesPaths, ...configFiles].filter(Boolean),
|
|
@@ -8004,7 +8020,7 @@ async function renameInFile(filePath, oldText, newText) {
|
|
|
8004
8020
|
__name(renameInFile, "renameInFile");
|
|
8005
8021
|
var getDotStorybookReferences = /* @__PURE__ */ __name(async (searchDir) => {
|
|
8006
8022
|
try {
|
|
8007
|
-
const { globby } = await import("./globby-
|
|
8023
|
+
const { globby } = await import("./globby-KA6WL2LK.js");
|
|
8008
8024
|
const { readFile: readFile7 } = await import("node:fs/promises");
|
|
8009
8025
|
const files = await globby(`${searchDir}/**/*`, {
|
|
8010
8026
|
onlyFiles: true,
|
|
@@ -8039,7 +8055,7 @@ var rnstorybookConfig = {
|
|
|
8039
8055
|
const projectDir = mainConfigPath ? join2(mainConfigPath, "..", "..") : process.cwd();
|
|
8040
8056
|
const storybookDir = join2(projectDir, ".storybook");
|
|
8041
8057
|
const rnStorybookDir = join2(projectDir, ".rnstorybook");
|
|
8042
|
-
const { globby } = await import("./globby-
|
|
8058
|
+
const { globby } = await import("./globby-KA6WL2LK.js");
|
|
8043
8059
|
const requiresFiles = await globby(join2(storybookDir, "storybook.requires.*"));
|
|
8044
8060
|
if (existsSync2(storybookDir) && requiresFiles.length > 0 && !existsSync2(rnStorybookDir)) {
|
|
8045
8061
|
return { storybookDir, rnStorybookDir };
|
|
@@ -9531,7 +9547,7 @@ var sandbox = /* @__PURE__ */ __name(async ({
|
|
|
9531
9547
|
{
|
|
9532
9548
|
message: "Enter the output directory",
|
|
9533
9549
|
initialValue: outputDirectoryName ?? void 0,
|
|
9534
|
-
validate: /* @__PURE__ */ __name((directoryName) => existsSync3(directoryName) ? `${directoryName} already exists. Please choose another name.` : void 0, "validate")
|
|
9550
|
+
validate: /* @__PURE__ */ __name((directoryName) => directoryName && existsSync3(directoryName) ? `${directoryName} already exists. Please choose another name.` : void 0, "validate")
|
|
9535
9551
|
},
|
|
9536
9552
|
{
|
|
9537
9553
|
onCancel: /* @__PURE__ */ __name(() => {
|
package/dist/bin/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import CJS_COMPAT_NODE_URL_48ba0y5fih6 from 'node:url';
|
|
3
|
+
import CJS_COMPAT_NODE_PATH_48ba0y5fih6 from 'node:path';
|
|
4
|
+
import CJS_COMPAT_NODE_MODULE_48ba0y5fih6 from "node:module";
|
|
5
5
|
|
|
6
|
-
var __filename =
|
|
7
|
-
var __dirname =
|
|
8
|
-
var require =
|
|
6
|
+
var __filename = CJS_COMPAT_NODE_URL_48ba0y5fih6.fileURLToPath(import.meta.url);
|
|
7
|
+
var __dirname = CJS_COMPAT_NODE_PATH_48ba0y5fih6.dirname(__filename);
|
|
8
|
+
var require = CJS_COMPAT_NODE_MODULE_48ba0y5fih6.createRequire(import.meta.url);
|
|
9
9
|
|
|
10
10
|
// ------------------------------------------------------------
|
|
11
11
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -22,4 +22,4 @@ if (majorNodeVersion < 20 || majorNodeVersion === 20 && minorNodeVersion < 19 ||
|
|
|
22
22
|
);
|
|
23
23
|
process.exit(1);
|
|
24
24
|
}
|
|
25
|
-
import("../_node-chunks/run-
|
|
25
|
+
import("../_node-chunks/run-F43VY34Q.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/cli",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.5",
|
|
4
4
|
"description": "Storybook CLI: Develop, document, and test UI components in isolation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -41,24 +41,24 @@
|
|
|
41
41
|
"prep": "jiti ../../../scripts/build/build-package.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@storybook/codemod": "10.0.0-beta.
|
|
44
|
+
"@storybook/codemod": "10.0.0-beta.5",
|
|
45
45
|
"@types/semver": "^7.3.4",
|
|
46
|
-
"commander": "^
|
|
47
|
-
"create-storybook": "10.0.0-beta.
|
|
48
|
-
"giget": "^
|
|
46
|
+
"commander": "^14.0.1",
|
|
47
|
+
"create-storybook": "10.0.0-beta.5",
|
|
48
|
+
"giget": "^2.0.0",
|
|
49
49
|
"jscodeshift": "^0.15.1",
|
|
50
|
-
"storybook": "10.0.0-beta.
|
|
50
|
+
"storybook": "10.0.0-beta.5",
|
|
51
51
|
"ts-dedent": "^2.0.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/cross-spawn": "^6.0.6",
|
|
55
55
|
"@types/prompts": "^2.0.9",
|
|
56
|
-
"boxen": "^
|
|
56
|
+
"boxen": "^8.0.1",
|
|
57
57
|
"comment-json": "^4.2.5",
|
|
58
58
|
"cross-spawn": "^7.0.6",
|
|
59
|
+
"empathic": "^2.0.0",
|
|
59
60
|
"envinfo": "^7.14.0",
|
|
60
61
|
"execa": "^9.6.0",
|
|
61
|
-
"find-up": "^7.0.0",
|
|
62
62
|
"globby": "^14.0.1",
|
|
63
63
|
"leven": "^4.0.0",
|
|
64
64
|
"p-limit": "^6.2.0",
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ovdoyekg4cg from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ovdoyekg4cg from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ovdoyekg4cg from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ovdoyekg4cg.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ovdoyekg4cg.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ovdoyekg4cg.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
import {
|
|
13
|
-
__name
|
|
14
|
-
} from "./chunk-42LUW6OW.js";
|
|
15
|
-
|
|
16
|
-
// ../../node_modules/yocto-queue/index.js
|
|
17
|
-
var Node = class {
|
|
18
|
-
static {
|
|
19
|
-
__name(this, "Node");
|
|
20
|
-
}
|
|
21
|
-
value;
|
|
22
|
-
next;
|
|
23
|
-
constructor(value) {
|
|
24
|
-
this.value = value;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var Queue = class {
|
|
28
|
-
static {
|
|
29
|
-
__name(this, "Queue");
|
|
30
|
-
}
|
|
31
|
-
#head;
|
|
32
|
-
#tail;
|
|
33
|
-
#size;
|
|
34
|
-
constructor() {
|
|
35
|
-
this.clear();
|
|
36
|
-
}
|
|
37
|
-
enqueue(value) {
|
|
38
|
-
const node = new Node(value);
|
|
39
|
-
if (this.#head) {
|
|
40
|
-
this.#tail.next = node;
|
|
41
|
-
this.#tail = node;
|
|
42
|
-
} else {
|
|
43
|
-
this.#head = node;
|
|
44
|
-
this.#tail = node;
|
|
45
|
-
}
|
|
46
|
-
this.#size++;
|
|
47
|
-
}
|
|
48
|
-
dequeue() {
|
|
49
|
-
const current = this.#head;
|
|
50
|
-
if (!current) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
this.#head = this.#head.next;
|
|
54
|
-
this.#size--;
|
|
55
|
-
return current.value;
|
|
56
|
-
}
|
|
57
|
-
peek() {
|
|
58
|
-
if (!this.#head) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
return this.#head.value;
|
|
62
|
-
}
|
|
63
|
-
clear() {
|
|
64
|
-
this.#head = void 0;
|
|
65
|
-
this.#tail = void 0;
|
|
66
|
-
this.#size = 0;
|
|
67
|
-
}
|
|
68
|
-
get size() {
|
|
69
|
-
return this.#size;
|
|
70
|
-
}
|
|
71
|
-
*[Symbol.iterator]() {
|
|
72
|
-
let current = this.#head;
|
|
73
|
-
while (current) {
|
|
74
|
-
yield current.value;
|
|
75
|
-
current = current.next;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
*drain() {
|
|
79
|
-
while (this.#head) {
|
|
80
|
-
yield this.dequeue();
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export {
|
|
86
|
-
Queue
|
|
87
|
-
};
|