| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/readjs/node_modules/expand-braces/node_modules/braces/ |
Upload File : |
/*!
* braces <https://github.com/jonschlinkert/braces>
*
* Copyright (c) 2014 Jon Schlinkert, contributors.
* Licensed under the MIT license.
*/
'use strict';
/**
* Module dependencies
*/
var expand = require('expand-range');
/**
* Expose `braces`
*/
module.exports = function (str, fn) {
return braces(str, fn);
};
/**
* Expand `{foo,bar}` or `{1..5}` braces in the
* give `string`.
*
* @param {String} `str`
* @param {Array} `arr`
* @return {Array}
*/
function braces(str, arr, fn) {
var match = regex().exec(str);
if (match == null) {
return [str];
}
if (typeof str !== 'string') {
throw new Error('braces expects a string');
}
if (typeof arr === 'function') {
fn = arr;
arr = [];
}
arr = arr || [];
var paths;
if (/\.{2}/.test(match[2])) {
paths = expand(match[2], fn);
} else {
paths = match[2].split(',');
}
var len = paths.length;
var i = 0, val, idx;
while (len--) {
val = splice(str, match[1], paths[i++]);
idx = val.indexOf('{');
if (idx !== -1) {
if (val.indexOf('}', idx + 2) === -1) {
var msg = '[brace expansion] imbalanced brace in: ';
throw new Error(msg + str);
}
arr = braces(val, arr);
} else if (arr.indexOf(val) === -1) {
arr.push(val);
}
}
return arr;
}
/**
* Braces regex.
*/
function regex() {
return /.*(\{([^\\}]*)\})/g;
}
/**
* Faster alternative to `String.replace()`
*/
function splice(str, token, replacement) {
var i = str.indexOf(token);
var end = i + token.length;
return str.substr(0, i)
+ replacement
+ str.substr(end, str.length);
}