{"id":16007536,"url":"https://github.com/redkenrok/node-planckmatch","last_synced_at":"2025-04-05T02:15:16.990Z","repository":{"id":49639009,"uuid":"148914608","full_name":"RedKenrok/node-planckmatch","owner":"RedKenrok","description":"Small and simple matching library using glob patterns.","archived":false,"fork":false,"pushed_at":"2021-06-11T16:21:19.000Z","size":605,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T11:58:03.712Z","etag":null,"topics":["glob-pattern","match","matching","regular-expression"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RedKenrok.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-15T15:30:44.000Z","updated_at":"2022-07-26T17:45:23.000Z","dependencies_parsed_at":"2022-08-01T01:48:51.376Z","dependency_job_id":null,"html_url":"https://github.com/RedKenrok/node-planckmatch","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedKenrok%2Fnode-planckmatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedKenrok%2Fnode-planckmatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedKenrok%2Fnode-planckmatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RedKenrok%2Fnode-planckmatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RedKenrok","download_url":"https://codeload.github.com/RedKenrok/node-planckmatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276188,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["glob-pattern","match","matching","regular-expression"],"created_at":"2024-10-08T12:03:54.282Z","updated_at":"2025-04-05T02:15:16.971Z","avatar_url":"https://github.com/RedKenrok.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \n  [![npm package @latest](https://img.shields.io/npm/v/planckmatch.svg?label=npm@latest\u0026style=flat-square\u0026maxAge=3600)](https://npmjs.com/package/planckmatch)\n  [![npm package @next](https://img.shields.io/npm/v/planckmatch/next.svg?label=npm@next\u0026style=flat-square\u0026maxAge=3600)](https://npmjs.com/package/planckmatch)\n  \n  [![Travis-ci build master branch](https://img.shields.io/travis-ci/RedKenrok/node-planckmatch.svg?label=test%20status\u0026branch=master\u0026style=flat-square\u0026maxAge=3600)](https://travis-ci.org/RedKenrok/node-planckmatch)\n  [![CodeCov coverage master branch](https://img.shields.io/codecov/c/github/redkenrok/node-planckmatch/master.svg?label=test%20coverage\u0026style=flat-square\u0026maxAge=3600)](https://codecov.io/gh/RedKenrok/node-planckmatch)\n  \n  [![License agreement](https://img.shields.io/github/license/redkenrok/node-planckmatch.svg?style=flat-square\u0026maxAge=86400)](https://github.com/redkenrok/node-planckmatch/blob/master/LICENSE)\n  [![Open issues on GitHub](https://img.shields.io/github/issues/redkenrok/node-planckmatch.svg?style=flat-square\u0026maxAge=86400)](https://github.com/redkenrok/node-planckmatch/issues)\n  \n\u003c/div\u003e\n\n# Planckmatch\n\nSmall and simple matching library using glob patterns.\n\n## Install\n\n```\n$ npm install planckmatch\n```\n\n## Functions\n\n**planckmatch(value, patterns, options, path)**\n\nMatches extended glob patterns with a given value.\n\nReturns: `Boolean` or `Array of Booleans`\n\n* `value`: A value to match to.\n  * Type: `String` or `Array of strings`\n  * Required: `true`\n* `patterns`: An extended glob pattern or array of extended glob patterns.\n  * Type: `String` or `Array of strings`\n  * Required: `true`\n* `options`: [Options](#options) for conversion of glob pattern to regular expression.\n  * Type: `Object`\n  * Default: `{}`\n* `path`: Whether to use platform specific path separators in the expression. For instance when set to true, `path/to/file` will be treated as `path/to/file` on Unix and as `path\\\\to\\\\file` on Windows.\n  * Type: `Boolean`\n  * Default: `false`\n\n**planckmatch.all(value, patterns, options, path)**\n\nSame as `planckmatch(value, patterns, options, path)` except it always returns a single boolean with whether all of the patterns matched.\n\nReturns: `Boolean`\n\n**planckmatch.any(value, patterns, options, path)**\n\nSame as `planckmatch(value, patterns, options, path)` except it always returns a single boolean with whether any of the patterns matched.\n\nReturns: `Boolean`\n\n**planckmatch.parse(patterns, options, path)**\n\nParses extended glob patterns into regular expressions.\n\nReturns: `RegExp` or `Array of RegExps`\n\n* `patterns`: An extended glob pattern or array of extended glob patterns.\n  * Type: `String` or `Array of strings`\n  * Required: `true`\n* `options`: [Options](#options) for conversion of glob pattern to regular expression.\n  * Type: `Object`\n  * Default: `{}`\n* `path`: Whether to use platform specific path separators in the expression. For instance when set to true, `path/to/file` will be treated as `path/to/file` on Unix and as `path\\\\to\\\\file` on Windows.\n  * Type: `Boolean`\n  * Default: `false`\n\n**planckmatch.match(value, expressions)**\n\nMatches regular expressions with a given value.\n\nReturns: `Boolean` or `Array of Booleans`\n\n* `value`: A value to match to.\n  * Type: `String` or `Array of strings`\n  * Required: `true`\n* `expressions`: A RegExp or array of RegExp used to match with.\n  * Type: `RegExp` or `Array of RegExps`\n  * Required: `true`\n\n**planckmatch.match.all(value, expressions)**\n\nSame as `planckmatch.match(value, expressions)` except it always returns a single boolean with whether all of the patterns matched.\n\nReturns: `Boolean`\n\n**planckmatch.match.any(value, expressions)**\n\nSame as `planckmatch.match(value, expressions)` except it always returns a single boolean with whether any of the patterns matched.\n\nReturns: `Boolean`\n\n## Options\n\nOptions for conversion of glob pattern to regular expression.\n\n* `options.extended`: Enable all advanced features from `extglob`.\n  * Type: `Boolean`\n  * Default: `false`\n* `options.flags`: RegExp flags (e.g. `'i'` ) to pass to the RegExp constructor.\n  * Type: `String`\n  * Default: `''`\n* `options.globstar`: If `false` the pattern `'path/*'` will match any string beginning with `'path/'`, for example it will match `'path/file.txt'` and `'path/to/file.txt'`. If `true` the same `'path/*'` will match any string beginning with `'path/'` that does not have a `'/'` to the right of it, for example it will match `'path/file.txt'` but not `'path/to/file.txt'`. If `true` the pattern `'path/**'` will match any string beginning with `'path/'`, which is equal to the `'path/*'` with globstar set to false.\n  * Type: `Boolean`\n  * Default: `false`\n* `options.strict`: Be forgiving about multiple slashes, such as `///` and make everything after the first `/` optional. Like how bash glob works.\n  * Type: `Boolean`\n  * Default: `false`\n\n## Usage\n\nThe most basic example using a single path and pattern.\n\n```JavaScript\nconst planckmatch = require(`planckmatch`);\n\nplanckmatch(`path/to/file.css`, `**/*.css`); // true\nplanckmatch(`path/to/file.css`, `**/*.js`); // false\n```\n\n**Multiple patterns**\n\nThe pattern can also be an array, therefor the returned results will also be an array of equal length.\n\n```JavaScript\nconst planckmatch = require(`planckmatch`);\n\nplanckmatch(`path/to/file.css`, [\n  `*.css`,\n  `*.js`\n]); // [ true, false ]\n```\n\n**Re-use patterns**\n\nIf you re-use patterns I highly recommend parsing the patterns and matching the values direct instead of using the all-in-one function for it, as it parses the patterns each time.\n\n```JavaScript\nconst planckmatch = require(`planckmatch`);\n\nconst expression = planckmatch.parse(`*.css`);\n\nplanckmatch.match(`path/to/file.css`, expression); // true\nplanckmatch.match(`path/to/file.js`, expression); // false\n```\n\n**Match all**\n\nCheck if all patterns match.\n\n```JavaScript\nconst planckmatch = require(`planckmatch`);\n\nplanckmatch.all(`path/to/file.css`, [ `*.html`, `*/to/*` ]); // false, since `*.html` does not match.\nplanckmatch.all(`path/to/file.css`, [ `*.css`, `*/to/*` ]); // true, since all patterns match.\n```\n\n**Match any**\n\nCheck if any pattern matches.\n\n```JavaScript\nconst planckmatch = require(`planckmatch`);\n\nplanckmatch.any(`path/to/file.css`, [ `*.html`, `to/*` ]); // false, since no pattern matches.\nplanckmatch.any(`path/to/file.css`, [ `*.css`, `to/*` ]); // true, since the first pattern matches.\nplanckmatch.any(`path/to/file.css`, [ `*.css`, `*/to/*` ]); // true, since both patterns match.\n```\n\n**Filter array**\n\nUse the module to filter an array.\n\n```JavaScript\nconst planckmatch = require(`planckmatch`);\n\nlet expressions = planckmatch.parse([\n  `a.*`,\n  `*.html`\n]);\n\n// Match all.\n[ `a.css`, `b.html`, `c.js` ].filter(function(value) {\n  return planckmatch.match.all(value, expressions);\n}); // []\n\n// Match any.\n[ `a.css`, `b.html`, `c.js` ].filter(function(value) {\n  return planckmatch.match.any(value, expressions);\n}); // [ `a.css`, `b.html` ]\n\n// Filter out any '.css' files.\nexpressions = planckmatch.parse([\n  `*`,\n  `!(*.css)`\n], { extended: true });\n\n[ `a.css`, `b.html`, `c.js` ].filter(function(value) {\n  return planckmatch.match.all(value, expressions);\n}); // [ `b.html`, `c.js` ]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredkenrok%2Fnode-planckmatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredkenrok%2Fnode-planckmatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredkenrok%2Fnode-planckmatch/lists"}