{"name":"gulp-filter","version":"7.0.0","description":"Filter files in a `vinyl` stream","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/gulp-filter.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"engines":{"node":">=12"},"scripts":{"test":"xo && mocha"},"keywords":["gulpplugin","filter","ignore","file","files","match","minimatch","glob","globbing","vinyl"],"dependencies":{"multimatch":"^5.0.0","plugin-error":"^1.0.1","streamfilter":"^3.0.0","to-absolute-glob":"^2.0.2"},"devDependencies":{"mocha":"^8.3.2","vinyl":"^2.2.1","xo":"^0.39.1"},"peerDependencies":{"gulp":">=4"},"peerDependenciesMeta":{"gulp":{"optional":true}},"gitHead":"d75da43d92fab88b6a32a73a55b673f25b8bbbb7","bugs":{"url":"https://github.com/sindresorhus/gulp-filter/issues"},"homepage":"https://github.com/sindresorhus/gulp-filter#readme","_id":"gulp-filter@7.0.0","_nodeVersion":"12.22.1","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-ZGWtJo0j1mHfP77tVuhyqem4MRA5NfNRjoVe6VAkLGeQQ/QGo2VsFwp7zfPTGDsd1rwzBmoDHhxpE6f5B3Zuaw==","shasum":"e0712f3e57b5d647f802a1880255cafb54abf158","tarball":"http://registry-npm.ywwl.com/gulp-filter/download/gulp-filter-7.0.0.tgz","fileCount":4,"unpackedSize":7453,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2s1ACRA9TVsSAnZWagAAWh8QAKTKXZmQKGLZzEqGewNe\n10K+2F3JZbVhvNvP9zHIF1yA86/3yKXdbME32HRmd2ltlyVvIcZjO5Olx0dp\nFjwRS0zAqnZSIKsepqqCAEuB3Nh1OFrTkRaM5UFvPwr8sL6OtdpoY8X5vLKP\nyS9n0jTPiq55xh+8O+/cuGYqMZxEZFBpBm7skkwxz+7XpfcGs45Ri+UooXjg\nmHN5BV+ICsO2ynwm4WF/kuzVQ7VhS6AR8OiopwkUpo7fCvFPT3WUzpD/apaj\nHFUncGMXd1B7JMqZQe2rZPk0U95TodXc23aPgoFJxrLA2yh97tssRoSjRzkO\nxkshxl5CVqYielFf31iTfekJcrQRRCccx82ev6RxJAK3Kg2er3ulOmGgpTOJ\nPjT2p7YbEr7ojYXlo7kIBN0ZAnEPfkD3ns3D4xcwWFDHupOt100x6kOUN51c\nFuGIhz32UCr4WvChjOgEyCUbWIudVJd+QiBuHq0P/wtlGAw5mBHgk0J5d3e2\nl2nEID+jPV1XCapjUDnSJNTxuSle1slPDP/Cst3kG/4xehctYtA7jZ4Y7uIY\nxmCdSzVaYcThRb+jpWQUXpMFBM17UT7ewArG1NB8o+zLIr+BUqfLij5WQXCs\njHKDccnxfTgyk8dlYlI/raA2VM5bqLTyiR4eAWDM4VvVTeDr7HM5MRd8sW6o\nPNi6\r\n=3Mec\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCSzwliW4hY1UkXgM/wMBpnxzcIf3QHMk9UAHZeAwf2KQIgXpqI0VOptpveWpjbfImqKMcgdW9bKyqSzLtHitqKScw="}],"size":3061,"noattachment":false,"key":"/gulp-filter/-/gulp-filter-7.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gulp-filter_7.0.0_1619289875310_0.4551379094936421"},"_hasShrinkwrap":false,"readme":"# gulp-filter\n\n> Filter files in a [`vinyl`](https://github.com/gulpjs/vinyl) stream\n\nEnables you to work on a subset of the original files by filtering them using glob patterns. When you're done and want all the original files back, you just use the `restore` stream.\n\n## Install\n\n```sh\nnpm install --save-dev gulp-filter\n```\n\n## Usage\n\n### Filter only\n\nYou may want to just filter the stream content:\n\n```js\nimport gulp from 'gulp';\nimport uglify from 'gulp-uglify';\nimport filter from 'gulp-filter';\n\nexport default () => {\n\t// Create filter instance inside task function\n\tconst f = filter(['**', '!*src/vendor']);\n\n\treturn gulp.src('src/**/*.js')\n\t\t// Filter a subset of the files\n\t\t.pipe(f)\n\t\t// Run them through a plugin\n\t\t.pipe(uglify())\n\t\t.pipe(gulp.dest('dist'));\n};\n```\n\n### Restoring filtered files\n\n```js\nimport gulp 'gulp';\nimport uglify 'gulp-uglify';\nimport filter 'gulp-filter';\n\nexport default () => {\n\t// Create filter instance inside task function\n\tconst f = filter(['**', '!*src/vendor'], {restore: true});\n\n\treturn gulp.src('src/**/*.js')\n\t\t// Filter a subset of the files\n\t\t.pipe(f)\n\t\t// Run them through a plugin\n\t\t.pipe(uglify())\n\t\t// Bring back the previously filtered out files (optional)\n\t\t.pipe(f.restore)\n\t\t.pipe(gulp.dest('dist'));\n};\n```\n\n### Multiple filters\n\nBy combining and restoring different filters you can process different sets of files with a single pipeline.\n\n```js\nimport gulp from 'gulp';\nimport less from 'gulp-less';\nimport concat from 'gulp-concat';\nimport filter from 'gulp-filter';\n\nexport default () => {\n\tconst jsFilter = filter('**/*.js', {restore: true});\n\tconst lessFilter = filter('**/*.less', {restore: true});\n\n\treturn gulp.src('assets/**')\n\t\t.pipe(jsFilter)\n\t\t.pipe(concat('bundle.js'))\n\t\t.pipe(jsFilter.restore)\n\t\t.pipe(lessFilter)\n\t\t.pipe(less())\n\t\t.pipe(lessFilter.restore)\n\t\t.pipe(gulp.dest('out/'));\n};\n```\n\n### Restore as a file source\n\nYou can restore filtered files in a different place and use it as a standalone source of files (ReadableStream). Setting the `passthrough` option to `false` allows you to do so.\n\n```js\nimport gulp 'gulp';\nimport uglify 'gulp-uglify';\nimport filter 'gulp-filter';\n\nexport default () => {\n\tconst f = filter(['**', '!*src/vendor'], {restore: true, passthrough: false});\n\n\tconst stream = gulp.src('src/**/*.js')\n\t\t// Filter a subset of the files\n\t\t.pipe(f)\n\t\t// Run them through a plugin\n\t\t.pipe(uglify())\n\t\t.pipe(gulp.dest('dist'));\n\n\t// Use filtered files as a gulp file source\n\tf.restore.pipe(gulp.dest('vendor-dist'));\n\n\treturn stream;\n};\n```\n\n## API\n\n### filter(pattern, options?)\n\nReturns a [transform stream](https://nodejs.org/api/stream.html#stream_class_stream_transform) with a [.restore](#optionsrestore) property.\n\n#### pattern\n\nType: `string | string[] | Function`\n\nAccepts a string/array with globbing patterns which are run through [multimatch](https://github.com/sindresorhus/multimatch).\n\nIf you supply a function, you'll get a [`vinyl` file object](https://github.com/wearefractal/vinyl#file) as the first argument and you're expected to return a boolean of whether to include the file:\n\n```js\nfilter(file => /unicorns/.test(file.path));\n```\n\n#### options\n\nType: `object`\n\nAccepts [`minimatch` options](https://github.com/isaacs/minimatch#options).\n\n*Note:* Set `dot: true` if you need to match files prefixed with a dot, for example, `.gitignore`.\n\n##### restore\n\nType: `boolean`\\\nDefault: `false`\n\nRestore filtered files.\n\n##### passthrough\n\nType: `boolean`\\\nDefault: `true`\n\nWhen set to `true`, filtered files are restored with a `stream.PassThrough`, otherwise, when set to `false`, filtered files are restored as a `stram.Readable`.\n\nWhen the stream is a `stream.Readable`, it ends by itself, but when it's `stream.PassThrough`, you are responsible of ending the stream.\n","publish_time":1619289875446,"_cnpm_publish_time":1619289875446,"dist-tags":{"latest":"10.0.0"}}