CoolFace
Apppublic

opusdev/vector-similarity-api

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes
README.md138 linesDownload Raw Back to glob-parent
1<p align="center">2  <a href="https://gulpjs.com">3    <img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">4  </a>5</p>6 7# glob-parent8 9[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Azure Pipelines Build Status][azure-pipelines-image]][azure-pipelines-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]10 11Extract the non-magic parent path from a glob string.12 13## Usage14 15```js16var globParent = require('glob-parent');17 18globParent('path/to/*.js'); // 'path/to'19globParent('/root/path/to/*.js'); // '/root/path/to'20globParent('/*.js'); // '/'21globParent('*.js'); // '.'22globParent('**/*.js'); // '.'23globParent('path/{to,from}'); // 'path'24globParent('path/!(to|from)'); // 'path'25globParent('path/?(to|from)'); // 'path'26globParent('path/+(to|from)'); // 'path'27globParent('path/*(to|from)'); // 'path'28globParent('path/@(to|from)'); // 'path'29globParent('path/**/*'); // 'path'30 31// if provided a non-glob path, returns the nearest dir32globParent('path/foo/bar.js'); // 'path/foo'33globParent('path/foo/'); // 'path/foo'34globParent('path/foo'); // 'path' (see issue #3 for details)35```36 37## API38 39### `globParent(maybeGlobString, [options])`40 41Takes a string and returns the part of the path before the glob begins. Be aware of Escaping rules and Limitations below.42 43#### options44 45```js46{47  // Disables the automatic conversion of slashes for Windows48  flipBackslashes: true49}50```51 52## Escaping53 54The following characters have special significance in glob patterns and must be escaped if you want them to be treated as regular path characters:55 56- `?` (question mark) unless used as a path segment alone57- `*` (asterisk)58- `|` (pipe)59- `(` (opening parenthesis)60- `)` (closing parenthesis)61- `{` (opening curly brace)62- `}` (closing curly brace)63- `[` (opening bracket)64- `]` (closing bracket)65 66**Example**67 68```js69globParent('foo/[bar]/') // 'foo'70globParent('foo/\\[bar]/') // 'foo/[bar]'71```72 73## Limitations74 75### Braces & Brackets76This library attempts a quick and imperfect method of determining which path77parts have glob magic without fully parsing/lexing the pattern. There are some78advanced use cases that can trip it up, such as nested braces where the outer79pair is escaped and the inner one contains a path separator. If you find80yourself in the unlikely circumstance of being affected by this or need to81ensure higher-fidelity glob handling in your library, it is recommended that you82pre-process your input with [expand-braces] and/or [expand-brackets].83 84### Windows85Backslashes are not valid path separators for globs. If a path with backslashes86is provided anyway, for simple cases, glob-parent will replace the path87separator for you and return the non-glob parent path (now with88forward-slashes, which are still valid as Windows path separators).89 90This cannot be used in conjunction with escape characters.91 92```js93// BAD94globParent('C:\\Program Files \\(x86\\)\\*.ext') // 'C:/Program Files /(x86/)'95 96// GOOD97globParent('C:/Program Files\\(x86\\)/*.ext') // 'C:/Program Files (x86)'98```99 100If you are using escape characters for a pattern without path parts (i.e.101relative to `cwd`), prefix with `./` to avoid confusing glob-parent.102 103```js104// BAD105globParent('foo \\[bar]') // 'foo '106globParent('foo \\[bar]*') // 'foo '107 108// GOOD109globParent('./foo \\[bar]') // 'foo [bar]'110globParent('./foo \\[bar]*') // '.'111```112 113## License114 115ISC116 117[expand-braces]: https://github.com/jonschlinkert/expand-braces118[expand-brackets]: https://github.com/jonschlinkert/expand-brackets119 120[downloads-image]: https://img.shields.io/npm/dm/glob-parent.svg121[npm-url]: https://www.npmjs.com/package/glob-parent122[npm-image]: https://img.shields.io/npm/v/glob-parent.svg123 124[azure-pipelines-url]: https://dev.azure.com/gulpjs/gulp/_build/latest?definitionId=2&branchName=master125[azure-pipelines-image]: https://dev.azure.com/gulpjs/gulp/_apis/build/status/glob-parent?branchName=master126 127[travis-url]: https://travis-ci.org/gulpjs/glob-parent128[travis-image]: https://img.shields.io/travis/gulpjs/glob-parent.svg?label=travis-ci129 130[appveyor-url]: https://ci.appveyor.com/project/gulpjs/glob-parent131[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/glob-parent.svg?label=appveyor132 133[coveralls-url]: https://coveralls.io/r/gulpjs/glob-parent134[coveralls-image]: https://img.shields.io/coveralls/gulpjs/glob-parent/master.svg135 136[gitter-url]: https://gitter.im/gulpjs/gulp137[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg138