{"_id":"@jsdevtools/file-path-filter","_rev":"37938","name":"@jsdevtools/file-path-filter","description":"Filters file paths using globs, regular expressions, or custom criteria","dist-tags":{"latest":"3.0.2"},"maintainers":[{"name":"jamesmessinger","email":"james.messinger@gmail.com"},{"name":"james_messinger","email":"j.ames.messinger@gmail.com"}],"time":{"modified":"2021-06-03T10:10:43.000Z","created":"2020-02-16T14:32:39.309Z","3.0.2":"2020-07-16T13:55:18.752Z","3.0.1":"2020-03-15T14:56:20.873Z","3.0.0":"2020-02-16T14:44:27.312Z","2.2.2":"2020-02-16T14:32:39.309Z"},"users":{},"author":{"name":"James Messinger","url":"https://jamesmessinger.com"},"repository":{"type":"git","url":"git+https://github.com/JS-DevTools/file-path-filter.git"},"versions":{"3.0.2":{"name":"@jsdevtools/file-path-filter","version":"3.0.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":"eslint src 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":"^1.0.3","@jsdevtools/version-bump-prompt":"^6.0.5","@types/chai":"^4.2.11","@types/glob-to-regexp":"^0.4.0","@types/mocha":"^8.0.0","@types/node":"^14.0.23","chai":"^4.2.0","eslint":"^7.4.0","mocha":"^8.0.1","npm-check":"^5.9.2","nyc":"^15.1.0","shx":"^0.3.2","typescript":"^3.9.6"},"dependencies":{"glob-to-regexp":"^0.4.1"},"gitHead":"a56139256b85d017506d46a007919a3c689a95fe","bugs":{"url":"https://github.com/JS-DevTools/file-path-filter/issues"},"_id":"@jsdevtools/file-path-filter@3.0.2","_nodeVersion":"10.21.0","_npmVersion":"6.14.4","dist":{"shasum":"22a0b544b8471fafd8da87c471a92bc778ab75f1","size":9351,"noattachment":false,"key":"/@jsdevtools/file-path-filter/-/@jsdevtools/file-path-filter-3.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@jsdevtools/file-path-filter/download/@jsdevtools/file-path-filter-3.0.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_3.0.2_1594907718663_0.8394552025809052"},"_hasShrinkwrap":false,"publish_time":1594907718752,"_cnpm_publish_time":1594907718752},"3.0.1":{"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":{"shasum":"7fa96b4c0d41a2ec6231584a9f90f4e9442d24eb","size":9232,"noattachment":false,"key":"/@jsdevtools/file-path-filter/-/@jsdevtools/file-path-filter-3.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@jsdevtools/file-path-filter/download/@jsdevtools/file-path-filter-3.0.1.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_3.0.1_1584284180749_0.2255803200118136"},"_hasShrinkwrap":false,"publish_time":1584284180873,"_cnpm_publish_time":1584284180873},"3.0.0":{"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":{"shasum":"682a47369a595815f081aa3d7e8c1fae42ce2e29","size":9030,"noattachment":false,"key":"/@jsdevtools/file-path-filter/-/@jsdevtools/file-path-filter-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@jsdevtools/file-path-filter/download/@jsdevtools/file-path-filter-3.0.0.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_3.0.0_1581864267210_0.29890728960286284"},"_hasShrinkwrap":false,"publish_time":1581864267312,"_cnpm_publish_time":1581864267312},"2.2.2":{"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":{"shasum":"fd0baecac30eb057d67a06b53fbef220f21ae48d","size":8942,"noattachment":false,"key":"/@jsdevtools/file-path-filter/-/@jsdevtools/file-path-filter-2.2.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@jsdevtools/file-path-filter/download/@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,"publish_time":1581863559309,"_cnpm_publish_time":1581863559309}},"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","_attachments":{},"homepage":"https://jstools.dev/file-path-filter","bugs":{"url":"https://github.com/JS-DevTools/file-path-filter/issues"},"license":"MIT"}