How to use the default function from fast-glob

Find comprehensive JavaScript fast-glob.default code examples handpicked from public code repositorys.

fast-glob.default is a Node.js library for quickly and efficiently searching for files and directories that match specific patterns, using a variety of options and filters.

156
157
158
159
160
161
162
163
164
165
},
readContentPaths () {
    let content = [];
    // Resolve globs from the content config
    // TODO: When we make the postcss plugin async-capable this can become async
    let files = _fastGlob.default.sync(this.contentPatterns.all);
    for (let file of files){
        if (_sharedState.env.OXIDE) {
            content.push({
                file,
fork icon0
star icon0
watch icon1

+ 4 other calls in file

3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
if (!conf.language) {
  throw new Error("Configuration does not have language.");
}
await this.clearEverything(userDb);
await this.setConfig(userDb, conf);
const files = import_fast_glob.default.sync(import_path2.default.join(out, "accounts", "*"));
await this.setAccounts(userDb, files);
const periodsPath = import_path2.default.join(out, "periods.tsv");
await this.setPeriods(userDb, (0, import_ts_opaque2.create)(periodsPath));
const entriesPath = import_path2.default.join(out, "entries.tsv");
fork icon0
star icon0
watch icon2

+ 3 other calls in file

How does fast-glob.default work?

fast-glob.default is a Node.js library for quickly and efficiently searching for files and directories that match specific patterns, using a variety of options and filters.

When fast-glob.default is used, it provides a simple and easy-to-use API for performing searches, which includes a range of options and filters to customize the search behavior. Some of the available options include the ability to specify which files and directories to include or exclude, whether to follow symbolic links, and how to sort and limit the results.

fast-glob.default is designed to be fast and efficient, using advanced algorithms and optimizations to perform searches quickly and with low memory usage. It can search for files and directories using a range of patterns, including glob patterns, regular expressions, and even custom functions.

fast-glob.default also supports streaming results, allowing searches to be performed on very large directories or directories with a high number of files, without loading all the results into memory at once.

Overall, fast-glob.default provides a powerful and flexible way to search for files and directories in Node.js applications, making it easier to build powerful and efficient tools for working with files and directories.

126
127
128
129
130
131
132
133
134
135
136
137
138


function resolveChangedFiles(candidateFiles, fileModifiedMap) {
  let changedFiles = new Set();
  _sharedState.env.DEBUG && console.time('Finding changed files');


  let files = _fastGlob.default.sync(candidateFiles);


  for (let file of files) {
    let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity;

fork icon0
star icon0
watch icon1

+ 2 other calls in file

500
501
502
503
504
505
506
507
508
509
function getChangedContent(config) {
  let changedContent = []; // Resolve globs from the purge config

  let globs = extractFileGlobs(config);

  let files = _fastGlob.default.sync(globs);

  for (let file of files) {
    changedContent.push({
      content: _fs.default.readFileSync(_path.default.resolve(file), 'utf8'),
fork icon0
star icon0
watch icon1

+ 2 other calls in file

Ai Example

1
2
3
4
5
6
const fg = require("fast-glob");

// Search for all .js files in the current directory and its subdirectories
fg(["**/*.js"]).then((files) => {
  console.log(files);
});

In this example, we first import fast-glob.default as a module using require. We then call the fg function, passing in a single argument that specifies the pattern to search for: **/*.js. This pattern tells fast-glob.default to search for all files with the .js extension in the current directory and its subdirectories. Finally, we use the then method to handle the results of the search, which are returned as an array of file paths. In this example, we simply log the array of file paths to the console. This example shows how fast-glob.default can be used to perform searches for files and directories using a simple and flexible API, with powerful options and filters to customize the search behavior.

28
29
30
31
32
33
34
35
36
37
let files = tailwindConfig.content.files;
// Normalize the file globs
files = files.filter((filePath)=>typeof filePath === "string");
files = files.map(_normalizePath.default);
// Split into included and excluded globs
let tasks = _fastGlob.default.generateTasks(files);
/** @type {ContentPath[]} */ let included = [];
/** @type {ContentPath[]} */ let excluded = [];
for (const task of tasks){
    included.push(...task.positive.map((filePath)=>parseFilePath(filePath, false)));
fork icon0
star icon0
watch icon0

+ 2 other calls in file