source: trip-planner-front/node_modules/extglob/lib/extglob.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.7 KB
RevLine 
[6a3a178]1'use strict';
2
3/**
4 * Module dependencies
5 */
6
7var Snapdragon = require('snapdragon');
8var define = require('define-property');
9var extend = require('extend-shallow');
10
11/**
12 * Local dependencies
13 */
14
15var compilers = require('./compilers');
16var parsers = require('./parsers');
17
18/**
19 * Customize Snapdragon parser and renderer
20 */
21
22function Extglob(options) {
23 this.options = extend({source: 'extglob'}, options);
24 this.snapdragon = this.options.snapdragon || new Snapdragon(this.options);
25 this.snapdragon.patterns = this.snapdragon.patterns || {};
26 this.compiler = this.snapdragon.compiler;
27 this.parser = this.snapdragon.parser;
28
29 compilers(this.snapdragon);
30 parsers(this.snapdragon);
31
32 /**
33 * Override Snapdragon `.parse` method
34 */
35
36 define(this.snapdragon, 'parse', function(str, options) {
37 var parsed = Snapdragon.prototype.parse.apply(this, arguments);
38 parsed.input = str;
39
40 // escape unmatched brace/bracket/parens
41 var last = this.parser.stack.pop();
42 if (last && this.options.strict !== true) {
43 var node = last.nodes[0];
44 node.val = '\\' + node.val;
45 var sibling = node.parent.nodes[1];
46 if (sibling.type === 'star') {
47 sibling.loose = true;
48 }
49 }
50
51 // add non-enumerable parser reference
52 define(parsed, 'parser', this.parser);
53 return parsed;
54 });
55
56 /**
57 * Decorate `.parse` method
58 */
59
60 define(this, 'parse', function(ast, options) {
61 return this.snapdragon.parse.apply(this.snapdragon, arguments);
62 });
63
64 /**
65 * Decorate `.compile` method
66 */
67
68 define(this, 'compile', function(ast, options) {
69 return this.snapdragon.compile.apply(this.snapdragon, arguments);
70 });
71
72}
73
74/**
75 * Expose `Extglob`
76 */
77
78module.exports = Extglob;
Note: See TracBrowser for help on using the repository browser.