1.0.4 • Published 4 years ago

glob-merge v1.0.4

Weekly downloads
-
License
0BSD
Repository
github
Last release
4 years ago

Installation

You can install glob-merge with following tools:

  • npm: npm install glob-merge (add -D flag to install in devDependencies)
  • yarn: yarn add glob-merge (add --dev flag to install in devDependencies)
  • pnpm: pnpm add glob-merge (add -D flag to install in devDependencies)

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 to node-glob. Defaults to an empty Object. If missing, the second argument is treated as a callback.
  • callback: A function with error and matches 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!

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago