Sha256: 7ee76c952fb46253b98a8c8c5cd622b160aefba87b64b9da465b734230a5e06d

Contents?: true

Size: 867 Bytes

Versions: 10

Compression:

Stored size: 867 Bytes

Contents

import { resolve, sep } from 'path';
import mm from 'micromatch';
import ensureArray from './utils/ensureArray';

export default function createFilter ( include, exclude ) {
	const getMatcher = id => ( isRegexp( id ) ? id : { test: mm.matcher( resolve( id ) ) } );
	include = ensureArray( include ).map( getMatcher );
	exclude = ensureArray( exclude ).map( getMatcher );

	return function ( id ) {

		if ( typeof id !== 'string' ) return false;
		if ( /\0/.test( id ) ) return false;

		id = id.split( sep ).join( '/' );

		for ( let i = 0; i < exclude.length; ++i ) {
			const matcher = exclude[i];
			if ( matcher.test( id ) ) return false;
		}

		for ( let i = 0; i < include.length; ++i ) {
			const matcher = include[i];
			if ( matcher.test( id ) ) return true;
		}

		return !include.length;
	};
}

function isRegexp ( val ) {
	return val instanceof RegExp;
}

Version data entries

10 entries across 8 versions & 3 rubygems

Version Path
jass-0.9.5 vendor/node_modules/rollup-pluginutils/src/createFilter.js
jass-0.9.4 vendor/node_modules/rollup-pluginutils/src/createFilter.js
jass-vue-0.4.0 vendor/node_modules/rollup-pluginutils/src/createFilter.js
jass-vue-0.4.0 vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/src/createFilter.js
jass-vue-0.3.0 vendor/node_modules/rollup-pluginutils/src/createFilter.js
jass-vue-0.3.0 vendor/node_modules/rollup-plugin-replace/node_modules/rollup-pluginutils/src/createFilter.js
jass-0.9.3 vendor/node_modules/rollup-pluginutils/src/createFilter.js
condenser-0.0.4 lib/condenser/processors/node_modules/rollup-pluginutils/src/createFilter.js
jass-vue-0.2.1 vendor/node_modules/rollup-pluginutils/src/createFilter.js
jass-0.9.1 vendor/node_modules/rollup-pluginutils/src/createFilter.js