{"name":"@jsdevtools/file-path-filter","version":"2.2.2","description":"Filters file paths using globs, regular expressions, or custom criteria","keywords":["filter","find","file","path","regex","regexp","glob","include","exclude"],"author":{"name":"James Messinger","url":"https://jamesmessinger.com"},"license":"MIT","homepage":"https://jstools.dev/file-path-filter","repository":{"type":"git","url":"git+https://github.com/JS-DevTools/file-path-filter.git"},"main":"lib/index.js","types":"lib/index.d.ts","scripts":{"clean":"shx rm -rf .nyc_output coverage lib","lint":"npm run lint:typescript && npm run lint:javascript","lint:typescript":"tslint -p tsconfig.json","lint:javascript":"eslint test","build":"tsc","watch":"tsc --watch","test":"mocha && npm run lint","coverage":"nyc node_modules/mocha/bin/mocha","upgrade":"npm-check -u && npm audit fix","bump":"bump --tag --push --all","release":"npm run upgrade && npm run clean && npm run build && npm test && npm run bump"},"engines":{"node":">=10"},"devDependencies":{"@jsdevtools/eslint-config-modular":"^8.0.0","@jsdevtools/tslint-modular":"^2.0.1","@jsdevtools/version-bump-prompt":"^6.0.0","@types/chai":"^4.2.9","@types/glob-to-regexp":"^0.4.0","@types/mocha":"^7.0.1","@types/node":"^13.7.1","chai":"^4.2.0","coveralls":"^3.0.9","eslint":"^6.8.0","mocha":"^7.0.1","npm-check":"^5.9.0","nyc":"^15.0.0","shx":"^0.3.2","tslint":"^6.0.0","typescript":"^3.7.5","typescript-tslint-plugin":"^0.5.5"},"dependencies":{"glob-to-regexp":"^0.4.1"},"gitHead":"5dd79a22d1bee706e2409d369c1583fa86129a22","bugs":{"url":"https://github.com/JS-DevTools/file-path-filter/issues"},"_id":"@jsdevtools/file-path-filter@2.2.2","_nodeVersion":"13.3.0","_npmVersion":"6.13.1","dist":{"integrity":"sha512-d5rr9U47RHs84XH+5OyomWLZAgob3HFMVzQw+dT1CBKWqUQ2C3RQmwBwM7UD3OpzOeiW+A6dDpbzyMOSm6plFw==","shasum":"fd0baecac30eb057d67a06b53fbef220f21ae48d","tarball":"http://registry-npm.ywwl.com/@jsdevtools/file-path-filter/download/@jsdevtools/file-path-filter-2.2.2.tgz","fileCount":22,"unpackedSize":29637,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSVKHCRA9TVsSAnZWagAA5AUP/Aj04+Dkx1llTjlwZbc5\n+fEi0AJmejA3km0m2sc4SqSo059BYmkDOwq902tXtlfjr97d78gXJseloPAd\nz6qHjVQ1zUHf84we3OteTFlQ5e3e8Bkkf7x9cIgskLZYiKq3Wjhb2pW5EW4h\nfTWPyClBKZySsvwVAjW/TGdNx7gotshKHL98QmU0zdH7WrZY/n3puUFyPcK0\nU+dknSvH4bJvgOr/f2R4YnICvLA1GRfiUOJcBHMse0FHm2enVxuZPdFu+oOz\nN34sOEGADEOGApMQMLpnuSECISidgyYmJBUGYB2L3DrvScJf4KyIx8xsVwA2\nSZU+I63mp3vd4GKiJF4VoEI6rZG+qfRs+Qs1Oa41E7QvPRWqzvMRLfE9b6Dm\njF32uVPd+5HtmXFatRFoDtLEmTQPunUj+C9fJp+0dV43KzVWnPVwLkcd4Wi5\nqJMC8LJHwHFEt0u9Kwm7od6rwwDMUB9BUFB2Nhyetz1KnuPWjoHfws1WJxgr\n3/x35BKs5rR29SvugJvTqBKPyzsudQ7mP4DmG+/ZcurONcSVzXzkt3l7LdhK\npMSrFieZXt5DMrt0wY3ri1BvMpP2o2nyrRQi8Nc+1lbWPq3PETMNn2qMFwnn\nDcgOldIdmwfLTyxt20Shyiudt1oDvPdE6ILNUR6KrPQTJ4aW5vVsXSwQukE7\n0ci+\r\n=ETqe\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDyBqip9f7SFbG6EIrn12RYpDlOfXvfUw6EuXP38jciEAiEA+3xCS/vkDxsdDR37cYmcFTGjboEPBmXeAVdoWJdvSUU="}],"size":8942,"noattachment":false,"key":"/@jsdevtools/file-path-filter/-/@jsdevtools/file-path-filter-2.2.2.tgz"},"maintainers":[{"name":"jamesmessinger","email":"james.messinger@gmail.com"},{"name":"james_messinger","email":"j.ames.messinger@gmail.com"}],"_npmUser":{"name":"jamesmessinger","email":"james.messinger@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/file-path-filter_2.2.2_1581863559193_0.7974526461031357"},"_hasShrinkwrap":false,"readme":"# File Path Filter\nFilters file paths using globs, regular expressions, or custom criteria\n\n[![Cross-Platform Compatibility](https://jstools.dev/img/badges/os-badges.svg)](https://github.com/JS-DevTools/file-path-filter/actions)\n[![Build Status](https://github.com/JS-DevTools/file-path-filter/workflows/CI-CD/badge.svg)](https://github.com/JS-DevTools/file-path-filter/actions)\n\n[![Coverage Status](https://coveralls.io/repos/github/JS-DevTools/file-path-filter/badge.svg?branch=master)](https://coveralls.io/github/JS-DevTools/file-path-filter)\n[![Dependencies](https://david-dm.org/JS-DevTools/file-path-filter.svg)](https://david-dm.org/JS-DevTools/file-path-filter)\n\n[![npm](https://img.shields.io/npm/v/@jsdevtools/file-path-filter.svg)](https://www.npmjs.com/package/@jsdevtools/file-path-filter)\n[![License](https://img.shields.io/npm/l/@jsdevtools/file-path-filter.svg)](LICENSE)\n[![Buy us a tree](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen)](https://plant.treeware.earth/JS-DevTools/file-path-filter)\n\n\n\nExample\n--------------------------\n\n```javascript\nconst filePathFilter = require(\"@jsdevtools/file-path-filter\");\n\nconst paths = [\n  \"/some/path/index.html\",\n  \"/some/path/contact.html\",\n  \"/some/path/about.html\",\n  \"/some/path/favicon.ico\",\n  \"/some/path/img/logo.png\",\n];\n\n// Filter using a glob pattern\npaths.filter(filePathFilter(\"**/*.html\"));\n\n// Exclude glob patterns with \"!\"\npaths.filter(filePathFilter(\"**/*.html\", \"!**/index.html\"));\n\n// Filter using a regular expression\npaths.filter(filePathFilter(/\\.(ico|png)$/));\n\n// Filter using custom criteria\npaths.filter(filePathFilter(path => path.length === 23));\n\n// Use any combination of filters\npaths.filter(filePathFilter([\n  \"**/*.html\",\n  \"!**/index.html\",\n  /\\.(ico|png)$/,\n  path => path.length === 23\n]));\n\n// Explicitly specify include and exclude criteria\npaths.filter(filePathFilter({\n  include:  [\n    \"**/*.html\",\n    /\\.(ico|png)$/,\n    path => path.length === 23\n  ],\n  exclude: \"**/index.html\",\n));\n\n```\n\n\n\nInstallation\n--------------------------\nYou can install File Path Filter via [npm](https://docs.npmjs.com/about-npm/).\n\n```bash\nnpm install @jsdevtools/file-path-filter\n```\n\n\n\nUsage\n--------------------------\n\n### filePathFilter(criteria)\n\n- **`criteria`** - The filter criteria. This can be any of the following:\n  - A boolean. `true` will match all files. `false` will not match any files.\n  - A [glob pattern](https://en.wikipedia.org/wiki/Glob_(programming)). If the pattern starts with `!`, then it will be treated as an `exclude` pattern (see below)\n  - A [regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp)\n  - A [filter function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#Syntax) that accepts a file path and returns `true` if the file should be matched\n  - An array containing any combination of the above types\n  - An object with `include` and `exclude` properties. Each of these properties can be any of the above types.  File paths will be matched if they match any of the `include` criteria and do not match any of the `exclude` criteria.\n\n- **`return value`** - A [filter function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#Syntax) that matches file paths that meet the specified criteria\n\n\n### createFilter(options, criteria)\n\n- **`options`** - An object with some or all of the following properties:\n  - `map` - A function that maps filtered items to file paths\n  - `sep` - A custom path separator, such as `\\` or `/`\n\n- **`criteria`** - The filter criteria. See the [`filePathFilter`](#filepathfiltercriteria) for details.\n\n- **`return value`** - A [filter function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#Syntax) that matches file paths that meet the specified criteria\n\nThe `createFilter` function is an alternative to the `filePathFilter` function that allows you to customize the behavior to suit your needs.\n\n#### Filtering objects\nThe `filePathFilter` function creates a function that filters arrays of strings, but what if you need to filter an array of objects instead?  That's where the `map` option comes in handy. You can use it to map objects (or any other value) to file paths.  Here's an example:\n\n```javascript\nconst { createFilter } = require(\"@jsdevtools/file-path-filter\");\nconst path = require(\"path\");\n\nconst files = [\n  { dir: \"/my/website\", filename: \"index.html\" },\n  { dir: \"/my/website\", filename: \"contact.html\" },\n  { dir: \"/my/website/blog\", filename: \"post-1.html\" },\n  { dir: \"/my/website/blog\", filename: \"post-2.html\" },\n];\n\n// A function to returns the path of each file\nfunction map(file) {\n  return path.join(file.dir, file.filename);\n}\n\n// Filter the file objects - return all HTML files except the blog posts\nfiles.filter(createFilter({ map }, \"**/*.html\", \"!**/blog/*.html\"));\n```\n\n\nContributing\n--------------------------\nContributions, enhancements, and bug-fixes are welcome!  [Open an issue](https://github.com/JS-DevTools/file-path-filter/issues) on GitHub and [submit a pull request](https://github.com/JS-DevTools/file-path-filter/pulls).\n\n#### Building\nTo build the project locally on your computer:\n\n1. __Clone this repo__<br>\n`git clone https://github.com/JS-DevTools/file-path-filter.git`\n\n2. __Install dependencies__<br>\n`npm install`\n\n3. __Build the code__<br>\n`npm run build`\n\n4. __Run the tests__<br>\n`npm test`\n\n\n\nLicense\n--------------------------\nFile Path Filter is 100% free and open-source, under the [MIT license](LICENSE). Use it however you want.\n\nThis package is [Treeware](http://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**](https://plant.treeware.earth/JS-DevTools/file-path-filter) to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.\n\n\n\nBig Thanks To\n--------------------------\nThanks to these awesome companies for their support of Open Source developers ❤\n\n[![Travis CI](https://jstools.dev/img/badges/travis-ci.svg)](https://travis-ci.com)\n[![SauceLabs](https://jstools.dev/img/badges/sauce-labs.svg)](https://saucelabs.com)\n[![Coveralls](https://jstools.dev/img/badges/coveralls.svg)](https://coveralls.io)\n","publish_time":1581863559309,"_cnpm_publish_time":1581863559309,"dist-tags":{"latest":"3.0.2"}}