node_modules/expand-brackets/README.md

expand-brackets NPM version NPM monthly downloads NPM total downloads Linux Build Status Windows Build Status

Expand POSIX bracket expressions (character classes) in glob patterns.

Install

Install with npm:

$ npm install --save expand-brackets

Usage

var brackets = require('expand-brackets');
brackets(string[, options]);

Params

The main export is a function that takes the following parameters:

Example

console.log(brackets('[![:lower:]]'));
//=> '[^a-z]'

API

brackets

Parses the given POSIX character class pattern and returns a string that can be used for creating regular expressions for matching.

Params

.match

Takes an array of strings and a POSIX character class pattern, and returns a new array with only the strings that matched the pattern.

Example

var brackets = require('expand-brackets');
console.log(brackets.match(['1', 'a', 'ab'], '[[:alpha:]]'));
//=> ['a']

console.log(brackets.match(['1', 'a', 'ab'], '[[:alpha:]]+'));
//=> ['a', 'ab']

Params

.isMatch

Returns true if the specified string matches the given brackets pattern.

Example

var brackets = require('expand-brackets');

console.log(brackets.isMatch('a.a', '[[:alpha:]].[[:alpha:]]'));
//=> true
console.log(brackets.isMatch('1.2', '[[:alpha:]].[[:alpha:]]'));
//=> false

Params

.matcher

Takes a POSIX character class pattern and returns a matcher function. The returned function takes the string to match as its only argument.

Example

var brackets = require('expand-brackets');
var isMatch = brackets.matcher('[[:lower:]].[[:upper:]]');

console.log(isMatch('a.a'));
//=> false
console.log(isMatch('a.A'));
//=> true

Params

.makeRe

Create a regular expression from the given pattern.

Example

var brackets = require('expand-brackets');
var re = brackets.makeRe('[[:alpha:]]');
console.log(re);
//=> /^(?:[a-zA-Z])$/

Params

.create

Parses the given POSIX character class pattern and returns an object with the compiled output and optional source map.

Example

var brackets = require('expand-brackets');
console.log(brackets('[[:alpha:]]'));
// { options: { source: 'string' },
//   input: '[[:alpha:]]',
//   state: {},
//   compilers:
//    { eos: [Function],
//      noop: [Function],
//      bos: [Function],
//      not: [Function],
//      escape: [Function],
//      text: [Function],
//      posix: [Function],
//      bracket: [Function],
//      'bracket.open': [Function],
//      'bracket.inner': [Function],
//      'bracket.literal': [Function],
//      'bracket.close': [Function] },
//   output: '[a-zA-Z]',
//   ast:
//    { type: 'root',
//      errors: [],
//      nodes: [ [Object], [Object], [Object] ] },
//   parsingErrors: [] }

Params

Options

options.sourcemap

Generate a source map for the given pattern.

Example

var res = brackets('[:alpha:]', {sourcemap: true});

console.log(res.map);
// { version: 3,
//   sources: [ 'brackets' ],
//   names: [],
//   mappings: 'AAAA,MAAS',
//   sourcesContent: [ '[:alpha:]' ] }

POSIX Character classes

The following named POSIX bracket expressions are supported:

See posix-character-classes for more details.

Not supported

Changelog

v2.0.0

Breaking changes

Added features

v0.2.0

In addition to performance and matching improvements, the v0.2.0 refactor adds complete POSIX character class support, with the exception of equivalence classes and POSIX.2 collating symbols which are not relevant to node.js usage.

Added features

source map example

var brackets = require('expand-brackets');
var res = brackets('[:alpha:]');
console.log(res.map);

{ version: 3,
     sources: [ 'brackets' ],
     names: [],
     mappings: 'AAAA,MAAS',
     sourcesContent: [ '[:alpha:]' ] }

About

Related projects

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Contributors

| Commits | Contributor | | --- | --- | | 66 | jonschlinkert | | 2 | MartinKolarik | | 2 | es128 | | 1 | eush77 |

Building docs

(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)

To generate the readme and API documentation with verb:

$ npm install -g verb verb-generate-readme && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.

This file was generated by verb-generate-readme, v0.2.0, on December 12, 2016.



thisisnic/starrating documentation built on May 18, 2019, 1:32 p.m.