0.1.2 • Published 5 years ago

globrex v0.1.2

Weekly downloads
409,287
License
MIT
Repository
github
Last release
5 years ago

Install

npm install globrex --save

Core Features

  • 💪 extended globbing: transform advance ExtGlob features
  • 📦 simple: no dependencies
  • 🛣️ paths: split paths into multiple RegExp segments

Usage

const globrex = require('globrex');

const result = globrex('p*uck')
// => { regex: /^p.*uck$/, string: '^p.*uck$', segments: [ /^p.*uck$/ ] }

result.regex.test('pluck'); // true

API

globrex(glob, options)

Type: function Returns: Object

Transform globs intp regular expressions. Returns object with the following properties:

regex

Type: RegExp

JavaScript RegExp instance.

Note: Read more about how to use RegExp on MDN.

path

This property only exists if the option filepath is true.

Note: filepath is false by default

path.segments

Type: Array

Array of RegExp instances seperated by /. This can be usable when working with file paths or urls.

Example array could be:

[ /^foo$/, /^bar$/, /^([^\/]*)$/, '^baz\\.(md|js|txt)$' ]

path.regex

Type: RegExp

JavaScript RegExp instance build for testign against paths. The regex have different path seperators depending on host OS.

glob

Type: String

Glob string to transform.

options.extended

Type: Boolean Default: false

Enable all advanced features from extglob.

Matching so called "extended" globs pattern like single character matching, matching ranges of characters, group matching, etc.

Note: Interprets [a-d] as [abcd]. To match a literal -, include it as first or last character.

options.globstar

Type: Boolean Default: false

When globstar is false globs like '/foo/*' are transformed to the following '^\/foo\/.*$' which will match any string beginning with '/foo/'.

When the globstar option is true, the same '/foo/*' glob is transformed to '^\/foo\/[^/]*$' which will match any string beginning with '/foo/' that does not have a '/' to the right of it. '/foo/*' will match: '/foo/bar', '/foo/bar.txt' but not '/foo/bar/baz' or '/foo/bar/baz.txt'.

Note: When globstar is true, '/foo/**' is equivelant to '/foo/*' when globstar is false.

options.strict

Type: Boolean Default: false

Be forgiving about mutiple slashes, like /// and make everything after the first / optional. This is how bash glob works.

options.flags

Type: String Default: ''

RegExp flags (e.g. 'i' ) to pass to the RegExp constructor.

options.filepath

Type: Boolean Default: false

Parse input strings as it was a file path for special path related features. This feature only makes sense if the input is a POSIX path like /foo/bar/hello.js or URLs.

When true the returned object will have an additional path object.

  • segment: Array containing a RegExp object for each path segment.
  • regex: OS specific file path RegExp. Path seperator used is based on the operating system.
  • globstar: Regex string used to test for globstars.

Note: Please only use forward-slashes in file path glob expressions Though windows uses either / or \ as its path separator, only / characters are used by this glob implementation. You must use forward-slashes only in glob expressions. Back-slashes will always be interpreted as escape characters, not path separators.

References

Learn more about advanced globbing here

License

MIT © Terkel Gjervig

annikel-framework-detectcloud-archive-s3gql_din_mod@iobroker-community-adapters/iobroker.device-watcherframework-detecttest-framework-detecttest13-framework-detectannikel-testfd@saaspe/componentsexpand-react-bridge@everything-registry/sub-chunk-1771p149-table@mediakular/svelte-data-gridyatlibwebchewebapp-framework-detectionwrenchnpm-ui-componentstestapatextio-s3-deploytiny-globtest-results-parservitest-tsconfig-pathsvite-jsconfig-pathsultra-runnervite-tsconfig-pathsvite-tsconfig-paths-altvite-tsconfig-paths-silent@haysquare/svelte-multi-select@haysquare/svelte-multiselect@inti-ar/evm-chains@infinitebrahmanuniverse/nolb-glo@hproinformatica/functionsrunnaserws3-aws-deploys3-deployshainashirin-common-packagesmart-globsvelte-component-libsvelte-searchable-selectsushi-sdk-ftm@omneedia/isomorphic-git@maujzs/branch-release@meysam213/react-leaflet@jretts/modified-sveltejs@manoelmotoso/eslint-config@leiyulf/gantt-task-react@percent/percent-api-hookszzzxxxyyy321123@neuraiproject/chains@pundle/api@pundle/chunk-generator-html@nxext/vite@qandq/plugins-common@projectbabelfish/defikingdoms-sdkex-ikon-components-library@velocitycubed/static-web-apps-cli@traitsniper/web3-react-connector@traitsniper/web3-react-v6-connector@transferwise/cookie-consent-js@torswap/tor-token-lists@summonlabs/use-ada-handle-resolver@massivepixel/use-query@humanity.cash/typesdskcorenew@thinkincoin-libs/token-lists@sleepfinance/chaindts-buddyes-react-bridge@tamedjs/tm-sync@kommunicate/kommunicate-chatbot-plugin@aristidenf/streak-counteraemsync@at0lttr/static-web-apps-cli@yak-spirit/yak-swap-ui@yalam/operators@xswap/token-lists@alexkeating/vite-plugin@alexkeating/vite-lugin@zh0st/evm-chainsannikel-framework-detect2@azure/static-web-apps-cli@azure/web-apps-framework-detection@donapot/mylibtestimport-adjutor@cryptocode99/token-listsnumhandlercotrader-dex-sdkp147-tablep148-tablebackend-testing-core@bundless/plugin-tsconfig-paths@behzadebrhm/utilsframework-detect-packagearacnecfb-cms-demoip-designjsctags-oasisperformance-results-parser
0.1.2

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago