count.macro Babel宏计算文件行数与单词数
想知道文件中到底有多少行代码或者多少个单词?count.macro来帮你!它是一个 Babel 宏,能在构建时就计算出源文件的行数和单词数,超方便。你只需要安装npm install --save-dev count.macro
,在代码里这样写:
import { lines, linesIn, wordsIn } from 'count.macro';
console.log(`This file has ${lines} lines`);
。代码会自动转译,输出就像这样:console.log(`This file has 7 lines`);
。对于像 CRA、Gatsby、Next 这些项目都挺兼容的,能省去你手动统计的烦恼。使用时,记得
linesIn
和wordsIn
支持传入路径,能读取其他文件的行数和单词数哦。挺,效果也直观。
count_macro-master.zip
预估大小:17个文件
count.macro-master
文件夹
example
文件夹
lines.txt
12B
index.ts
273B
words.txt
28B
package.json
1KB
.github
文件夹
dependabot.yml
125B
workflows
文件夹
main.yml
251B
77.7KB
文件大小:
评论区