Skip to content

Commit

Permalink
Remove useless
Browse files Browse the repository at this point in the history
  • Loading branch information
otomad committed Apr 13, 2024
1 parent cf26757 commit bc9d57b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
7 changes: 3 additions & 4 deletions modules/components-globalized/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { createResolver, defineNuxtModule } from "@nuxt/kit";
import { lstat, readFile, readdir, writeFile } from "fs/promises";
import { throttle } from "lodash-es";
import { parse, basename } from "path";
import { enumerate } from "../../utils/array";
import { environment } from "../../utils/environment";

type WatchEvent = "update" | "remove";
Expand All @@ -14,7 +13,7 @@ export default defineNuxtModule({
if (environment.production) return;
const { resolve: localResolve } = createResolver(import.meta.url);
const { resolve } = createResolver(localResolve("../../.nuxt"));

const registered = {
components: [] as string[],
classes: [] as string[],
Expand Down Expand Up @@ -43,8 +42,8 @@ export default defineNuxtModule({
registered.classes = classes.slice();
await writeFile(resolve("../types/", D_TS_NAME), (() => {
let result = "";
for (const [index, klass] of enumerate(classes, 1))
result += `import * as _${index} from "../classes/${klass}";\n`;
for (const [index, klass] of classes.entries())
result += `import * as _${index + 1} from "../classes/${klass}";\n`;
result += "\ndeclare global {\n";
result += "\t// components\n";
for (const component of components)
Expand Down
12 changes: 0 additions & 12 deletions utils/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,6 @@ export function arrayMapObject<T, K extends ObjectKey, U>(array: T[], callbackFn
return Object.fromEntries(array.map((value, index, array) => callbackFn(value, index, array))) as Record<K, U>;
}

/**
* 类似于 Python 的 `enumerate` 函数。
*
* `enumerate()` 函数用于将一个可遍历的数据对象(如列表、元组或字符串)组合为一个索引序列,同时列出数据和数据下标,一般用在 for...of 循环当中。
* @param array - 一个序列、迭代器或其他支持迭代对象。
* @param start - 下标起始位置的值,默认为 0。
* @returns 返回依次包含索引值、元素值、源数组的元组。
*/
export function enumerate<T>(array: T[], start: number = 0) {
return array.map((value, index, array) => [index + start, value, array] as const);
}

/**
* 数组去重。
* @param array - 数组。
Expand Down

0 comments on commit bc9d57b

Please sign in to comment.