Skip to content

Commit

Permalink
调整项目整体
Browse files Browse the repository at this point in the history
  • Loading branch information
chenbimo committed Nov 9, 2024
1 parent a70b85d commit 2f39ac9
Show file tree
Hide file tree
Showing 81 changed files with 84 additions and 2,354 deletions.
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,9 @@ console.log(validNumber('1.2.')); // 1.20

目前用到的依赖如下:

1. lodash-es
2. es-toolkit
3. date-fns

因为es-toolkit还在开发中,所以部分函数用lodash-es中的。

最终目标是所有基础函数都用es-toolkit中的。

`lib` 目录下,每一个目录是一个函数类型集合。

每个目录下,不能再创建目录,只能创建函数文件。
Expand Down
11 changes: 0 additions & 11 deletions count.js

This file was deleted.

81 changes: 40 additions & 41 deletions generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,49 @@ import { basename, resolve } from 'node:path';
import { readJsonSync } from 'fs-extra/esm';

const categories = {};
const dirPath = 'lib';

['lib', 'libNode', 'libBrowser'].forEach((dirPath) => {
const fileData = [];
const libNames = [];
const dirNames = [];
const fileData = [];
const libNames = [];
const dirNames = [];

// 自动生成导出和单文件
readdirSync(dirPath).forEach((dir) => {
dirNames.push(dir);
const metaFile = resolve(dirPath, dir, '_meta.json');
const metaData = readJsonSync(metaFile);
categories[dir] = { displayName: metaData.name };
const files = readdirSync(resolve(dirPath, dir));
files.forEach((file) => {
if (file === '_meta.json') return;
if (file.endsWith('.test.js')) return;
const stat = statSync(resolve(dirPath, dir, file));
if (stat.isFile() && file.endsWith('.js')) {
const fileName = basename(file, '.js');
const filePath = resolve(dirPath, dir, file);
libNames.push(`yd_${dir}_${fileName}`);
fileData.push(
//
`export { default as yd_${dir}_${fileName} } from './${dirPath}/${dir}/${file}';\r\n`
);
// 判断是否有相关标签
const fileData2 = readFileSync(filePath, { encoding: 'utf8' });
if (!fileData2.includes('@author')) {
console.log(`${filePath} 文件缺少 [作者]`);
}
if (!fileData2.includes('@category')) {
console.log(`${filePath} 文件缺少 [分类]`);
}
if (!fileData2.includes('@alias')) {
console.log(`${filePath} 文件缺少 [别名]`);
}
} else {
console.log(`${dir}/${file}不是一个函数文件`);
// 自动生成导出和单文件
readdirSync(dirPath).forEach((dir) => {
dirNames.push(dir);
const metaFile = resolve(dirPath, dir, '_meta.json');
const metaData = readJsonSync(metaFile);
categories[dir] = { displayName: metaData.name };
const files = readdirSync(resolve(dirPath, dir));
files.forEach((file) => {
if (file === '_meta.json') return;
if (file.endsWith('.test.js')) return;
const stat = statSync(resolve(dirPath, dir, file));
if (stat.isFile() && file.endsWith('.js')) {
const fileName = basename(file, '.js');
const filePath = resolve(dirPath, dir, file);
libNames.push(`yd_${dir}_${fileName}`);
fileData.push(
//
`export { default as yd_${dir}_${fileName} } from './${dirPath}/${dir}/${file}';\r\n`
);
// 判断是否有相关标签
const fileData2 = readFileSync(filePath, { encoding: 'utf8' });
if (!fileData2.includes('@author')) {
console.log(`${filePath} 文件缺少 [作者]`);
}
});
if (!fileData2.includes('@category')) {
console.log(`${filePath} 文件缺少 [分类]`);
}
if (!fileData2.includes('@alias')) {
console.log(`${filePath} 文件缺少 [别名]`);
}
} else {
console.log(`${dir}/${file}不是一个函数文件`);
}
});

writeFileSync(`./${dirPath}.js`, fileData.join(''));
writeFileSync(`./${dirPath}Names.js`, `export const ${dirPath}Names = ${JSON.stringify(libNames)};`);
console.log(`${dirPath} 数据生成完毕`);
});

writeFileSync(`./${dirPath}.js`, fileData.join(''));
writeFileSync(`./${dirPath}Names.js`, `export const ${dirPath}Names = ${JSON.stringify(libNames)};`);
console.log(`${dirPath} 数据生成完毕`);
writeFileSync('./categories.json', JSON.stringify(categories));
38 changes: 0 additions & 38 deletions lib/array/countByProperty.js

This file was deleted.

41 changes: 0 additions & 41 deletions lib/array/countByProperty.test.js

This file was deleted.

26 changes: 0 additions & 26 deletions lib/array/countOccurrences.js

This file was deleted.

16 changes: 0 additions & 16 deletions lib/array/durstenfeldShuffle.js

This file was deleted.

71 changes: 0 additions & 71 deletions lib/array/durstenfeldShuffle.test.js

This file was deleted.

22 changes: 0 additions & 22 deletions lib/array/filterPlus.js

This file was deleted.

40 changes: 0 additions & 40 deletions lib/array/filterPlus.test.js

This file was deleted.

Loading

0 comments on commit 2f39ac9

Please sign in to comment.