{"name":"@jsdevtools/file-path-filter","version":"3.0.0","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":"53aecdf9418601d9de846ad5eafc0f0f1833fee9","bugs":{"url":"https://github.com/JS-DevTools/file-path-filter/issues"},"_id":"@jsdevtools/file-path-filter@3.0.0","_nodeVersion":"10.19.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-JNtnixm+7/x5wo32j2d3XEaU3NITa1XD1nuYTCM0peSkB1AC0ziA7lRJ4o3CwpSlq1QUXgi2ymJLjWWw0PROgw==","shasum":"682a47369a595815f081aa3d7e8c1fae42ce2e29","tarball":"http://registry-npm.ywwl.com/@jsdevtools/file-path-filter/download/@jsdevtools/file-path-filter-3.0.0.tgz","fileCount":22,"unpackedSize":30123,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeSVVLCRA9TVsSAnZWagAAsOQP/0C13F5tRMs+a9gKAN4H\n/EP87o1rIQxyg+x6NMG7Lr/CKCYUvOrPA2f/q4x0pQ4jx68qAVXsEN/YQlGl\ny8rbeFUDIQbuR8Y+x2hVJFHhptoq36Kw3BQAbY2LwBeoiVjXJC7MRo6HRb1h\nwaEmyHKIBIFpFPsL5m8LpfNR77SJZs3EzDqkiaCJvdiK0RfX9PC9mg8t+GV7\nU+xhtk/Pwg6Y7RrMGEjH28KcIXW/aDcn0OnGppcTw0hXnb6oUFfho+cmLCJG\nzd6jfah0SAoLknHAXB4Xi20t4CzlZAF/5Z4/ev1b4SsDwJAuvGZ+fNL5VMv/\no/b8OVigkcGegTbwP3WUDja3sNNvlgsvLffhc1KUMX2v1+YLfsOqP3Ngykew\n/Ir+QzSyx5XbLQ9+nx71zmIGXnUNX6nid3s85DaPbd53WbGVeEvanP7xf9xm\neYXHKGPWrza9ZTbha4+Xv368Q+paL7ghjJvJSpqxZ378LgUj9TcBf0r5qMxh\n1O8NqQtdcYZlB7RtJ/rWI23JjIJcC+BxSlk0kUCxdJzoRRpDUaSmBDB05KCO\n8aVuYBEH+VhVTnTzsMV53ut/tbKD9wdxouloaDd7dI6XEBMInH0b56EIBkZp\n3e2hoWHmeWoCuENrductgPF/UQANw16jSB5lsDZVavemx8qow1Rp7Fmp6NzX\nsGQ2\r\n=6Zf5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDZVtjhqSyTOgD+oxoDlAsiGoMHhDRv7crLZKDfH+yi+AiAKyK2H326AdVSV+Q2Ew+oeG/8hBRL4Mw71o3u7DG6EMA=="}],"size":9030,"noattachment":false,"key":"/@jsdevtools/file-path-filter/-/@jsdevtools/file-path-filter-3.0.0.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.0_1581864267210_0.29890728960286284"},"_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":1581864267312,"_cnpm_publish_time":1581864267312,"dist-tags":{"latest":"3.0.2"}}