{"name":"@jsdevtools/file-path-filter","version":"3.0.1","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","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":"bd7079fa361301513ed20e40a52b6030074d9311","bugs":{"url":"https://github.com/JS-DevTools/file-path-filter/issues"},"_id":"@jsdevtools/file-path-filter@3.0.1","_nodeVersion":"10.19.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-7kOhYFyidfB9fZf2LLkMD/AntpFnxzWW614H4hLvWe3ENE9NN32cZQeF0Ychjg6h91XaUYbqQx2D/GtXJ05/Ew==","shasum":"7fa96b4c0d41a2ec6231584a9f90f4e9442d24eb","tarball":"http://registry-npm.ywwl.com/@jsdevtools/file-path-filter/download/@jsdevtools/file-path-filter-3.0.1.tgz","fileCount":22,"unpackedSize":30574,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJebkIVCRA9TVsSAnZWagAA4wMP/Rom6Nbz7U2tcpqOJbzO\na5M/lzKFfukMUs/gU0XgLBRnp7CAX5EjtYUrJKgbnQkexK5alEg3oAuZzLlo\njjH1p+9sxRsn0STcodO7L+8hu99oiYEm2dPQoAj2VfLAZQB3JE10bLf1opE/\nfNaljrmCzXoEADuC0bpIc6Bv+IwROwZSJk63xZFn74b5D/vuXYWy8J8Iq5qt\njbi8xAhWj5I2K/RiHx0GqXXB9Lu6f3CpN33lQkGICL3+uoTQgxtvUa0z/3Q0\nAYB48mD8tsrzGcH9pnjMliQCb+wI9erC7ivi/IvHiJnIUZ06fzRrob3YkN9P\nZuzjMZA0tlp8rLtyv9iLPttpdw22zkgoljnA/1raoQ6WGU9ahy/ihXa9DXdP\n+uWVk9DgIpxmoB//4Cxxz5Vf7LRIT2S5d9RfkdlmxDaP6nrFlRDcZPZnaAMc\nRiSEDVRS4z4zCNmO02QhHKczyvKUEAhBRt9vS/tXJtwodsUfHkVsk2jDGxAb\nQu3xX6p2IZlzd83Gawyoy98RLyIG7UWLre0eungLXdIOMbadNgyViLRbbbzb\nLmpWjhTa9af7+ZN2AfOz4LtcnNl96cvEPTOcBxkN+cH43UlxnC+Dz2JyN1TN\nUlOwyvqn0Ax6ofFxPvEkkvU+1PZCSkOn9oKNrTGj1UV5htFV+RYylBX09sZZ\nzRAl\r\n=puqJ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7Wvc9Klk/ciMO0a4jtHteWzPlL1KIJNj/QP69yKdaOwIgIB4k6WnwuOaCP5yYiTn6UxLMArtZM+3CvXSHAVbWSTo="}],"size":9232,"noattachment":false,"key":"/@jsdevtools/file-path-filter/-/@jsdevtools/file-path-filter-3.0.1.tgz"},"maintainers":[{"name":"james_messinger","email":"j.ames.messinger@gmail.com"},{"name":"jamesmessinger","email":"james.messinger@gmail.com"}],"_npmUser":{"name":"jamesmessinger","email":"james.messinger@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/file-path-filter_3.0.1_1584284180749_0.2255803200118136"},"_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":1584284180873,"_cnpm_publish_time":1584284180873,"dist-tags":{"latest":"3.0.2"}}