Skip to content

fast-glob

约 115 字小于 1 分钟

2024-05-13

NodeJS 18.18.0+

概述

fast-glob 官方文档

这是一个非常快速高效的Node.js glob 库。

安装

npm
npm install fast-glob

使用

import { glob, globStream, globSync } from 'fast-glob'
// 异步模式
const entries = await glob(['.editorconfig', '**/index.js'], { dot: true })

// 同步模式
const entries = globSync(['.editorconfig', '**/index.js'], { dot: true })

// 流模式
const stream = globStream(['.editorconfig', '**/index.js'], { dot: true })

for await (const entry of stream) {
  // .editorconfig
  // services/index.js
}