Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
glob-possible-parent
Advanced tools
Find out if a path can be a parent of a file you are looking for
Find out if a path can be a parent of a file you are looking for.
$ npm install glob-possible-parent
This library can be used with a glob matching library (micromatch, minimatch, etc.) to create a matcher that will match not only the given pattern, but also any parent directories. This can be used to optimize glob implementation, and prevent unnecessary disk access, by immediately ruling out directories which can't contain any matching files.
var gpp = require('glob-possible-parent');
var micromatch = require('micromatch'); // you can use any matcher implementation here
// 1. use gpp() to transform the original pattern into an array of patterns which can be passed to the matching library
// 2. create a RegExp from each pattern
// 3. join all created RegExps
var gppRegExp = new RegExp('^(?:\\/$|(?:' + gpp('src/js/**/*.js').map(function (pattern) {
return micromatch.makeRe(pattern, { dot: true }).toString().slice(1, -1);
}).join('|') + '))$');
console.log(gppRegExp.test('src')); // => true
console.log(gppRegExp.test('src/js')); // => true
console.log(gppRegExp.test('src/js/x.js')); // => true
console.log(gppRegExp.test('src/css')); // => false
Copyright (c) 2016 Martin Kolárik. Released under the MIT license.
FAQs
Find out if a path can be a parent of a file you are looking for
The npm package glob-possible-parent receives a total of 1 weekly downloads. As such, glob-possible-parent popularity was classified as not popular.
We found that glob-possible-parent demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.