1.0.4 • Published 4 years ago
glob-merge v1.0.4
Installation
You can install glob-merge
with following tools:
npm
:npm install glob-merge
(add-D
flag to install indevDependencies
)yarn
:yarn add glob-merge
(add--dev
flag to install indevDependencies
)pnpm
:pnpm add glob-merge
(add-D
flag to install indevDependencies
)
Usage
Import the module
// ES6
import globMerge from 'glob-merge'; // globMerge.async; globMerge.sync
import { globMerge, globMergeSync } from 'glob-merge';
// CommonJS
const globMerge = require('glob-merge'); // globMerge.async; globMerge.sync
const { globMerge, globMergeSync } = require('glob-merge');
Asyncronous
globMerge.async(patterns[, options[, callback]]);
patterns
: A pattern (string) or an array of patterns.options
: An Object of options that is passed tonode-glob
. Defaults to an empty Object. If missing, the second argument is treated as a callback.callback
: A function witherror
andmatches
arguments. If missing, a Promise will be returned.
Synchronous
const matches = globMerge.sync(patterns[, options]);
Returns an array of matched files.
Examples
Asynchronous usgae
// Callback
globMerge.async('*.json', (error, matches) => {
if (error) {
throw error;
}
console.log(matches);
});
// Promise
globMerge.async('*.json')
.then((matches) => {
console.log(matches);
})
.catch((error) => {
throw error;
});
// Promise (async-await)
(async () => {
try {
const matches = await globMerge.sync('*.json');
console.log(matches);
} catch (error) {
throw error;
}
})();
Synchronous usage:
try {
const matches = globMerge.sync('*.json');
console.log(matches);
} catch (error) {
throw error;
}
License
glob-merge
is licensed under the Zero-clause BSD (0BSD) license, so do whatever you want!