Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/compat-transpiler/runtime/index.js +123 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-dotall-s-transform.js +69 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-named-capturing-groups-transform.js +59 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-x-flag-transform.js +23 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/compat-transpiler/transforms/index.js +17 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/char-class-to-meta-transform.js +197 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/char-class-to-single-char-transform.js +98 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/char-code-to-simple-char-transform.js +84 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/char-escape-unescape-transform.js +150 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/char-surrogate-pair-to-single-unicode-transform.js +27 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/combine-repeating-patterns-transform.js +194 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/disjunction-remove-duplicates-transform.js +44 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/group-single-chars-to-char-class.js +96 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/index.js +55 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/quantifier-range-to-symbol-transform.js +74 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/quantifiers-merge-transform.js +113 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/remove-empty-group-transform.js +34 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/ungroup-transform.js +86 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/parser/generated/regexp-tree.js +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/parser/unicode/parser-unicode-properties.js +379 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp.prototype.flags/test/builtin.js +46 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp.prototype.flags/test/implementation.js +20 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp.prototype.flags/test/index.js +17 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp.prototype.flags/test/shimmed.js +48 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/regexp.prototype.flags/test/tests.js +143 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve-pkg-maps/dist/index.cjs +1 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve-pkg-maps/dist/index.d.cts +11 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve-pkg-maps/dist/index.d.mts +11 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve-pkg-maps/dist/index.mjs +1 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/.github/FUNDING.yml +12 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/bin/resolve +50 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/example/async.js +5 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/example/sync.js +3 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/async.js +349 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/caller.js +8 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/homedir.js +24 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/node-modules-paths.js +42 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/normalize-options.js +10 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/sync.js +221 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/dotdot.js +29 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/dotdot/abc/index.js +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/dotdot/index.js +0 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/faulty_basedir.js +29 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/filter.js +37 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/filter_sync.js +33 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/home_paths.js +127 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/home_paths_sync.js +114 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/mock.js +315 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/mock_sync.js +215 -0
- novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/module_dir.js +56 -0
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/compat-transpiler/runtime/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* The `RegExpTree` class provides runtime support for `compat-transpiler`
|
| 10 |
+
* module from `regexp-tree`.
|
| 11 |
+
*
|
| 12 |
+
* E.g. it tracks names of the capturing groups, in order to access the
|
| 13 |
+
* names on the matched result.
|
| 14 |
+
*
|
| 15 |
+
* It's a thin-wrapper on top of original regexp.
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
| 19 |
+
|
| 20 |
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
| 21 |
+
|
| 22 |
+
var RegExpTree = function () {
|
| 23 |
+
/**
|
| 24 |
+
* Initializes a `RegExpTree` instance.
|
| 25 |
+
*
|
| 26 |
+
* @param RegExp - a regular expression
|
| 27 |
+
*
|
| 28 |
+
* @param Object state:
|
| 29 |
+
*
|
| 30 |
+
* An extra state which may store any related to transformation
|
| 31 |
+
* data, for example, names of the groups.
|
| 32 |
+
*
|
| 33 |
+
* - flags - original flags
|
| 34 |
+
* - groups - names of the groups, and their indices
|
| 35 |
+
* - source - original source
|
| 36 |
+
*/
|
| 37 |
+
function RegExpTree(re, _ref) {
|
| 38 |
+
var flags = _ref.flags,
|
| 39 |
+
groups = _ref.groups,
|
| 40 |
+
source = _ref.source;
|
| 41 |
+
|
| 42 |
+
_classCallCheck(this, RegExpTree);
|
| 43 |
+
|
| 44 |
+
this._re = re;
|
| 45 |
+
this._groups = groups;
|
| 46 |
+
|
| 47 |
+
// Original props.
|
| 48 |
+
this.flags = flags;
|
| 49 |
+
this.source = source || re.source;
|
| 50 |
+
this.dotAll = flags.includes('s');
|
| 51 |
+
|
| 52 |
+
// Inherited directly from `re`.
|
| 53 |
+
this.global = re.global;
|
| 54 |
+
this.ignoreCase = re.ignoreCase;
|
| 55 |
+
this.multiline = re.multiline;
|
| 56 |
+
this.sticky = re.sticky;
|
| 57 |
+
this.unicode = re.unicode;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* Facade wrapper for RegExp `test` method.
|
| 62 |
+
*/
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
_createClass(RegExpTree, [{
|
| 66 |
+
key: 'test',
|
| 67 |
+
value: function test(string) {
|
| 68 |
+
return this._re.test(string);
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* Facade wrapper for RegExp `compile` method.
|
| 73 |
+
*/
|
| 74 |
+
|
| 75 |
+
}, {
|
| 76 |
+
key: 'compile',
|
| 77 |
+
value: function compile(string) {
|
| 78 |
+
return this._re.compile(string);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* Facade wrapper for RegExp `toString` method.
|
| 83 |
+
*/
|
| 84 |
+
|
| 85 |
+
}, {
|
| 86 |
+
key: 'toString',
|
| 87 |
+
value: function toString() {
|
| 88 |
+
if (!this._toStringResult) {
|
| 89 |
+
this._toStringResult = '/' + this.source + '/' + this.flags;
|
| 90 |
+
}
|
| 91 |
+
return this._toStringResult;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* Facade wrapper for RegExp `exec` method.
|
| 96 |
+
*/
|
| 97 |
+
|
| 98 |
+
}, {
|
| 99 |
+
key: 'exec',
|
| 100 |
+
value: function exec(string) {
|
| 101 |
+
var result = this._re.exec(string);
|
| 102 |
+
|
| 103 |
+
if (!this._groups || !result) {
|
| 104 |
+
return result;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
result.groups = {};
|
| 108 |
+
|
| 109 |
+
for (var group in this._groups) {
|
| 110 |
+
var groupNumber = this._groups[group];
|
| 111 |
+
result.groups[group] = result[groupNumber];
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
return result;
|
| 115 |
+
}
|
| 116 |
+
}]);
|
| 117 |
+
|
| 118 |
+
return RegExpTree;
|
| 119 |
+
}();
|
| 120 |
+
|
| 121 |
+
module.exports = {
|
| 122 |
+
RegExpTree: RegExpTree
|
| 123 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-dotall-s-transform.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to translate `/./s` to `/[\0-\uFFFF]/`.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
module.exports = {
|
| 13 |
+
|
| 14 |
+
// Whether `u` flag present. In which case we transform to
|
| 15 |
+
// \u{10FFFF} instead of \uFFFF.
|
| 16 |
+
_hasUFlag: false,
|
| 17 |
+
|
| 18 |
+
// Only run this plugin if we have `s` flag.
|
| 19 |
+
shouldRun: function shouldRun(ast) {
|
| 20 |
+
var shouldRun = ast.flags.includes('s');
|
| 21 |
+
|
| 22 |
+
if (!shouldRun) {
|
| 23 |
+
return false;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
// Strip the `s` flag.
|
| 27 |
+
ast.flags = ast.flags.replace('s', '');
|
| 28 |
+
|
| 29 |
+
// Whether we have also `u`.
|
| 30 |
+
this._hasUFlag = ast.flags.includes('u');
|
| 31 |
+
|
| 32 |
+
return true;
|
| 33 |
+
},
|
| 34 |
+
Char: function Char(path) {
|
| 35 |
+
var node = path.node;
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
if (node.kind !== 'meta' || node.value !== '.') {
|
| 39 |
+
return;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
var toValue = '\\uFFFF';
|
| 43 |
+
var toSymbol = '\uFFFF';
|
| 44 |
+
|
| 45 |
+
if (this._hasUFlag) {
|
| 46 |
+
toValue = '\\u{10FFFF}';
|
| 47 |
+
toSymbol = '\uDBFF\uDFFF';
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
path.replace({
|
| 51 |
+
type: 'CharacterClass',
|
| 52 |
+
expressions: [{
|
| 53 |
+
type: 'ClassRange',
|
| 54 |
+
from: {
|
| 55 |
+
type: 'Char',
|
| 56 |
+
value: '\\0',
|
| 57 |
+
kind: 'decimal',
|
| 58 |
+
symbol: '\0'
|
| 59 |
+
},
|
| 60 |
+
to: {
|
| 61 |
+
type: 'Char',
|
| 62 |
+
value: toValue,
|
| 63 |
+
kind: 'unicode',
|
| 64 |
+
symbol: toSymbol
|
| 65 |
+
}
|
| 66 |
+
}]
|
| 67 |
+
});
|
| 68 |
+
}
|
| 69 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-named-capturing-groups-transform.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to translate `/(?<name>a)\k<name>/` to `/(a)\1/`.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
module.exports = {
|
| 13 |
+
// To track the names of the groups, and return them
|
| 14 |
+
// in the transform result state.
|
| 15 |
+
//
|
| 16 |
+
// A map from name to number: {foo: 2, bar: 4}
|
| 17 |
+
_groupNames: {},
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* Initialises the trasnform.
|
| 21 |
+
*/
|
| 22 |
+
init: function init() {
|
| 23 |
+
this._groupNames = {};
|
| 24 |
+
},
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Returns extra state, which eventually is returned to
|
| 29 |
+
*/
|
| 30 |
+
getExtra: function getExtra() {
|
| 31 |
+
return this._groupNames;
|
| 32 |
+
},
|
| 33 |
+
Group: function Group(path) {
|
| 34 |
+
var node = path.node;
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
if (!node.name) {
|
| 38 |
+
return;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
// Record group name.
|
| 42 |
+
this._groupNames[node.name] = node.number;
|
| 43 |
+
|
| 44 |
+
delete node.name;
|
| 45 |
+
delete node.nameRaw;
|
| 46 |
+
},
|
| 47 |
+
Backreference: function Backreference(path) {
|
| 48 |
+
var node = path.node;
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
if (node.kind !== 'name') {
|
| 52 |
+
return;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
node.kind = 'number';
|
| 56 |
+
node.reference = node.number;
|
| 57 |
+
delete node.referenceRaw;
|
| 58 |
+
}
|
| 59 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/compat-transpiler/transforms/compat-x-flag-transform.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to remove `x` flag `/foo/x` to `/foo/`.
|
| 10 |
+
*
|
| 11 |
+
* Note: other features of `x` flags (whitespace, comments) are
|
| 12 |
+
* already removed at parsing stage.
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
module.exports = {
|
| 16 |
+
RegExp: function RegExp(_ref) {
|
| 17 |
+
var node = _ref.node;
|
| 18 |
+
|
| 19 |
+
if (node.flags.includes('x')) {
|
| 20 |
+
node.flags = node.flags.replace('x', '');
|
| 21 |
+
}
|
| 22 |
+
}
|
| 23 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/compat-transpiler/transforms/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
module.exports = {
|
| 9 |
+
// "dotAll" `s` flag
|
| 10 |
+
dotAll: require('./compat-dotall-s-transform'),
|
| 11 |
+
|
| 12 |
+
// Named capturing groups.
|
| 13 |
+
namedCapturingGroups: require('./compat-named-capturing-groups-transform'),
|
| 14 |
+
|
| 15 |
+
// `x` flag
|
| 16 |
+
xFlag: require('./compat-x-flag-transform')
|
| 17 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/char-class-to-meta-transform.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to replace standard character classes with
|
| 10 |
+
* their meta symbols equivalents.
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
| 14 |
+
|
| 15 |
+
module.exports = {
|
| 16 |
+
_hasIFlag: false,
|
| 17 |
+
_hasUFlag: false,
|
| 18 |
+
init: function init(ast) {
|
| 19 |
+
this._hasIFlag = ast.flags.includes('i');
|
| 20 |
+
this._hasUFlag = ast.flags.includes('u');
|
| 21 |
+
},
|
| 22 |
+
CharacterClass: function CharacterClass(path) {
|
| 23 |
+
// [0-9] -> \d
|
| 24 |
+
rewriteNumberRanges(path);
|
| 25 |
+
|
| 26 |
+
// [a-zA-Z_0-9] -> \w
|
| 27 |
+
rewriteWordRanges(path, this._hasIFlag, this._hasUFlag);
|
| 28 |
+
|
| 29 |
+
// [ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff] -> \s
|
| 30 |
+
rewriteWhitespaceRanges(path);
|
| 31 |
+
}
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Rewrites number ranges: [0-9] -> \d
|
| 36 |
+
*/
|
| 37 |
+
function rewriteNumberRanges(path) {
|
| 38 |
+
var node = path.node;
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
node.expressions.forEach(function (expression, i) {
|
| 42 |
+
if (isFullNumberRange(expression)) {
|
| 43 |
+
path.getChild(i).replace({
|
| 44 |
+
type: 'Char',
|
| 45 |
+
value: '\\d',
|
| 46 |
+
kind: 'meta'
|
| 47 |
+
});
|
| 48 |
+
}
|
| 49 |
+
});
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
/**
|
| 53 |
+
* Rewrites word ranges: [a-zA-Z_0-9] -> \w
|
| 54 |
+
* Thus, the ranges may go in any order, and other symbols/ranges
|
| 55 |
+
* are kept untouched, e.g. [a-z_\dA-Z$] -> [\w$]
|
| 56 |
+
*/
|
| 57 |
+
function rewriteWordRanges(path, hasIFlag, hasUFlag) {
|
| 58 |
+
var node = path.node;
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
var numberPath = null;
|
| 62 |
+
var lowerCasePath = null;
|
| 63 |
+
var upperCasePath = null;
|
| 64 |
+
var underscorePath = null;
|
| 65 |
+
var u017fPath = null;
|
| 66 |
+
var u212aPath = null;
|
| 67 |
+
|
| 68 |
+
node.expressions.forEach(function (expression, i) {
|
| 69 |
+
// \d
|
| 70 |
+
if (isMetaChar(expression, '\\d')) {
|
| 71 |
+
numberPath = path.getChild(i);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
// a-z
|
| 75 |
+
else if (isLowerCaseRange(expression)) {
|
| 76 |
+
lowerCasePath = path.getChild(i);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
// A-Z
|
| 80 |
+
else if (isUpperCaseRange(expression)) {
|
| 81 |
+
upperCasePath = path.getChild(i);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
// _
|
| 85 |
+
else if (isUnderscore(expression)) {
|
| 86 |
+
underscorePath = path.getChild(i);
|
| 87 |
+
} else if (hasIFlag && hasUFlag && isCodePoint(expression, 0x017f)) {
|
| 88 |
+
u017fPath = path.getChild(i);
|
| 89 |
+
} else if (hasIFlag && hasUFlag && isCodePoint(expression, 0x212a)) {
|
| 90 |
+
u212aPath = path.getChild(i);
|
| 91 |
+
}
|
| 92 |
+
});
|
| 93 |
+
|
| 94 |
+
// If we found the whole pattern, replace it.
|
| 95 |
+
if (numberPath && (lowerCasePath && upperCasePath || hasIFlag && (lowerCasePath || upperCasePath)) && underscorePath && (!hasUFlag || !hasIFlag || u017fPath && u212aPath)) {
|
| 96 |
+
// Put \w in place of \d.
|
| 97 |
+
numberPath.replace({
|
| 98 |
+
type: 'Char',
|
| 99 |
+
value: '\\w',
|
| 100 |
+
kind: 'meta'
|
| 101 |
+
});
|
| 102 |
+
|
| 103 |
+
// Other paths are removed.
|
| 104 |
+
if (lowerCasePath) {
|
| 105 |
+
lowerCasePath.remove();
|
| 106 |
+
}
|
| 107 |
+
if (upperCasePath) {
|
| 108 |
+
upperCasePath.remove();
|
| 109 |
+
}
|
| 110 |
+
underscorePath.remove();
|
| 111 |
+
if (u017fPath) {
|
| 112 |
+
u017fPath.remove();
|
| 113 |
+
}
|
| 114 |
+
if (u212aPath) {
|
| 115 |
+
u212aPath.remove();
|
| 116 |
+
}
|
| 117 |
+
}
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/**
|
| 121 |
+
* Rewrites whitespace ranges: [ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff] -> \s.
|
| 122 |
+
*/
|
| 123 |
+
var whitespaceRangeTests = [function (node) {
|
| 124 |
+
return isChar(node, ' ');
|
| 125 |
+
}].concat(_toConsumableArray(['\\f', '\\n', '\\r', '\\t', '\\v'].map(function (char) {
|
| 126 |
+
return function (node) {
|
| 127 |
+
return isMetaChar(node, char);
|
| 128 |
+
};
|
| 129 |
+
})), _toConsumableArray([0x00a0, 0x1680, 0x2028, 0x2029, 0x202f, 0x205f, 0x3000, 0xfeff].map(function (codePoint) {
|
| 130 |
+
return function (node) {
|
| 131 |
+
return isCodePoint(node, codePoint);
|
| 132 |
+
};
|
| 133 |
+
})), [function (node) {
|
| 134 |
+
return node.type === 'ClassRange' && isCodePoint(node.from, 0x2000) && isCodePoint(node.to, 0x200a);
|
| 135 |
+
}]);
|
| 136 |
+
|
| 137 |
+
function rewriteWhitespaceRanges(path) {
|
| 138 |
+
var node = path.node;
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
if (node.expressions.length < whitespaceRangeTests.length || !whitespaceRangeTests.every(function (test) {
|
| 142 |
+
return node.expressions.some(function (expression) {
|
| 143 |
+
return test(expression);
|
| 144 |
+
});
|
| 145 |
+
})) {
|
| 146 |
+
return;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
// If we found the whole pattern, replace it.
|
| 150 |
+
|
| 151 |
+
// Put \s in place of \n.
|
| 152 |
+
var nNode = node.expressions.find(function (expression) {
|
| 153 |
+
return isMetaChar(expression, '\\n');
|
| 154 |
+
});
|
| 155 |
+
nNode.value = '\\s';
|
| 156 |
+
nNode.symbol = undefined;
|
| 157 |
+
nNode.codePoint = NaN;
|
| 158 |
+
|
| 159 |
+
// Other paths are removed.
|
| 160 |
+
node.expressions.map(function (expression, i) {
|
| 161 |
+
return whitespaceRangeTests.some(function (test) {
|
| 162 |
+
return test(expression);
|
| 163 |
+
}) ? path.getChild(i) : undefined;
|
| 164 |
+
}).filter(Boolean).forEach(function (path) {
|
| 165 |
+
return path.remove();
|
| 166 |
+
});
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
function isFullNumberRange(node) {
|
| 170 |
+
return node.type === 'ClassRange' && node.from.value === '0' && node.to.value === '9';
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
function isChar(node, value) {
|
| 174 |
+
var kind = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'simple';
|
| 175 |
+
|
| 176 |
+
return node.type === 'Char' && node.value === value && node.kind === kind;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
function isMetaChar(node, value) {
|
| 180 |
+
return isChar(node, value, 'meta');
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
function isLowerCaseRange(node) {
|
| 184 |
+
return node.type === 'ClassRange' && node.from.value === 'a' && node.to.value === 'z';
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
function isUpperCaseRange(node) {
|
| 188 |
+
return node.type === 'ClassRange' && node.from.value === 'A' && node.to.value === 'Z';
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
function isUnderscore(node) {
|
| 192 |
+
return node.type === 'Char' && node.value === '_' && node.kind === 'simple';
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
function isCodePoint(node, codePoint) {
|
| 196 |
+
return node.type === 'Char' && node.kind === 'unicode' && node.codePoint === codePoint;
|
| 197 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/char-class-to-single-char-transform.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to replace single char character classes with
|
| 10 |
+
* just that character.
|
| 11 |
+
*
|
| 12 |
+
* [\d] -> \d, [^\w] -> \W
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
module.exports = {
|
| 16 |
+
CharacterClass: function CharacterClass(path) {
|
| 17 |
+
var node = path.node;
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
if (node.expressions.length !== 1 || !hasAppropriateSiblings(path) || !isAppropriateChar(node.expressions[0])) {
|
| 21 |
+
return;
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
var _node$expressions$ = node.expressions[0],
|
| 25 |
+
value = _node$expressions$.value,
|
| 26 |
+
kind = _node$expressions$.kind,
|
| 27 |
+
escaped = _node$expressions$.escaped;
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
if (node.negative) {
|
| 31 |
+
// For negative can extract only meta chars like [^\w] -> \W
|
| 32 |
+
// cannot do for [^a] -> a (wrong).
|
| 33 |
+
if (!isMeta(value)) {
|
| 34 |
+
return;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
value = getInverseMeta(value);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
path.replace({
|
| 41 |
+
type: 'Char',
|
| 42 |
+
value: value,
|
| 43 |
+
kind: kind,
|
| 44 |
+
escaped: escaped || shouldEscape(value)
|
| 45 |
+
});
|
| 46 |
+
}
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
function isAppropriateChar(node) {
|
| 50 |
+
return node.type === 'Char' &&
|
| 51 |
+
// We don't extract [\b] (backspace) since \b has different
|
| 52 |
+
// semantics (word boundary).
|
| 53 |
+
node.value !== '\\b';
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
function isMeta(value) {
|
| 57 |
+
return (/^\\[dwsDWS]$/.test(value)
|
| 58 |
+
);
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
function getInverseMeta(value) {
|
| 62 |
+
return (/[dws]/.test(value) ? value.toUpperCase() : value.toLowerCase()
|
| 63 |
+
);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
function hasAppropriateSiblings(path) {
|
| 67 |
+
var parent = path.parent,
|
| 68 |
+
index = path.index;
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
if (parent.type !== 'Alternative') {
|
| 72 |
+
return true;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
var previousNode = parent.expressions[index - 1];
|
| 76 |
+
if (previousNode == null) {
|
| 77 |
+
return true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// Don't optimized \1[0] to \10
|
| 81 |
+
if (previousNode.type === 'Backreference' && previousNode.kind === 'number') {
|
| 82 |
+
return false;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
// Don't optimized \2[0] to \20
|
| 86 |
+
if (previousNode.type === 'Char' && previousNode.kind === 'decimal') {
|
| 87 |
+
return false;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
return true;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
// Note: \{ and \} are always preserved to avoid `a[{]2[}]` turning
|
| 94 |
+
// into `a{2}`.
|
| 95 |
+
function shouldEscape(value) {
|
| 96 |
+
return (/[*[()+?$./{}|]/.test(value)
|
| 97 |
+
);
|
| 98 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/char-code-to-simple-char-transform.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
var UPPER_A_CP = 'A'.codePointAt(0);
|
| 9 |
+
var UPPER_Z_CP = 'Z'.codePointAt(0);
|
| 10 |
+
var LOWER_A_CP = 'a'.codePointAt(0);
|
| 11 |
+
var LOWER_Z_CP = 'z'.codePointAt(0);
|
| 12 |
+
var DIGIT_0_CP = '0'.codePointAt(0);
|
| 13 |
+
var DIGIT_9_CP = '9'.codePointAt(0);
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* A regexp-tree plugin to transform coded chars into simple chars.
|
| 17 |
+
*
|
| 18 |
+
* \u0061 -> a
|
| 19 |
+
*/
|
| 20 |
+
module.exports = {
|
| 21 |
+
Char: function Char(path) {
|
| 22 |
+
var node = path.node,
|
| 23 |
+
parent = path.parent;
|
| 24 |
+
|
| 25 |
+
if (isNaN(node.codePoint) || node.kind === 'simple') {
|
| 26 |
+
return;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
if (parent.type === 'ClassRange') {
|
| 30 |
+
if (!isSimpleRange(parent)) {
|
| 31 |
+
return;
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
if (!isPrintableASCIIChar(node.codePoint)) {
|
| 36 |
+
return;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
var symbol = String.fromCodePoint(node.codePoint);
|
| 40 |
+
var newChar = {
|
| 41 |
+
type: 'Char',
|
| 42 |
+
kind: 'simple',
|
| 43 |
+
value: symbol,
|
| 44 |
+
symbol: symbol,
|
| 45 |
+
codePoint: node.codePoint
|
| 46 |
+
};
|
| 47 |
+
if (needsEscape(symbol, parent.type)) {
|
| 48 |
+
newChar.escaped = true;
|
| 49 |
+
}
|
| 50 |
+
path.replace(newChar);
|
| 51 |
+
}
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* Checks if a range is included either in 0-9, a-z or A-Z
|
| 56 |
+
* @param classRange
|
| 57 |
+
* @returns {boolean}
|
| 58 |
+
*/
|
| 59 |
+
function isSimpleRange(classRange) {
|
| 60 |
+
var from = classRange.from,
|
| 61 |
+
to = classRange.to;
|
| 62 |
+
|
| 63 |
+
return from.codePoint >= DIGIT_0_CP && from.codePoint <= DIGIT_9_CP && to.codePoint >= DIGIT_0_CP && to.codePoint <= DIGIT_9_CP || from.codePoint >= UPPER_A_CP && from.codePoint <= UPPER_Z_CP && to.codePoint >= UPPER_A_CP && to.codePoint <= UPPER_Z_CP || from.codePoint >= LOWER_A_CP && from.codePoint <= LOWER_Z_CP && to.codePoint >= LOWER_A_CP && to.codePoint <= LOWER_Z_CP;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* Checks if a code point in the range of printable ASCII chars
|
| 68 |
+
* (DEL char excluded)
|
| 69 |
+
* @param codePoint
|
| 70 |
+
* @returns {boolean}
|
| 71 |
+
*/
|
| 72 |
+
function isPrintableASCIIChar(codePoint) {
|
| 73 |
+
return codePoint >= 0x20 && codePoint <= 0x7e;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
function needsEscape(symbol, parentType) {
|
| 77 |
+
if (parentType === 'ClassRange' || parentType === 'CharacterClass') {
|
| 78 |
+
return (/[\]\\^-]/.test(symbol)
|
| 79 |
+
);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
return (/[*[()+?^$./\\|{}]/.test(symbol)
|
| 83 |
+
);
|
| 84 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/char-escape-unescape-transform.js
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to remove unnecessary escape.
|
| 10 |
+
*
|
| 11 |
+
* \e -> e
|
| 12 |
+
*
|
| 13 |
+
* [\(] -> [(]
|
| 14 |
+
*/
|
| 15 |
+
|
| 16 |
+
module.exports = {
|
| 17 |
+
_hasXFlag: false,
|
| 18 |
+
init: function init(ast) {
|
| 19 |
+
this._hasXFlag = ast.flags.includes('x');
|
| 20 |
+
},
|
| 21 |
+
Char: function Char(path) {
|
| 22 |
+
var node = path.node;
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
if (!node.escaped) {
|
| 26 |
+
return;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
if (shouldUnescape(path, this._hasXFlag)) {
|
| 30 |
+
delete node.escaped;
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
};
|
| 34 |
+
|
| 35 |
+
function shouldUnescape(path, hasXFlag) {
|
| 36 |
+
var value = path.node.value,
|
| 37 |
+
index = path.index,
|
| 38 |
+
parent = path.parent;
|
| 39 |
+
|
| 40 |
+
// In char class (, etc are allowed.
|
| 41 |
+
|
| 42 |
+
if (parent.type !== 'CharacterClass' && parent.type !== 'ClassRange') {
|
| 43 |
+
return !preservesEscape(value, index, parent, hasXFlag);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
return !preservesInCharClass(value, index, parent);
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* \], \\, \^, \-
|
| 51 |
+
*/
|
| 52 |
+
function preservesInCharClass(value, index, parent) {
|
| 53 |
+
if (value === '^') {
|
| 54 |
+
// Avoid [\^a] turning into [^a]
|
| 55 |
+
return index === 0 && !parent.negative;
|
| 56 |
+
}
|
| 57 |
+
if (value === '-') {
|
| 58 |
+
// Avoid [a\-z] turning into [a-z]
|
| 59 |
+
return true;
|
| 60 |
+
}
|
| 61 |
+
return (/[\]\\]/.test(value)
|
| 62 |
+
);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
function preservesEscape(value, index, parent, hasXFlag) {
|
| 66 |
+
if (value === '{') {
|
| 67 |
+
return preservesOpeningCurlyBraceEscape(index, parent);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
if (value === '}') {
|
| 71 |
+
return preservesClosingCurlyBraceEscape(index, parent);
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
if (hasXFlag && /[ #]/.test(value)) {
|
| 75 |
+
return true;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
return (/[*[()+?^$./\\|]/.test(value)
|
| 79 |
+
);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
function consumeNumbers(startIndex, parent, rtl) {
|
| 83 |
+
var i = startIndex;
|
| 84 |
+
var siblingNode = (rtl ? i >= 0 : i < parent.expressions.length) && parent.expressions[i];
|
| 85 |
+
|
| 86 |
+
while (siblingNode && siblingNode.type === 'Char' && siblingNode.kind === 'simple' && !siblingNode.escaped && /\d/.test(siblingNode.value)) {
|
| 87 |
+
rtl ? i-- : i++;
|
| 88 |
+
siblingNode = (rtl ? i >= 0 : i < parent.expressions.length) && parent.expressions[i];
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
return Math.abs(startIndex - i);
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
function isSimpleChar(node, value) {
|
| 95 |
+
return node && node.type === 'Char' && node.kind === 'simple' && !node.escaped && node.value === value;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
function preservesOpeningCurlyBraceEscape(index, parent) {
|
| 99 |
+
// (?:\{) -> (?:{)
|
| 100 |
+
if (index == null) {
|
| 101 |
+
return false;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
var nbFollowingNumbers = consumeNumbers(index + 1, parent);
|
| 105 |
+
var i = index + nbFollowingNumbers + 1;
|
| 106 |
+
var nextSiblingNode = i < parent.expressions.length && parent.expressions[i];
|
| 107 |
+
|
| 108 |
+
if (nbFollowingNumbers) {
|
| 109 |
+
// Avoid \{3} turning into {3}
|
| 110 |
+
if (isSimpleChar(nextSiblingNode, '}')) {
|
| 111 |
+
return true;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
if (isSimpleChar(nextSiblingNode, ',')) {
|
| 115 |
+
nbFollowingNumbers = consumeNumbers(i + 1, parent);
|
| 116 |
+
i = i + nbFollowingNumbers + 1;
|
| 117 |
+
nextSiblingNode = i < parent.expressions.length && parent.expressions[i];
|
| 118 |
+
|
| 119 |
+
// Avoid \{3,} turning into {3,}
|
| 120 |
+
return isSimpleChar(nextSiblingNode, '}');
|
| 121 |
+
}
|
| 122 |
+
}
|
| 123 |
+
return false;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
function preservesClosingCurlyBraceEscape(index, parent) {
|
| 127 |
+
// (?:\{) -> (?:{)
|
| 128 |
+
if (index == null) {
|
| 129 |
+
return false;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
var nbPrecedingNumbers = consumeNumbers(index - 1, parent, true);
|
| 133 |
+
var i = index - nbPrecedingNumbers - 1;
|
| 134 |
+
var previousSiblingNode = i >= 0 && parent.expressions[i];
|
| 135 |
+
|
| 136 |
+
// Avoid {3\} turning into {3}
|
| 137 |
+
if (nbPrecedingNumbers && isSimpleChar(previousSiblingNode, '{')) {
|
| 138 |
+
return true;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
if (isSimpleChar(previousSiblingNode, ',')) {
|
| 142 |
+
nbPrecedingNumbers = consumeNumbers(i - 1, parent, true);
|
| 143 |
+
i = i - nbPrecedingNumbers - 1;
|
| 144 |
+
previousSiblingNode = i < parent.expressions.length && parent.expressions[i];
|
| 145 |
+
|
| 146 |
+
// Avoid {3,\} turning into {3,}
|
| 147 |
+
return nbPrecedingNumbers && isSimpleChar(previousSiblingNode, '{');
|
| 148 |
+
}
|
| 149 |
+
return false;
|
| 150 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/char-surrogate-pair-to-single-unicode-transform.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to transform surrogate pairs into single unicode code point
|
| 10 |
+
*
|
| 11 |
+
* \ud83d\ude80 -> \u{1f680}
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
module.exports = {
|
| 15 |
+
shouldRun: function shouldRun(ast) {
|
| 16 |
+
return ast.flags.includes('u');
|
| 17 |
+
},
|
| 18 |
+
Char: function Char(path) {
|
| 19 |
+
var node = path.node;
|
| 20 |
+
|
| 21 |
+
if (node.kind !== 'unicode' || !node.isSurrogatePair || isNaN(node.codePoint)) {
|
| 22 |
+
return;
|
| 23 |
+
}
|
| 24 |
+
node.value = '\\u{' + node.codePoint.toString(16) + '}';
|
| 25 |
+
delete node.isSurrogatePair;
|
| 26 |
+
}
|
| 27 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/combine-repeating-patterns-transform.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
| 9 |
+
|
| 10 |
+
var NodePath = require('../../traverse/node-path');
|
| 11 |
+
|
| 12 |
+
var _require = require('../../transform/utils'),
|
| 13 |
+
increaseQuantifierByOne = _require.increaseQuantifierByOne;
|
| 14 |
+
|
| 15 |
+
/**
|
| 16 |
+
* A regexp-tree plugin to combine repeating patterns.
|
| 17 |
+
*
|
| 18 |
+
* /^abcabcabc/ -> /^abc{3}/
|
| 19 |
+
* /^(?:abc){2}abc/ -> /^(?:abc){3}/
|
| 20 |
+
* /^abc(?:abc){2}/ -> /^(?:abc){3}/
|
| 21 |
+
*/
|
| 22 |
+
|
| 23 |
+
module.exports = {
|
| 24 |
+
Alternative: function Alternative(path) {
|
| 25 |
+
var node = path.node;
|
| 26 |
+
|
| 27 |
+
// We can skip the first child
|
| 28 |
+
|
| 29 |
+
var index = 1;
|
| 30 |
+
while (index < node.expressions.length) {
|
| 31 |
+
var child = path.getChild(index);
|
| 32 |
+
index = Math.max(1, combineRepeatingPatternLeft(path, child, index));
|
| 33 |
+
|
| 34 |
+
if (index >= node.expressions.length) {
|
| 35 |
+
break;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
child = path.getChild(index);
|
| 39 |
+
index = Math.max(1, combineWithPreviousRepetition(path, child, index));
|
| 40 |
+
|
| 41 |
+
if (index >= node.expressions.length) {
|
| 42 |
+
break;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
child = path.getChild(index);
|
| 46 |
+
index = Math.max(1, combineRepetitionWithPrevious(path, child, index));
|
| 47 |
+
|
| 48 |
+
index++;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
};
|
| 52 |
+
|
| 53 |
+
// abcabc -> (?:abc){2}
|
| 54 |
+
function combineRepeatingPatternLeft(alternative, child, index) {
|
| 55 |
+
var node = alternative.node;
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
var nbPossibleLengths = Math.ceil(index / 2);
|
| 59 |
+
var i = 0;
|
| 60 |
+
|
| 61 |
+
while (i < nbPossibleLengths) {
|
| 62 |
+
var startIndex = index - 2 * i - 1;
|
| 63 |
+
var right = void 0,
|
| 64 |
+
left = void 0;
|
| 65 |
+
|
| 66 |
+
if (i === 0) {
|
| 67 |
+
right = child;
|
| 68 |
+
left = alternative.getChild(startIndex);
|
| 69 |
+
} else {
|
| 70 |
+
right = NodePath.getForNode({
|
| 71 |
+
type: 'Alternative',
|
| 72 |
+
expressions: [].concat(_toConsumableArray(node.expressions.slice(index - i, index)), [child.node])
|
| 73 |
+
});
|
| 74 |
+
|
| 75 |
+
left = NodePath.getForNode({
|
| 76 |
+
type: 'Alternative',
|
| 77 |
+
expressions: [].concat(_toConsumableArray(node.expressions.slice(startIndex, index - i)))
|
| 78 |
+
});
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
if (right.hasEqualSource(left)) {
|
| 82 |
+
for (var j = 0; j < 2 * i + 1; j++) {
|
| 83 |
+
alternative.getChild(startIndex).remove();
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
child.replace({
|
| 87 |
+
type: 'Repetition',
|
| 88 |
+
expression: i === 0 && right.node.type !== 'Repetition' ? right.node : {
|
| 89 |
+
type: 'Group',
|
| 90 |
+
capturing: false,
|
| 91 |
+
expression: right.node
|
| 92 |
+
},
|
| 93 |
+
quantifier: {
|
| 94 |
+
type: 'Quantifier',
|
| 95 |
+
kind: 'Range',
|
| 96 |
+
from: 2,
|
| 97 |
+
to: 2,
|
| 98 |
+
greedy: true
|
| 99 |
+
}
|
| 100 |
+
});
|
| 101 |
+
return startIndex;
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
i++;
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
return index;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
// (?:abc){2}abc -> (?:abc){3}
|
| 111 |
+
function combineWithPreviousRepetition(alternative, child, index) {
|
| 112 |
+
var node = alternative.node;
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
var i = 0;
|
| 116 |
+
while (i < index) {
|
| 117 |
+
var previousChild = alternative.getChild(i);
|
| 118 |
+
|
| 119 |
+
if (previousChild.node.type === 'Repetition' && previousChild.node.quantifier.greedy) {
|
| 120 |
+
var left = previousChild.getChild();
|
| 121 |
+
var right = void 0;
|
| 122 |
+
|
| 123 |
+
if (left.node.type === 'Group' && !left.node.capturing) {
|
| 124 |
+
left = left.getChild();
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
if (i + 1 === index) {
|
| 128 |
+
right = child;
|
| 129 |
+
if (right.node.type === 'Group' && !right.node.capturing) {
|
| 130 |
+
right = right.getChild();
|
| 131 |
+
}
|
| 132 |
+
} else {
|
| 133 |
+
right = NodePath.getForNode({
|
| 134 |
+
type: 'Alternative',
|
| 135 |
+
expressions: [].concat(_toConsumableArray(node.expressions.slice(i + 1, index + 1)))
|
| 136 |
+
});
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
if (left.hasEqualSource(right)) {
|
| 140 |
+
for (var j = i; j < index; j++) {
|
| 141 |
+
alternative.getChild(i + 1).remove();
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
increaseQuantifierByOne(previousChild.node.quantifier);
|
| 145 |
+
|
| 146 |
+
return i;
|
| 147 |
+
}
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
i++;
|
| 151 |
+
}
|
| 152 |
+
return index;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
// abc(?:abc){2} -> (?:abc){3}
|
| 156 |
+
function combineRepetitionWithPrevious(alternative, child, index) {
|
| 157 |
+
var node = alternative.node;
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
if (child.node.type === 'Repetition' && child.node.quantifier.greedy) {
|
| 161 |
+
var right = child.getChild();
|
| 162 |
+
var left = void 0;
|
| 163 |
+
|
| 164 |
+
if (right.node.type === 'Group' && !right.node.capturing) {
|
| 165 |
+
right = right.getChild();
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
var rightLength = void 0;
|
| 169 |
+
if (right.node.type === 'Alternative') {
|
| 170 |
+
rightLength = right.node.expressions.length;
|
| 171 |
+
left = NodePath.getForNode({
|
| 172 |
+
type: 'Alternative',
|
| 173 |
+
expressions: [].concat(_toConsumableArray(node.expressions.slice(index - rightLength, index)))
|
| 174 |
+
});
|
| 175 |
+
} else {
|
| 176 |
+
rightLength = 1;
|
| 177 |
+
left = alternative.getChild(index - 1);
|
| 178 |
+
if (left.node.type === 'Group' && !left.node.capturing) {
|
| 179 |
+
left = left.getChild();
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
if (left.hasEqualSource(right)) {
|
| 184 |
+
for (var j = index - rightLength; j < index; j++) {
|
| 185 |
+
alternative.getChild(index - rightLength).remove();
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
increaseQuantifierByOne(child.node.quantifier);
|
| 189 |
+
|
| 190 |
+
return index - rightLength;
|
| 191 |
+
}
|
| 192 |
+
}
|
| 193 |
+
return index;
|
| 194 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/disjunction-remove-duplicates-transform.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
var NodePath = require('../../traverse/node-path');
|
| 9 |
+
|
| 10 |
+
var _require = require('../../transform/utils'),
|
| 11 |
+
disjunctionToList = _require.disjunctionToList,
|
| 12 |
+
listToDisjunction = _require.listToDisjunction;
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* Removes duplicates from a disjunction sequence:
|
| 16 |
+
*
|
| 17 |
+
* /(ab|bc|ab)+(xy|xy)+/ -> /(ab|bc)+(xy)+/
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
module.exports = {
|
| 22 |
+
Disjunction: function Disjunction(path) {
|
| 23 |
+
var node = path.node;
|
| 24 |
+
|
| 25 |
+
// Make unique nodes.
|
| 26 |
+
|
| 27 |
+
var uniqueNodesMap = {};
|
| 28 |
+
|
| 29 |
+
var parts = disjunctionToList(node).filter(function (part) {
|
| 30 |
+
var encoded = part ? NodePath.getForNode(part).jsonEncode() : 'null';
|
| 31 |
+
|
| 32 |
+
// Already recorded this part, filter out.
|
| 33 |
+
if (uniqueNodesMap.hasOwnProperty(encoded)) {
|
| 34 |
+
return false;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
uniqueNodesMap[encoded] = part;
|
| 38 |
+
return true;
|
| 39 |
+
});
|
| 40 |
+
|
| 41 |
+
// Replace with the optimized disjunction.
|
| 42 |
+
path.replace(listToDisjunction(parts));
|
| 43 |
+
}
|
| 44 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/group-single-chars-to-char-class.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to replace single char group disjunction to char group
|
| 10 |
+
*
|
| 11 |
+
* a|b|c -> [abc]
|
| 12 |
+
* [12]|3|4 -> [1234]
|
| 13 |
+
* (a|b|c) -> ([abc])
|
| 14 |
+
* (?:a|b|c) -> [abc]
|
| 15 |
+
*/
|
| 16 |
+
|
| 17 |
+
module.exports = {
|
| 18 |
+
Disjunction: function Disjunction(path) {
|
| 19 |
+
var node = path.node,
|
| 20 |
+
parent = path.parent;
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if (!handlers[parent.type]) {
|
| 24 |
+
return;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
var charset = new Map();
|
| 28 |
+
|
| 29 |
+
if (!shouldProcess(node, charset) || !charset.size) {
|
| 30 |
+
return;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
var characterClass = {
|
| 34 |
+
type: 'CharacterClass',
|
| 35 |
+
expressions: Array.from(charset.keys()).sort().map(function (key) {
|
| 36 |
+
return charset.get(key);
|
| 37 |
+
})
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
handlers[parent.type](path.getParent(), characterClass);
|
| 41 |
+
}
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
var handlers = {
|
| 45 |
+
RegExp: function RegExp(path, characterClass) {
|
| 46 |
+
var node = path.node;
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
node.body = characterClass;
|
| 50 |
+
},
|
| 51 |
+
Group: function Group(path, characterClass) {
|
| 52 |
+
var node = path.node;
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
if (node.capturing) {
|
| 56 |
+
node.expression = characterClass;
|
| 57 |
+
} else {
|
| 58 |
+
path.replace(characterClass);
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
function shouldProcess(expression, charset) {
|
| 64 |
+
if (!expression) {
|
| 65 |
+
// Abort on empty disjunction part
|
| 66 |
+
return false;
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
var type = expression.type;
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
if (type === 'Disjunction') {
|
| 73 |
+
var left = expression.left,
|
| 74 |
+
right = expression.right;
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
return shouldProcess(left, charset) && shouldProcess(right, charset);
|
| 78 |
+
} else if (type === 'Char') {
|
| 79 |
+
if (expression.kind === 'meta' && expression.symbol === '.') {
|
| 80 |
+
return false;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
var value = expression.value;
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
charset.set(value, expression);
|
| 87 |
+
|
| 88 |
+
return true;
|
| 89 |
+
} else if (type === 'CharacterClass' && !expression.negative) {
|
| 90 |
+
return expression.expressions.every(function (expression) {
|
| 91 |
+
return shouldProcess(expression, charset);
|
| 92 |
+
});
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
return false;
|
| 96 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/index.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
module.exports = new Map([
|
| 9 |
+
// \ud83d\ude80 -> \u{1f680}
|
| 10 |
+
['charSurrogatePairToSingleUnicode', require('./char-surrogate-pair-to-single-unicode-transform')],
|
| 11 |
+
|
| 12 |
+
// \u0061 -> a
|
| 13 |
+
['charCodeToSimpleChar', require('./char-code-to-simple-char-transform')],
|
| 14 |
+
|
| 15 |
+
// /Aa/i -> /aa/i
|
| 16 |
+
['charCaseInsensitiveLowerCaseTransform', require('./char-case-insensitive-lowercase-transform')],
|
| 17 |
+
|
| 18 |
+
// [\d\d] -> [\d]
|
| 19 |
+
['charClassRemoveDuplicates', require('./char-class-remove-duplicates-transform')],
|
| 20 |
+
|
| 21 |
+
// a{1,2}a{2,3} -> a{3,5}
|
| 22 |
+
['quantifiersMerge', require('./quantifiers-merge-transform')],
|
| 23 |
+
|
| 24 |
+
// a{1,} -> a+, a{3,3} -> a{3}, a{1} -> a
|
| 25 |
+
['quantifierRangeToSymbol', require('./quantifier-range-to-symbol-transform')],
|
| 26 |
+
|
| 27 |
+
// [a-a] -> [a], [a-b] -> [ab]
|
| 28 |
+
['charClassClassrangesToChars', require('./char-class-classranges-to-chars-transform')],
|
| 29 |
+
|
| 30 |
+
// [0-9] -> [\d]
|
| 31 |
+
['charClassToMeta', require('./char-class-to-meta-transform')],
|
| 32 |
+
|
| 33 |
+
// [\d] -> \d, [^\w] -> \W
|
| 34 |
+
['charClassToSingleChar', require('./char-class-to-single-char-transform')],
|
| 35 |
+
|
| 36 |
+
// \e -> e
|
| 37 |
+
['charEscapeUnescape', require('./char-escape-unescape-transform')],
|
| 38 |
+
|
| 39 |
+
// [a-de-f] -> [a-f]
|
| 40 |
+
['charClassClassrangesMerge', require('./char-class-classranges-merge-transform')],
|
| 41 |
+
|
| 42 |
+
// (ab|ab) -> (ab)
|
| 43 |
+
['disjunctionRemoveDuplicates', require('./disjunction-remove-duplicates-transform')],
|
| 44 |
+
|
| 45 |
+
// (a|b|c) -> [abc]
|
| 46 |
+
['groupSingleCharsToCharClass', require('./group-single-chars-to-char-class')],
|
| 47 |
+
|
| 48 |
+
// (?:)a -> a
|
| 49 |
+
['removeEmptyGroup', require('./remove-empty-group-transform')],
|
| 50 |
+
|
| 51 |
+
// (?:a) -> a
|
| 52 |
+
['ungroup', require('./ungroup-transform')],
|
| 53 |
+
|
| 54 |
+
// abcabcabc -> (?:abc){3}
|
| 55 |
+
['combineRepeatingPatterns', require('./combine-repeating-patterns-transform')]]);
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/quantifier-range-to-symbol-transform.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to replace different range-based quantifiers
|
| 10 |
+
* with their symbol equivalents.
|
| 11 |
+
*
|
| 12 |
+
* a{0,} -> a*
|
| 13 |
+
* a{1,} -> a+
|
| 14 |
+
* a{1} -> a
|
| 15 |
+
*
|
| 16 |
+
* NOTE: the following is automatically handled in the generator:
|
| 17 |
+
*
|
| 18 |
+
* a{3,3} -> a{3}
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
module.exports = {
|
| 22 |
+
Quantifier: function Quantifier(path) {
|
| 23 |
+
var node = path.node;
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
if (node.kind !== 'Range') {
|
| 27 |
+
return;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
// a{0,} -> a*
|
| 31 |
+
rewriteOpenZero(path);
|
| 32 |
+
|
| 33 |
+
// a{1,} -> a+
|
| 34 |
+
rewriteOpenOne(path);
|
| 35 |
+
|
| 36 |
+
// a{1} -> a
|
| 37 |
+
rewriteExactOne(path);
|
| 38 |
+
}
|
| 39 |
+
};
|
| 40 |
+
|
| 41 |
+
function rewriteOpenZero(path) {
|
| 42 |
+
var node = path.node;
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
if (node.from !== 0 || node.to) {
|
| 46 |
+
return;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
node.kind = '*';
|
| 50 |
+
delete node.from;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
function rewriteOpenOne(path) {
|
| 54 |
+
var node = path.node;
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
if (node.from !== 1 || node.to) {
|
| 58 |
+
return;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
node.kind = '+';
|
| 62 |
+
delete node.from;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
function rewriteExactOne(path) {
|
| 66 |
+
var node = path.node;
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
if (node.from !== 1 || node.to !== 1) {
|
| 70 |
+
return;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
path.parentPath.replace(path.parentPath.node.expression);
|
| 74 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/quantifiers-merge-transform.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
var _require = require('../../transform/utils'),
|
| 9 |
+
increaseQuantifierByOne = _require.increaseQuantifierByOne;
|
| 10 |
+
|
| 11 |
+
/**
|
| 12 |
+
* A regexp-tree plugin to merge quantifiers
|
| 13 |
+
*
|
| 14 |
+
* a+a+ -> a{2,}
|
| 15 |
+
* a{2}a{3} -> a{5}
|
| 16 |
+
* a{1,2}a{2,3} -> a{3,5}
|
| 17 |
+
*/
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
module.exports = {
|
| 21 |
+
Repetition: function Repetition(path) {
|
| 22 |
+
var node = path.node,
|
| 23 |
+
parent = path.parent;
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
if (parent.type !== 'Alternative' || !path.index) {
|
| 27 |
+
return;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
var previousSibling = path.getPreviousSibling();
|
| 31 |
+
|
| 32 |
+
if (!previousSibling) {
|
| 33 |
+
return;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
if (previousSibling.node.type === 'Repetition') {
|
| 37 |
+
if (!previousSibling.getChild().hasEqualSource(path.getChild())) {
|
| 38 |
+
return;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
var _extractFromTo = extractFromTo(previousSibling.node.quantifier),
|
| 42 |
+
previousSiblingFrom = _extractFromTo.from,
|
| 43 |
+
previousSiblingTo = _extractFromTo.to;
|
| 44 |
+
|
| 45 |
+
var _extractFromTo2 = extractFromTo(node.quantifier),
|
| 46 |
+
nodeFrom = _extractFromTo2.from,
|
| 47 |
+
nodeTo = _extractFromTo2.to;
|
| 48 |
+
|
| 49 |
+
// It's does not seem reliable to merge quantifiers with different greediness
|
| 50 |
+
// when none of both is a greedy open range
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
if (previousSibling.node.quantifier.greedy !== node.quantifier.greedy && !isGreedyOpenRange(previousSibling.node.quantifier) && !isGreedyOpenRange(node.quantifier)) {
|
| 54 |
+
return;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// a*a* -> a*
|
| 58 |
+
// a*a+ -> a+
|
| 59 |
+
// a+a+ -> a{2,}
|
| 60 |
+
// a{2}a{4} -> a{6}
|
| 61 |
+
// a{1,2}a{2,3} -> a{3,5}
|
| 62 |
+
// a{1,}a{2,} -> a{3,}
|
| 63 |
+
// a+a{2,} -> a{3,}
|
| 64 |
+
|
| 65 |
+
// a??a{2,} -> a{2,}
|
| 66 |
+
// a*?a{2,} -> a{2,}
|
| 67 |
+
// a+?a{2,} -> a{3,}
|
| 68 |
+
|
| 69 |
+
node.quantifier.kind = 'Range';
|
| 70 |
+
node.quantifier.from = previousSiblingFrom + nodeFrom;
|
| 71 |
+
if (previousSiblingTo && nodeTo) {
|
| 72 |
+
node.quantifier.to = previousSiblingTo + nodeTo;
|
| 73 |
+
} else {
|
| 74 |
+
delete node.quantifier.to;
|
| 75 |
+
}
|
| 76 |
+
if (isGreedyOpenRange(previousSibling.node.quantifier) || isGreedyOpenRange(node.quantifier)) {
|
| 77 |
+
node.quantifier.greedy = true;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
previousSibling.remove();
|
| 81 |
+
} else {
|
| 82 |
+
if (!previousSibling.hasEqualSource(path.getChild())) {
|
| 83 |
+
return;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
increaseQuantifierByOne(node.quantifier);
|
| 87 |
+
previousSibling.remove();
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
function isGreedyOpenRange(quantifier) {
|
| 93 |
+
return quantifier.greedy && (quantifier.kind === '+' || quantifier.kind === '*' || quantifier.kind === 'Range' && !quantifier.to);
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
function extractFromTo(quantifier) {
|
| 97 |
+
var from = void 0,
|
| 98 |
+
to = void 0;
|
| 99 |
+
if (quantifier.kind === '*') {
|
| 100 |
+
from = 0;
|
| 101 |
+
} else if (quantifier.kind === '+') {
|
| 102 |
+
from = 1;
|
| 103 |
+
} else if (quantifier.kind === '?') {
|
| 104 |
+
from = 0;
|
| 105 |
+
to = 1;
|
| 106 |
+
} else {
|
| 107 |
+
from = quantifier.from;
|
| 108 |
+
if (quantifier.to) {
|
| 109 |
+
to = quantifier.to;
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
return { from: from, to: to };
|
| 113 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/remove-empty-group-transform.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to remove non-capturing empty groups.
|
| 10 |
+
*
|
| 11 |
+
* /(?:)a/ -> /a/
|
| 12 |
+
* /a|(?:)/ -> /a|/
|
| 13 |
+
*/
|
| 14 |
+
|
| 15 |
+
module.exports = {
|
| 16 |
+
Group: function Group(path) {
|
| 17 |
+
var node = path.node,
|
| 18 |
+
parent = path.parent;
|
| 19 |
+
|
| 20 |
+
var childPath = path.getChild();
|
| 21 |
+
|
| 22 |
+
if (node.capturing || childPath) {
|
| 23 |
+
return;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
if (parent.type === 'Repetition') {
|
| 27 |
+
|
| 28 |
+
path.getParent().replace(node);
|
| 29 |
+
} else if (parent.type !== 'RegExp') {
|
| 30 |
+
|
| 31 |
+
path.remove();
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/optimizer/transforms/ungroup-transform.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The MIT License (MIT)
|
| 3 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
'use strict';
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* A regexp-tree plugin to remove unnecessary groups.
|
| 10 |
+
*
|
| 11 |
+
* /(?:a)/ -> /a/
|
| 12 |
+
*/
|
| 13 |
+
|
| 14 |
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
| 15 |
+
|
| 16 |
+
module.exports = {
|
| 17 |
+
Group: function Group(path) {
|
| 18 |
+
var node = path.node,
|
| 19 |
+
parent = path.parent;
|
| 20 |
+
|
| 21 |
+
var childPath = path.getChild();
|
| 22 |
+
|
| 23 |
+
if (node.capturing || !childPath) {
|
| 24 |
+
return;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
// Don't optimize \1(?:0) to \10
|
| 28 |
+
if (!hasAppropriateSiblings(path)) {
|
| 29 |
+
return;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
// Don't optimize /a(?:b|c)/ to /ab|c/
|
| 33 |
+
// but /(?:b|c)/ to /b|c/ is ok
|
| 34 |
+
if (childPath.node.type === 'Disjunction' && parent.type !== 'RegExp') {
|
| 35 |
+
return;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
// Don't optimize /(?:ab)+/ to /ab+/
|
| 39 |
+
// but /(?:a)+/ to /a+/ is ok
|
| 40 |
+
// and /(?:[a-d])+/ to /[a-d]+/ is ok too
|
| 41 |
+
if (parent.type === 'Repetition' && childPath.node.type !== 'Char' && childPath.node.type !== 'CharacterClass') {
|
| 42 |
+
return;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
if (childPath.node.type === 'Alternative') {
|
| 46 |
+
var parentPath = path.getParent();
|
| 47 |
+
if (parentPath.node.type === 'Alternative') {
|
| 48 |
+
// /abc(?:def)ghi/ When (?:def) is ungrouped its content must be merged with parent alternative
|
| 49 |
+
|
| 50 |
+
parentPath.replace({
|
| 51 |
+
type: 'Alternative',
|
| 52 |
+
expressions: [].concat(_toConsumableArray(parent.expressions.slice(0, path.index)), _toConsumableArray(childPath.node.expressions), _toConsumableArray(parent.expressions.slice(path.index + 1)))
|
| 53 |
+
});
|
| 54 |
+
}
|
| 55 |
+
} else {
|
| 56 |
+
path.replace(childPath.node);
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
function hasAppropriateSiblings(path) {
|
| 62 |
+
var parent = path.parent,
|
| 63 |
+
index = path.index;
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
if (parent.type !== 'Alternative') {
|
| 67 |
+
return true;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
var previousNode = parent.expressions[index - 1];
|
| 71 |
+
if (previousNode == null) {
|
| 72 |
+
return true;
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
// Don't optimized \1(?:0) to \10
|
| 76 |
+
if (previousNode.type === 'Backreference' && previousNode.kind === 'number') {
|
| 77 |
+
return false;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
// Don't optimized \2(?:0) to \20
|
| 81 |
+
if (previousNode.type === 'Char' && previousNode.kind === 'decimal') {
|
| 82 |
+
return false;
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
return true;
|
| 86 |
+
}
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/parser/generated/regexp-tree.js
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp-tree/dist/parser/unicode/parser-unicode-properties.js
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* The MIT License (MIT)
|
| 5 |
+
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
| 6 |
+
*/
|
| 7 |
+
|
| 8 |
+
var NON_BINARY_PROP_NAMES_TO_ALIASES = {
|
| 9 |
+
General_Category: 'gc',
|
| 10 |
+
Script: 'sc',
|
| 11 |
+
Script_Extensions: 'scx'
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
var NON_BINARY_ALIASES_TO_PROP_NAMES = inverseMap(NON_BINARY_PROP_NAMES_TO_ALIASES);
|
| 15 |
+
|
| 16 |
+
var BINARY_PROP_NAMES_TO_ALIASES = {
|
| 17 |
+
ASCII: 'ASCII',
|
| 18 |
+
ASCII_Hex_Digit: 'AHex',
|
| 19 |
+
Alphabetic: 'Alpha',
|
| 20 |
+
Any: 'Any',
|
| 21 |
+
Assigned: 'Assigned',
|
| 22 |
+
Bidi_Control: 'Bidi_C',
|
| 23 |
+
Bidi_Mirrored: 'Bidi_M',
|
| 24 |
+
Case_Ignorable: 'CI',
|
| 25 |
+
Cased: 'Cased',
|
| 26 |
+
Changes_When_Casefolded: 'CWCF',
|
| 27 |
+
Changes_When_Casemapped: 'CWCM',
|
| 28 |
+
Changes_When_Lowercased: 'CWL',
|
| 29 |
+
Changes_When_NFKC_Casefolded: 'CWKCF',
|
| 30 |
+
Changes_When_Titlecased: 'CWT',
|
| 31 |
+
Changes_When_Uppercased: 'CWU',
|
| 32 |
+
Dash: 'Dash',
|
| 33 |
+
Default_Ignorable_Code_Point: 'DI',
|
| 34 |
+
Deprecated: 'Dep',
|
| 35 |
+
Diacritic: 'Dia',
|
| 36 |
+
Emoji: 'Emoji',
|
| 37 |
+
Emoji_Component: 'Emoji_Component',
|
| 38 |
+
Emoji_Modifier: 'Emoji_Modifier',
|
| 39 |
+
Emoji_Modifier_Base: 'Emoji_Modifier_Base',
|
| 40 |
+
Emoji_Presentation: 'Emoji_Presentation',
|
| 41 |
+
Extended_Pictographic: 'Extended_Pictographic',
|
| 42 |
+
Extender: 'Ext',
|
| 43 |
+
Grapheme_Base: 'Gr_Base',
|
| 44 |
+
Grapheme_Extend: 'Gr_Ext',
|
| 45 |
+
Hex_Digit: 'Hex',
|
| 46 |
+
IDS_Binary_Operator: 'IDSB',
|
| 47 |
+
IDS_Trinary_Operator: 'IDST',
|
| 48 |
+
ID_Continue: 'IDC',
|
| 49 |
+
ID_Start: 'IDS',
|
| 50 |
+
Ideographic: 'Ideo',
|
| 51 |
+
Join_Control: 'Join_C',
|
| 52 |
+
Logical_Order_Exception: 'LOE',
|
| 53 |
+
Lowercase: 'Lower',
|
| 54 |
+
Math: 'Math',
|
| 55 |
+
Noncharacter_Code_Point: 'NChar',
|
| 56 |
+
Pattern_Syntax: 'Pat_Syn',
|
| 57 |
+
Pattern_White_Space: 'Pat_WS',
|
| 58 |
+
Quotation_Mark: 'QMark',
|
| 59 |
+
Radical: 'Radical',
|
| 60 |
+
Regional_Indicator: 'RI',
|
| 61 |
+
Sentence_Terminal: 'STerm',
|
| 62 |
+
Soft_Dotted: 'SD',
|
| 63 |
+
Terminal_Punctuation: 'Term',
|
| 64 |
+
Unified_Ideograph: 'UIdeo',
|
| 65 |
+
Uppercase: 'Upper',
|
| 66 |
+
Variation_Selector: 'VS',
|
| 67 |
+
White_Space: 'space',
|
| 68 |
+
XID_Continue: 'XIDC',
|
| 69 |
+
XID_Start: 'XIDS'
|
| 70 |
+
};
|
| 71 |
+
|
| 72 |
+
var BINARY_ALIASES_TO_PROP_NAMES = inverseMap(BINARY_PROP_NAMES_TO_ALIASES);
|
| 73 |
+
|
| 74 |
+
var GENERAL_CATEGORY_VALUE_TO_ALIASES = {
|
| 75 |
+
Cased_Letter: 'LC',
|
| 76 |
+
Close_Punctuation: 'Pe',
|
| 77 |
+
Connector_Punctuation: 'Pc',
|
| 78 |
+
Control: ['Cc', 'cntrl'],
|
| 79 |
+
Currency_Symbol: 'Sc',
|
| 80 |
+
Dash_Punctuation: 'Pd',
|
| 81 |
+
Decimal_Number: ['Nd', 'digit'],
|
| 82 |
+
Enclosing_Mark: 'Me',
|
| 83 |
+
Final_Punctuation: 'Pf',
|
| 84 |
+
Format: 'Cf',
|
| 85 |
+
Initial_Punctuation: 'Pi',
|
| 86 |
+
Letter: 'L',
|
| 87 |
+
Letter_Number: 'Nl',
|
| 88 |
+
Line_Separator: 'Zl',
|
| 89 |
+
Lowercase_Letter: 'Ll',
|
| 90 |
+
Mark: ['M', 'Combining_Mark'],
|
| 91 |
+
Math_Symbol: 'Sm',
|
| 92 |
+
Modifier_Letter: 'Lm',
|
| 93 |
+
Modifier_Symbol: 'Sk',
|
| 94 |
+
Nonspacing_Mark: 'Mn',
|
| 95 |
+
Number: 'N',
|
| 96 |
+
Open_Punctuation: 'Ps',
|
| 97 |
+
Other: 'C',
|
| 98 |
+
Other_Letter: 'Lo',
|
| 99 |
+
Other_Number: 'No',
|
| 100 |
+
Other_Punctuation: 'Po',
|
| 101 |
+
Other_Symbol: 'So',
|
| 102 |
+
Paragraph_Separator: 'Zp',
|
| 103 |
+
Private_Use: 'Co',
|
| 104 |
+
Punctuation: ['P', 'punct'],
|
| 105 |
+
Separator: 'Z',
|
| 106 |
+
Space_Separator: 'Zs',
|
| 107 |
+
Spacing_Mark: 'Mc',
|
| 108 |
+
Surrogate: 'Cs',
|
| 109 |
+
Symbol: 'S',
|
| 110 |
+
Titlecase_Letter: 'Lt',
|
| 111 |
+
Unassigned: 'Cn',
|
| 112 |
+
Uppercase_Letter: 'Lu'
|
| 113 |
+
};
|
| 114 |
+
|
| 115 |
+
var GENERAL_CATEGORY_VALUE_ALIASES_TO_VALUES = inverseMap(GENERAL_CATEGORY_VALUE_TO_ALIASES);
|
| 116 |
+
|
| 117 |
+
var SCRIPT_VALUE_TO_ALIASES = {
|
| 118 |
+
Adlam: 'Adlm',
|
| 119 |
+
Ahom: 'Ahom',
|
| 120 |
+
Anatolian_Hieroglyphs: 'Hluw',
|
| 121 |
+
Arabic: 'Arab',
|
| 122 |
+
Armenian: 'Armn',
|
| 123 |
+
Avestan: 'Avst',
|
| 124 |
+
Balinese: 'Bali',
|
| 125 |
+
Bamum: 'Bamu',
|
| 126 |
+
Bassa_Vah: 'Bass',
|
| 127 |
+
Batak: 'Batk',
|
| 128 |
+
Bengali: 'Beng',
|
| 129 |
+
Bhaiksuki: 'Bhks',
|
| 130 |
+
Bopomofo: 'Bopo',
|
| 131 |
+
Brahmi: 'Brah',
|
| 132 |
+
Braille: 'Brai',
|
| 133 |
+
Buginese: 'Bugi',
|
| 134 |
+
Buhid: 'Buhd',
|
| 135 |
+
Canadian_Aboriginal: 'Cans',
|
| 136 |
+
Carian: 'Cari',
|
| 137 |
+
Caucasian_Albanian: 'Aghb',
|
| 138 |
+
Chakma: 'Cakm',
|
| 139 |
+
Cham: 'Cham',
|
| 140 |
+
Cherokee: 'Cher',
|
| 141 |
+
Common: 'Zyyy',
|
| 142 |
+
Coptic: ['Copt', 'Qaac'],
|
| 143 |
+
Cuneiform: 'Xsux',
|
| 144 |
+
Cypriot: 'Cprt',
|
| 145 |
+
Cyrillic: 'Cyrl',
|
| 146 |
+
Deseret: 'Dsrt',
|
| 147 |
+
Devanagari: 'Deva',
|
| 148 |
+
Dogra: 'Dogr',
|
| 149 |
+
Duployan: 'Dupl',
|
| 150 |
+
Egyptian_Hieroglyphs: 'Egyp',
|
| 151 |
+
Elbasan: 'Elba',
|
| 152 |
+
Ethiopic: 'Ethi',
|
| 153 |
+
Georgian: 'Geor',
|
| 154 |
+
Glagolitic: 'Glag',
|
| 155 |
+
Gothic: 'Goth',
|
| 156 |
+
Grantha: 'Gran',
|
| 157 |
+
Greek: 'Grek',
|
| 158 |
+
Gujarati: 'Gujr',
|
| 159 |
+
Gunjala_Gondi: 'Gong',
|
| 160 |
+
Gurmukhi: 'Guru',
|
| 161 |
+
Han: 'Hani',
|
| 162 |
+
Hangul: 'Hang',
|
| 163 |
+
Hanifi_Rohingya: 'Rohg',
|
| 164 |
+
Hanunoo: 'Hano',
|
| 165 |
+
Hatran: 'Hatr',
|
| 166 |
+
Hebrew: 'Hebr',
|
| 167 |
+
Hiragana: 'Hira',
|
| 168 |
+
Imperial_Aramaic: 'Armi',
|
| 169 |
+
Inherited: ['Zinh', 'Qaai'],
|
| 170 |
+
Inscriptional_Pahlavi: 'Phli',
|
| 171 |
+
Inscriptional_Parthian: 'Prti',
|
| 172 |
+
Javanese: 'Java',
|
| 173 |
+
Kaithi: 'Kthi',
|
| 174 |
+
Kannada: 'Knda',
|
| 175 |
+
Katakana: 'Kana',
|
| 176 |
+
Kayah_Li: 'Kali',
|
| 177 |
+
Kharoshthi: 'Khar',
|
| 178 |
+
Khmer: 'Khmr',
|
| 179 |
+
Khojki: 'Khoj',
|
| 180 |
+
Khudawadi: 'Sind',
|
| 181 |
+
Lao: 'Laoo',
|
| 182 |
+
Latin: 'Latn',
|
| 183 |
+
Lepcha: 'Lepc',
|
| 184 |
+
Limbu: 'Limb',
|
| 185 |
+
Linear_A: 'Lina',
|
| 186 |
+
Linear_B: 'Linb',
|
| 187 |
+
Lisu: 'Lisu',
|
| 188 |
+
Lycian: 'Lyci',
|
| 189 |
+
Lydian: 'Lydi',
|
| 190 |
+
Mahajani: 'Mahj',
|
| 191 |
+
Makasar: 'Maka',
|
| 192 |
+
Malayalam: 'Mlym',
|
| 193 |
+
Mandaic: 'Mand',
|
| 194 |
+
Manichaean: 'Mani',
|
| 195 |
+
Marchen: 'Marc',
|
| 196 |
+
Medefaidrin: 'Medf',
|
| 197 |
+
Masaram_Gondi: 'Gonm',
|
| 198 |
+
Meetei_Mayek: 'Mtei',
|
| 199 |
+
Mende_Kikakui: 'Mend',
|
| 200 |
+
Meroitic_Cursive: 'Merc',
|
| 201 |
+
Meroitic_Hieroglyphs: 'Mero',
|
| 202 |
+
Miao: 'Plrd',
|
| 203 |
+
Modi: 'Modi',
|
| 204 |
+
Mongolian: 'Mong',
|
| 205 |
+
Mro: 'Mroo',
|
| 206 |
+
Multani: 'Mult',
|
| 207 |
+
Myanmar: 'Mymr',
|
| 208 |
+
Nabataean: 'Nbat',
|
| 209 |
+
New_Tai_Lue: 'Talu',
|
| 210 |
+
Newa: 'Newa',
|
| 211 |
+
Nko: 'Nkoo',
|
| 212 |
+
Nushu: 'Nshu',
|
| 213 |
+
Ogham: 'Ogam',
|
| 214 |
+
Ol_Chiki: 'Olck',
|
| 215 |
+
Old_Hungarian: 'Hung',
|
| 216 |
+
Old_Italic: 'Ital',
|
| 217 |
+
Old_North_Arabian: 'Narb',
|
| 218 |
+
Old_Permic: 'Perm',
|
| 219 |
+
Old_Persian: 'Xpeo',
|
| 220 |
+
Old_Sogdian: 'Sogo',
|
| 221 |
+
Old_South_Arabian: 'Sarb',
|
| 222 |
+
Old_Turkic: 'Orkh',
|
| 223 |
+
Oriya: 'Orya',
|
| 224 |
+
Osage: 'Osge',
|
| 225 |
+
Osmanya: 'Osma',
|
| 226 |
+
Pahawh_Hmong: 'Hmng',
|
| 227 |
+
Palmyrene: 'Palm',
|
| 228 |
+
Pau_Cin_Hau: 'Pauc',
|
| 229 |
+
Phags_Pa: 'Phag',
|
| 230 |
+
Phoenician: 'Phnx',
|
| 231 |
+
Psalter_Pahlavi: 'Phlp',
|
| 232 |
+
Rejang: 'Rjng',
|
| 233 |
+
Runic: 'Runr',
|
| 234 |
+
Samaritan: 'Samr',
|
| 235 |
+
Saurashtra: 'Saur',
|
| 236 |
+
Sharada: 'Shrd',
|
| 237 |
+
Shavian: 'Shaw',
|
| 238 |
+
Siddham: 'Sidd',
|
| 239 |
+
SignWriting: 'Sgnw',
|
| 240 |
+
Sinhala: 'Sinh',
|
| 241 |
+
Sogdian: 'Sogd',
|
| 242 |
+
Sora_Sompeng: 'Sora',
|
| 243 |
+
Soyombo: 'Soyo',
|
| 244 |
+
Sundanese: 'Sund',
|
| 245 |
+
Syloti_Nagri: 'Sylo',
|
| 246 |
+
Syriac: 'Syrc',
|
| 247 |
+
Tagalog: 'Tglg',
|
| 248 |
+
Tagbanwa: 'Tagb',
|
| 249 |
+
Tai_Le: 'Tale',
|
| 250 |
+
Tai_Tham: 'Lana',
|
| 251 |
+
Tai_Viet: 'Tavt',
|
| 252 |
+
Takri: 'Takr',
|
| 253 |
+
Tamil: 'Taml',
|
| 254 |
+
Tangut: 'Tang',
|
| 255 |
+
Telugu: 'Telu',
|
| 256 |
+
Thaana: 'Thaa',
|
| 257 |
+
Thai: 'Thai',
|
| 258 |
+
Tibetan: 'Tibt',
|
| 259 |
+
Tifinagh: 'Tfng',
|
| 260 |
+
Tirhuta: 'Tirh',
|
| 261 |
+
Ugaritic: 'Ugar',
|
| 262 |
+
Vai: 'Vaii',
|
| 263 |
+
Warang_Citi: 'Wara',
|
| 264 |
+
Yi: 'Yiii',
|
| 265 |
+
Zanabazar_Square: 'Zanb'
|
| 266 |
+
};
|
| 267 |
+
|
| 268 |
+
var SCRIPT_VALUE_ALIASES_TO_VALUE = inverseMap(SCRIPT_VALUE_TO_ALIASES);
|
| 269 |
+
|
| 270 |
+
function inverseMap(data) {
|
| 271 |
+
var inverse = {};
|
| 272 |
+
|
| 273 |
+
for (var name in data) {
|
| 274 |
+
if (!data.hasOwnProperty(name)) {
|
| 275 |
+
continue;
|
| 276 |
+
}
|
| 277 |
+
var value = data[name];
|
| 278 |
+
if (Array.isArray(value)) {
|
| 279 |
+
for (var i = 0; i < value.length; i++) {
|
| 280 |
+
inverse[value[i]] = name;
|
| 281 |
+
}
|
| 282 |
+
} else {
|
| 283 |
+
inverse[value] = name;
|
| 284 |
+
}
|
| 285 |
+
}
|
| 286 |
+
|
| 287 |
+
return inverse;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
function isValidName(name) {
|
| 291 |
+
return NON_BINARY_PROP_NAMES_TO_ALIASES.hasOwnProperty(name) || NON_BINARY_ALIASES_TO_PROP_NAMES.hasOwnProperty(name) || BINARY_PROP_NAMES_TO_ALIASES.hasOwnProperty(name) || BINARY_ALIASES_TO_PROP_NAMES.hasOwnProperty(name);
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
function isValidValue(name, value) {
|
| 295 |
+
if (isGeneralCategoryName(name)) {
|
| 296 |
+
return isGeneralCategoryValue(value);
|
| 297 |
+
}
|
| 298 |
+
|
| 299 |
+
if (isScriptCategoryName(name)) {
|
| 300 |
+
return isScriptCategoryValue(value);
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
return false;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
function isAlias(name) {
|
| 307 |
+
return NON_BINARY_ALIASES_TO_PROP_NAMES.hasOwnProperty(name) || BINARY_ALIASES_TO_PROP_NAMES.hasOwnProperty(name);
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
function isGeneralCategoryName(name) {
|
| 311 |
+
return name === 'General_Category' || name == 'gc';
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
function isScriptCategoryName(name) {
|
| 315 |
+
return name === 'Script' || name === 'Script_Extensions' || name === 'sc' || name === 'scx';
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
function isGeneralCategoryValue(value) {
|
| 319 |
+
return GENERAL_CATEGORY_VALUE_TO_ALIASES.hasOwnProperty(value) || GENERAL_CATEGORY_VALUE_ALIASES_TO_VALUES.hasOwnProperty(value);
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
function isScriptCategoryValue(value) {
|
| 323 |
+
return SCRIPT_VALUE_TO_ALIASES.hasOwnProperty(value) || SCRIPT_VALUE_ALIASES_TO_VALUE.hasOwnProperty(value);
|
| 324 |
+
}
|
| 325 |
+
|
| 326 |
+
function isBinaryPropertyName(name) {
|
| 327 |
+
return BINARY_PROP_NAMES_TO_ALIASES.hasOwnProperty(name) || BINARY_ALIASES_TO_PROP_NAMES.hasOwnProperty(name);
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
function getCanonicalName(name) {
|
| 331 |
+
if (NON_BINARY_ALIASES_TO_PROP_NAMES.hasOwnProperty(name)) {
|
| 332 |
+
return NON_BINARY_ALIASES_TO_PROP_NAMES[name];
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
if (BINARY_ALIASES_TO_PROP_NAMES.hasOwnProperty(name)) {
|
| 336 |
+
return BINARY_ALIASES_TO_PROP_NAMES[name];
|
| 337 |
+
}
|
| 338 |
+
|
| 339 |
+
return null;
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
function getCanonicalValue(value) {
|
| 343 |
+
if (GENERAL_CATEGORY_VALUE_ALIASES_TO_VALUES.hasOwnProperty(value)) {
|
| 344 |
+
return GENERAL_CATEGORY_VALUE_ALIASES_TO_VALUES[value];
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
if (SCRIPT_VALUE_ALIASES_TO_VALUE.hasOwnProperty(value)) {
|
| 348 |
+
return SCRIPT_VALUE_ALIASES_TO_VALUE[value];
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
if (BINARY_ALIASES_TO_PROP_NAMES.hasOwnProperty(value)) {
|
| 352 |
+
return BINARY_ALIASES_TO_PROP_NAMES[value];
|
| 353 |
+
}
|
| 354 |
+
|
| 355 |
+
return null;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
module.exports = {
|
| 359 |
+
isAlias: isAlias,
|
| 360 |
+
isValidName: isValidName,
|
| 361 |
+
isValidValue: isValidValue,
|
| 362 |
+
isGeneralCategoryValue: isGeneralCategoryValue,
|
| 363 |
+
isScriptCategoryValue: isScriptCategoryValue,
|
| 364 |
+
isBinaryPropertyName: isBinaryPropertyName,
|
| 365 |
+
getCanonicalName: getCanonicalName,
|
| 366 |
+
getCanonicalValue: getCanonicalValue,
|
| 367 |
+
|
| 368 |
+
NON_BINARY_PROP_NAMES_TO_ALIASES: NON_BINARY_PROP_NAMES_TO_ALIASES,
|
| 369 |
+
NON_BINARY_ALIASES_TO_PROP_NAMES: NON_BINARY_ALIASES_TO_PROP_NAMES,
|
| 370 |
+
|
| 371 |
+
BINARY_PROP_NAMES_TO_ALIASES: BINARY_PROP_NAMES_TO_ALIASES,
|
| 372 |
+
BINARY_ALIASES_TO_PROP_NAMES: BINARY_ALIASES_TO_PROP_NAMES,
|
| 373 |
+
|
| 374 |
+
GENERAL_CATEGORY_VALUE_TO_ALIASES: GENERAL_CATEGORY_VALUE_TO_ALIASES,
|
| 375 |
+
GENERAL_CATEGORY_VALUE_ALIASES_TO_VALUES: GENERAL_CATEGORY_VALUE_ALIASES_TO_VALUES,
|
| 376 |
+
|
| 377 |
+
SCRIPT_VALUE_TO_ALIASES: SCRIPT_VALUE_TO_ALIASES,
|
| 378 |
+
SCRIPT_VALUE_ALIASES_TO_VALUE: SCRIPT_VALUE_ALIASES_TO_VALUE
|
| 379 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp.prototype.flags/test/builtin.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var test = require('tape');
|
| 4 |
+
var defineProperties = require('define-properties');
|
| 5 |
+
var callBind = require('call-bind');
|
| 6 |
+
|
| 7 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 8 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 9 |
+
var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames();
|
| 10 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 11 |
+
|
| 12 |
+
var runTests = require('./tests');
|
| 13 |
+
|
| 14 |
+
test('builtin', function (t) {
|
| 15 |
+
var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
|
| 16 |
+
|
| 17 |
+
t.equal(descriptor.get.length, 0, 'RegExp#flags getter has a length of 0');
|
| 18 |
+
|
| 19 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 20 |
+
st.equal(descriptor.get.name, functionsHaveConfigurableNames ? 'get flags' : 'flags', 'RegExp#flags getter has name "get flags" (or "flags" if function names are not configurable)');
|
| 21 |
+
st.end();
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 25 |
+
et.equal(false, isEnumerable.call(RegExp.prototype, 'flags'), 'RegExp#flags is not enumerable');
|
| 26 |
+
et.end();
|
| 27 |
+
});
|
| 28 |
+
|
| 29 |
+
t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
|
| 30 |
+
st['throws'](function () { return descriptor.get.call(undefined); }, TypeError, 'undefined is not an object');
|
| 31 |
+
st['throws'](function () { return descriptor.get.call(null); }, TypeError, 'null is not an object');
|
| 32 |
+
st.end();
|
| 33 |
+
});
|
| 34 |
+
|
| 35 |
+
t.test('has the correct descriptor', function (st) {
|
| 36 |
+
st.equal(descriptor.configurable, true);
|
| 37 |
+
st.equal(descriptor.enumerable, false);
|
| 38 |
+
st.equal(typeof descriptor.get, 'function');
|
| 39 |
+
st.equal(descriptor.set, undefined);
|
| 40 |
+
st.end();
|
| 41 |
+
});
|
| 42 |
+
|
| 43 |
+
runTests(callBind(descriptor.get), t);
|
| 44 |
+
|
| 45 |
+
t.end();
|
| 46 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp.prototype.flags/test/implementation.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var flags = require('../implementation');
|
| 4 |
+
var callBind = require('call-bind');
|
| 5 |
+
var test = require('tape');
|
| 6 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 7 |
+
var runTests = require('./tests');
|
| 8 |
+
|
| 9 |
+
test('as a function', function (t) {
|
| 10 |
+
t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
|
| 11 |
+
/* eslint no-useless-call: 0 */
|
| 12 |
+
st['throws'](function () { flags.call(undefined); }, TypeError, 'undefined is not an object');
|
| 13 |
+
st['throws'](function () { flags.call(null); }, TypeError, 'null is not an object');
|
| 14 |
+
st.end();
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
runTests(callBind(flags), t);
|
| 18 |
+
|
| 19 |
+
t.end();
|
| 20 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp.prototype.flags/test/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var flags = require('../');
|
| 4 |
+
var test = require('tape');
|
| 5 |
+
var runTests = require('./tests');
|
| 6 |
+
|
| 7 |
+
test('as a function', function (t) {
|
| 8 |
+
t.test('bad array/this value', function (st) {
|
| 9 |
+
st['throws'](function () { flags(undefined); }, TypeError, 'undefined is not an object');
|
| 10 |
+
st['throws'](function () { flags(null); }, TypeError, 'null is not an object');
|
| 11 |
+
st.end();
|
| 12 |
+
});
|
| 13 |
+
|
| 14 |
+
runTests(flags, t);
|
| 15 |
+
|
| 16 |
+
t.end();
|
| 17 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp.prototype.flags/test/shimmed.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
require('../auto');
|
| 4 |
+
|
| 5 |
+
var test = require('tape');
|
| 6 |
+
var defineProperties = require('define-properties');
|
| 7 |
+
var callBind = require('call-bind');
|
| 8 |
+
|
| 9 |
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
| 10 |
+
var functionsHaveNames = require('functions-have-names')();
|
| 11 |
+
var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames();
|
| 12 |
+
var hasStrictMode = require('has-strict-mode')();
|
| 13 |
+
|
| 14 |
+
var runTests = require('./tests');
|
| 15 |
+
|
| 16 |
+
test('shimmed', function (t) {
|
| 17 |
+
var descriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, 'flags');
|
| 18 |
+
|
| 19 |
+
t.equal(descriptor.get.length, 0, 'RegExp#flags getter has a length of 0');
|
| 20 |
+
|
| 21 |
+
t.test('Function name', { skip: !functionsHaveNames }, function (st) {
|
| 22 |
+
st.equal(descriptor.get.name, functionsHaveConfigurableNames ? 'get flags' : 'flags', 'RegExp#flags getter has name "get flags" (or "flags" if function names are not configurable)');
|
| 23 |
+
st.end();
|
| 24 |
+
});
|
| 25 |
+
|
| 26 |
+
t.test('enumerability', { skip: !defineProperties.supportsDescriptors }, function (et) {
|
| 27 |
+
et.equal(false, isEnumerable.call(RegExp.prototype, 'flags'), 'RegExp#flags is not enumerable');
|
| 28 |
+
et.end();
|
| 29 |
+
});
|
| 30 |
+
|
| 31 |
+
t.test('bad array/this value', { skip: !hasStrictMode }, function (st) {
|
| 32 |
+
st['throws'](function () { return descriptor.get.call(undefined); }, TypeError, 'undefined is not an object');
|
| 33 |
+
st['throws'](function () { return descriptor.get.call(null); }, TypeError, 'null is not an object');
|
| 34 |
+
st.end();
|
| 35 |
+
});
|
| 36 |
+
|
| 37 |
+
t.test('has the correct descriptor', function (st) {
|
| 38 |
+
st.equal(descriptor.configurable, true);
|
| 39 |
+
st.equal(descriptor.enumerable, false);
|
| 40 |
+
st.equal(typeof descriptor.get, 'function');
|
| 41 |
+
st.equal(descriptor.set, undefined);
|
| 42 |
+
st.end();
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
runTests(callBind(descriptor.get), t);
|
| 46 |
+
|
| 47 |
+
t.end();
|
| 48 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/regexp.prototype.flags/test/tests.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var hasOwn = require('hasown');
|
| 4 |
+
var inspect = require('object-inspect');
|
| 5 |
+
var supportsDescriptors = require('define-properties').supportsDescriptors;
|
| 6 |
+
var v = require('es-value-fixtures');
|
| 7 |
+
|
| 8 |
+
var forEach = require('for-each');
|
| 9 |
+
var availableFlags = require('available-regexp-flags');
|
| 10 |
+
var regexProperties = require('available-regexp-flags/properties');
|
| 11 |
+
|
| 12 |
+
var sortedFlags = availableFlags.slice().sort(function (a, b) { return a.localeCompare(b); }).join('');
|
| 13 |
+
|
| 14 |
+
var getRegexLiteral = function (stringRegex) {
|
| 15 |
+
try {
|
| 16 |
+
// eslint-disable-next-line no-new-func
|
| 17 |
+
return Function('return ' + stringRegex + ';')();
|
| 18 |
+
} catch (e) { /**/ }
|
| 19 |
+
return null;
|
| 20 |
+
};
|
| 21 |
+
|
| 22 |
+
module.exports = function runTests(flags, t) {
|
| 23 |
+
forEach(v.primitives, function (nonObject) {
|
| 24 |
+
t['throws'](
|
| 25 |
+
function () { flags(nonObject); },
|
| 26 |
+
TypeError,
|
| 27 |
+
'throws when called with a non-object receiver: ' + inspect(nonObject)
|
| 28 |
+
);
|
| 29 |
+
});
|
| 30 |
+
|
| 31 |
+
t.equal(flags(/a/g), 'g', 'flags(/a/g) !== "g"');
|
| 32 |
+
t.equal(flags(/a/gmi), 'gim', 'flags(/a/gmi) !== "gim"');
|
| 33 |
+
t.equal(flags(new RegExp('a', 'gmi')), 'gim', 'flags(new RegExp("a", "gmi")) !== "gim"');
|
| 34 |
+
t.equal(flags(/a/), '', 'flags(/a/) !== ""');
|
| 35 |
+
t.equal(flags(new RegExp('a')), '', 'flags(new RegExp("a")) !== ""');
|
| 36 |
+
|
| 37 |
+
forEach(availableFlags, function (flag) {
|
| 38 |
+
var property = regexProperties[flag];
|
| 39 |
+
t.test(property + ' flag', function (st) {
|
| 40 |
+
st.equal(flags(getRegexLiteral('/a/' + flag)), flag, 'flags(/a/' + flag + ') !== ' + inspect(flag));
|
| 41 |
+
st.equal(flags(new RegExp('a', flag)), flag, 'flags(new RegExp("a", ' + inspect(flag) + ')) !== ' + inspect(flag));
|
| 42 |
+
st.end();
|
| 43 |
+
});
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
t.test('sorting', function (st) {
|
| 47 |
+
st.equal(flags(/a/gim), 'gim', 'flags(/a/gim) !== "gim"');
|
| 48 |
+
st.equal(flags(/a/mig), 'gim', 'flags(/a/mig) !== "gim"');
|
| 49 |
+
st.equal(flags(/a/mgi), 'gim', 'flags(/a/mgi) !== "gim"');
|
| 50 |
+
if (hasOwn(RegExp.prototype, 'sticky')) {
|
| 51 |
+
st.equal(flags(getRegexLiteral('/a/gyim')), 'gimy', 'flags(/a/gyim) !== "gimy"');
|
| 52 |
+
}
|
| 53 |
+
if (hasOwn(RegExp.prototype, 'unicode')) {
|
| 54 |
+
st.equal(flags(getRegexLiteral('/a/ugmi')), 'gimu', 'flags(/a/ugmi) !== "gimu"');
|
| 55 |
+
}
|
| 56 |
+
if (hasOwn(RegExp.prototype, 'dotAll')) {
|
| 57 |
+
st.equal(flags(getRegexLiteral('/a/sgmi')), 'gims', 'flags(/a/sgmi) !== "gims"');
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
var randomFlags = availableFlags.slice().sort(function () { return Math.random() > 0.5 ? 1 : -1; }).join('').replace('v', '');
|
| 61 |
+
st.equal(
|
| 62 |
+
flags(getRegexLiteral('/a/' + randomFlags)),
|
| 63 |
+
sortedFlags.replace('v', ''),
|
| 64 |
+
'random: flags(/a/' + randomFlags + ') === ' + inspect(sortedFlags)
|
| 65 |
+
);
|
| 66 |
+
|
| 67 |
+
st.end();
|
| 68 |
+
});
|
| 69 |
+
|
| 70 |
+
t.test('basic examples', function (st) {
|
| 71 |
+
st.equal(flags(/a/g), 'g', '(/a/g).flags !== "g"');
|
| 72 |
+
st.equal(flags(/a/gmi), 'gim', '(/a/gmi).flags !== "gim"');
|
| 73 |
+
st.equal(flags(new RegExp('a', 'gmi')), 'gim', 'new RegExp("a", "gmi").flags !== "gim"');
|
| 74 |
+
st.equal(flags(/a/), '', '(/a/).flags !== ""');
|
| 75 |
+
st.equal(flags(new RegExp('a')), '', 'new RegExp("a").flags !== ""');
|
| 76 |
+
|
| 77 |
+
st.end();
|
| 78 |
+
});
|
| 79 |
+
|
| 80 |
+
t.test('generic flags', function (st) {
|
| 81 |
+
st.equal(flags({}), '');
|
| 82 |
+
st.equal(flags({ ignoreCase: true }), 'i');
|
| 83 |
+
st.equal(flags({ dotAll: 1, global: 0, sticky: 1, unicode: 1 }), 'suy');
|
| 84 |
+
st.equal(flags({ __proto__: { multiline: true } }), 'm');
|
| 85 |
+
|
| 86 |
+
var obj = {};
|
| 87 |
+
forEach(availableFlags, function (flag) {
|
| 88 |
+
if (flag !== 'v') {
|
| 89 |
+
obj[regexProperties[flag]] = true;
|
| 90 |
+
}
|
| 91 |
+
});
|
| 92 |
+
st.equal(flags(obj), sortedFlags.replace('v', ''), 'an object with every available flag: ' + sortedFlags);
|
| 93 |
+
|
| 94 |
+
st.end();
|
| 95 |
+
});
|
| 96 |
+
|
| 97 |
+
t.test('getters', { skip: !supportsDescriptors }, function (st) {
|
| 98 |
+
/* eslint getter-return: 0 */
|
| 99 |
+
var calls = '';
|
| 100 |
+
var re = {};
|
| 101 |
+
Object.defineProperty(re, 'hasIndices', {
|
| 102 |
+
get: function () {
|
| 103 |
+
calls += 'd';
|
| 104 |
+
}
|
| 105 |
+
});
|
| 106 |
+
Object.defineProperty(re, 'global', {
|
| 107 |
+
get: function () {
|
| 108 |
+
calls += 'g';
|
| 109 |
+
}
|
| 110 |
+
});
|
| 111 |
+
Object.defineProperty(re, 'ignoreCase', {
|
| 112 |
+
get: function () {
|
| 113 |
+
calls += 'i';
|
| 114 |
+
}
|
| 115 |
+
});
|
| 116 |
+
Object.defineProperty(re, 'multiline', {
|
| 117 |
+
get: function () {
|
| 118 |
+
calls += 'm';
|
| 119 |
+
}
|
| 120 |
+
});
|
| 121 |
+
Object.defineProperty(re, 'dotAll', {
|
| 122 |
+
get: function () {
|
| 123 |
+
calls += 's';
|
| 124 |
+
}
|
| 125 |
+
});
|
| 126 |
+
Object.defineProperty(re, 'unicode', {
|
| 127 |
+
get: function () {
|
| 128 |
+
calls += 'u';
|
| 129 |
+
}
|
| 130 |
+
});
|
| 131 |
+
Object.defineProperty(re, 'sticky', {
|
| 132 |
+
get: function () {
|
| 133 |
+
calls += 'y';
|
| 134 |
+
}
|
| 135 |
+
});
|
| 136 |
+
|
| 137 |
+
flags(re);
|
| 138 |
+
|
| 139 |
+
st.equal(calls, 'dgimsuy', 'getters are called in expected order');
|
| 140 |
+
|
| 141 |
+
st.end();
|
| 142 |
+
});
|
| 143 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve-pkg-maps/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const d=r=>r!==null&&typeof r=="object",s=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),g="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",P="ERR_PACKAGE_IMPORT_NOT_DEFINED",R=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,u=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,n,o,c)=>{if(t==null)return[];if(typeof t=="string"){const[e,...i]=t.split(u);if(e===".."||i.some(l=>O.test(l)))throw s(E,`Invalid "${r}" target "${t}" defined in the package config`);return[c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(e=>f(r,e,n,o,c));if(d(t)){for(const e of Object.keys(t)){if(R.test(e))throw s(g,"Cannot contain numeric property keys");if(e==="default"||o.includes(e))return f(r,t[e],n,o,c)}return[]}throw s(E,`Invalid "${r}" target "${t}"`)},a="*",v=(r,t)=>{const n=r.indexOf(a),o=t.indexOf(a);return n===o?t.length>r.length:o>n};function A(r,t){if(!t.includes(a)&&r.hasOwnProperty(t))return[t];let n,o;for(const c of Object.keys(r))if(c.includes(a)){const[e,i,l]=c.split(a);if(l===void 0&&t.startsWith(e)&&t.endsWith(i)){const _=t.slice(e.length,-i.length||void 0);_&&(!n||v(n,c))&&(n=c,o=_)}}return[n,o]}const p=r=>Object.keys(r).reduce((t,n)=>{const o=n===""||n[0]!==".";if(t===void 0||t===o)return o;throw s(g,'"exports" cannot contain some keys starting with "." and some not')},void 0),w=/^\w+:/,m=(r,t,n)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||d(r)&&p(r))&&(r={".":r});const[o,c]=A(r,t),e=f(h.Export,r[o],t,n,c);if(e.length===0)throw s(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of e)if(!i.startsWith("./")&&!w.test(i))throw s(E,`Invalid "exports" target "${i}" defined in the package config`);return e},T=(r,t,n)=>{if(!r)throw new Error('"imports" is required');const[o,c]=A(r,t),e=f(h.Import,r[o],t,n,c);if(e.length===0)throw s(P,`Package import specifier "${t}" is not defined in package`);return e};exports.resolveExports=m,exports.resolveImports=T;
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve-pkg-maps/dist/index.d.cts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
type PathConditionsMap = {
|
| 2 |
+
[condition: string]: PathConditions | null;
|
| 3 |
+
};
|
| 4 |
+
type PathOrMap = string | PathConditionsMap;
|
| 5 |
+
type PathConditions = PathOrMap | readonly PathOrMap[];
|
| 6 |
+
|
| 7 |
+
declare const resolveExports: (exports: PathConditions, request: string, conditions: readonly string[]) => string[];
|
| 8 |
+
|
| 9 |
+
declare const resolveImports: (imports: PathConditionsMap, request: string, conditions: readonly string[]) => string[];
|
| 10 |
+
|
| 11 |
+
export { PathConditions, PathConditionsMap, resolveExports, resolveImports };
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve-pkg-maps/dist/index.d.mts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
type PathConditionsMap = {
|
| 2 |
+
[condition: string]: PathConditions | null;
|
| 3 |
+
};
|
| 4 |
+
type PathOrMap = string | PathConditionsMap;
|
| 5 |
+
type PathConditions = PathOrMap | readonly PathOrMap[];
|
| 6 |
+
|
| 7 |
+
declare const resolveExports: (exports: PathConditions, request: string, conditions: readonly string[]) => string[];
|
| 8 |
+
|
| 9 |
+
declare const resolveImports: (imports: PathConditionsMap, request: string, conditions: readonly string[]) => string[];
|
| 10 |
+
|
| 11 |
+
export { PathConditions, PathConditionsMap, resolveExports, resolveImports };
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve-pkg-maps/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",P="ERR_PACKAGE_IMPORT_NOT_DEFINED",R=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,w=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,e,o,c)=>{if(t==null)return[];if(typeof t=="string"){const[n,...i]=t.split(w);if(n===".."||i.some(l=>O.test(l)))throw a(E,`Invalid "${r}" target "${t}" defined in the package config`);return[c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(n=>f(r,n,e,o,c));if(A(t)){for(const n of Object.keys(t)){if(R.test(n))throw a(_,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return[]}throw a(E,`Invalid "${r}" target "${t}"`)},s="*",m=(r,t)=>{const e=r.indexOf(s),o=t.indexOf(s);return e===o?t.length>r.length:o>e};function d(r,t){if(!t.includes(s)&&r.hasOwnProperty(t))return[t];let e,o;for(const c of Object.keys(r))if(c.includes(s)){const[n,i,l]=c.split(s);if(l===void 0&&t.startsWith(n)&&t.endsWith(i)){const g=t.slice(n.length,-i.length||void 0);g&&(!e||m(e,c))&&(e=c,o=g)}}return[e,o]}const p=r=>Object.keys(r).reduce((t,e)=>{const o=e===""||e[0]!==".";if(t===void 0||t===o)return o;throw a(_,'"exports" cannot contain some keys starting with "." and some not')},void 0),u=/^\w+:/,v=(r,t,e)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||A(r)&&p(r))&&(r={".":r});const[o,c]=d(r,t),n=f(h.Export,r[o],t,e,c);if(n.length===0)throw a(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u.test(i))throw a(E,`Invalid "exports" target "${i}" defined in the package config`);return n},T=(r,t,e)=>{if(!r)throw new Error('"imports" is required');const[o,c]=d(r,t),n=f(h.Import,r[o],t,e,c);if(n.length===0)throw a(P,`Package import specifier "${t}" is not defined in package`);return n};export{v as resolveExports,T as resolveImports};
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/.github/FUNDING.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# These are supported funding model platforms
|
| 2 |
+
|
| 3 |
+
github: [ljharb]
|
| 4 |
+
patreon: # Replace with a single Patreon username
|
| 5 |
+
open_collective: # Replace with a single Open Collective username
|
| 6 |
+
ko_fi: # Replace with a single Ko-fi username
|
| 7 |
+
tidelift: npm/resolve
|
| 8 |
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
| 9 |
+
liberapay: # Replace with a single Liberapay username
|
| 10 |
+
issuehunt: # Replace with a single IssueHunt username
|
| 11 |
+
otechie: # Replace with a single Otechie username
|
| 12 |
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/bin/resolve
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env node
|
| 2 |
+
|
| 3 |
+
'use strict';
|
| 4 |
+
|
| 5 |
+
var path = require('path');
|
| 6 |
+
var fs = require('fs');
|
| 7 |
+
|
| 8 |
+
if (
|
| 9 |
+
String(process.env.npm_lifecycle_script).slice(0, 8) !== 'resolve '
|
| 10 |
+
&& (
|
| 11 |
+
!process.argv
|
| 12 |
+
|| process.argv.length < 2
|
| 13 |
+
|| (process.argv[1] !== __filename && fs.statSync(process.argv[1]).ino !== fs.statSync(__filename).ino)
|
| 14 |
+
|| (process.env.npm_lifecycle_event !== 'npx' && process.env._ && fs.realpathSync(path.resolve(process.env._)) !== __filename)
|
| 15 |
+
)
|
| 16 |
+
) {
|
| 17 |
+
console.error('Error: `resolve` must be run directly as an executable');
|
| 18 |
+
process.exit(1);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
var supportsPreserveSymlinkFlag = require('supports-preserve-symlinks-flag');
|
| 22 |
+
|
| 23 |
+
var preserveSymlinks = false;
|
| 24 |
+
for (var i = 2; i < process.argv.length; i += 1) {
|
| 25 |
+
if (process.argv[i].slice(0, 2) === '--') {
|
| 26 |
+
if (supportsPreserveSymlinkFlag && process.argv[i] === '--preserve-symlinks') {
|
| 27 |
+
preserveSymlinks = true;
|
| 28 |
+
} else if (process.argv[i].length > 2) {
|
| 29 |
+
console.error('Unknown argument ' + process.argv[i].replace(/[=].*$/, ''));
|
| 30 |
+
process.exit(2);
|
| 31 |
+
}
|
| 32 |
+
process.argv.splice(i, 1);
|
| 33 |
+
i -= 1;
|
| 34 |
+
if (process.argv[i] === '--') { break; } // eslint-disable-line no-restricted-syntax
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
if (process.argv.length < 3) {
|
| 39 |
+
console.error('Error: `resolve` expects a specifier');
|
| 40 |
+
process.exit(2);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
var resolve = require('../');
|
| 44 |
+
|
| 45 |
+
var result = resolve.sync(process.argv[2], {
|
| 46 |
+
basedir: process.cwd(),
|
| 47 |
+
preserveSymlinks: preserveSymlinks
|
| 48 |
+
});
|
| 49 |
+
|
| 50 |
+
console.log(result);
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/example/async.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var resolve = require('../');
|
| 2 |
+
resolve('tap', { basedir: __dirname }, function (err, res) {
|
| 3 |
+
if (err) console.error(err);
|
| 4 |
+
else console.log(res);
|
| 5 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/example/sync.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var resolve = require('../');
|
| 2 |
+
var res = resolve.sync('tap', { basedir: __dirname });
|
| 3 |
+
console.log(res);
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/async.js
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var fs = require('fs');
|
| 2 |
+
var getHomedir = require('./homedir');
|
| 3 |
+
var path = require('path');
|
| 4 |
+
var caller = require('./caller');
|
| 5 |
+
var nodeModulesPaths = require('./node-modules-paths');
|
| 6 |
+
var normalizeOptions = require('./normalize-options');
|
| 7 |
+
var isCore = require('is-core-module');
|
| 8 |
+
|
| 9 |
+
var realpathFS = process.platform !== 'win32' && fs.realpath && typeof fs.realpath.native === 'function' ? fs.realpath.native : fs.realpath;
|
| 10 |
+
|
| 11 |
+
var homedir = getHomedir();
|
| 12 |
+
var defaultPaths = function () {
|
| 13 |
+
return [
|
| 14 |
+
path.join(homedir, '.node_modules'),
|
| 15 |
+
path.join(homedir, '.node_libraries')
|
| 16 |
+
];
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
var defaultIsFile = function isFile(file, cb) {
|
| 20 |
+
fs.stat(file, function (err, stat) {
|
| 21 |
+
if (!err) {
|
| 22 |
+
return cb(null, stat.isFile() || stat.isFIFO());
|
| 23 |
+
}
|
| 24 |
+
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
|
| 25 |
+
return cb(err);
|
| 26 |
+
});
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
var defaultIsDir = function isDirectory(dir, cb) {
|
| 30 |
+
fs.stat(dir, function (err, stat) {
|
| 31 |
+
if (!err) {
|
| 32 |
+
return cb(null, stat.isDirectory());
|
| 33 |
+
}
|
| 34 |
+
if (err.code === 'ENOENT' || err.code === 'ENOTDIR') return cb(null, false);
|
| 35 |
+
return cb(err);
|
| 36 |
+
});
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
var defaultRealpath = function realpath(x, cb) {
|
| 40 |
+
realpathFS(x, function (realpathErr, realPath) {
|
| 41 |
+
if (realpathErr && realpathErr.code !== 'ENOENT') cb(realpathErr);
|
| 42 |
+
else cb(null, realpathErr ? x : realPath);
|
| 43 |
+
});
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
var maybeRealpath = function maybeRealpath(realpath, x, opts, cb) {
|
| 47 |
+
if (!opts || !opts.preserveSymlinks) {
|
| 48 |
+
realpath(x, cb);
|
| 49 |
+
} else {
|
| 50 |
+
cb(null, x);
|
| 51 |
+
}
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
var defaultReadPackage = function defaultReadPackage(readFile, pkgfile, cb) {
|
| 55 |
+
readFile(pkgfile, function (readFileErr, body) {
|
| 56 |
+
if (readFileErr) cb(readFileErr);
|
| 57 |
+
else {
|
| 58 |
+
try {
|
| 59 |
+
var pkg = JSON.parse(body);
|
| 60 |
+
cb(null, pkg);
|
| 61 |
+
} catch (jsonErr) {
|
| 62 |
+
cb(jsonErr);
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
});
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
var getPackageCandidates = function getPackageCandidates(x, start, opts) {
|
| 69 |
+
var dirs = nodeModulesPaths(start, opts, x);
|
| 70 |
+
for (var i = 0; i < dirs.length; i++) {
|
| 71 |
+
dirs[i] = path.join(dirs[i], x);
|
| 72 |
+
}
|
| 73 |
+
return dirs;
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
module.exports = function resolve(x, options, callback) {
|
| 77 |
+
var cb = callback;
|
| 78 |
+
var opts = options;
|
| 79 |
+
if (typeof options === 'function') {
|
| 80 |
+
cb = opts;
|
| 81 |
+
opts = {};
|
| 82 |
+
}
|
| 83 |
+
if (typeof x !== 'string') {
|
| 84 |
+
var err = new TypeError('Path must be a string.');
|
| 85 |
+
return process.nextTick(function () {
|
| 86 |
+
cb(err);
|
| 87 |
+
});
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
opts = normalizeOptions(x, opts);
|
| 91 |
+
|
| 92 |
+
var isFile = opts.isFile || defaultIsFile;
|
| 93 |
+
var isDirectory = opts.isDirectory || defaultIsDir;
|
| 94 |
+
var readFile = opts.readFile || fs.readFile;
|
| 95 |
+
var realpath = opts.realpath || defaultRealpath;
|
| 96 |
+
var readPackage = opts.readPackage || defaultReadPackage;
|
| 97 |
+
if (opts.readFile && opts.readPackage) {
|
| 98 |
+
var conflictErr = new TypeError('`readFile` and `readPackage` are mutually exclusive.');
|
| 99 |
+
return process.nextTick(function () {
|
| 100 |
+
cb(conflictErr);
|
| 101 |
+
});
|
| 102 |
+
}
|
| 103 |
+
var packageIterator = opts.packageIterator;
|
| 104 |
+
|
| 105 |
+
var extensions = opts.extensions || ['.js'];
|
| 106 |
+
var includeCoreModules = opts.includeCoreModules !== false;
|
| 107 |
+
var basedir = opts.basedir || path.dirname(caller());
|
| 108 |
+
var parent = opts.filename || basedir;
|
| 109 |
+
|
| 110 |
+
opts.paths = opts.paths || defaultPaths();
|
| 111 |
+
|
| 112 |
+
// ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
|
| 113 |
+
var absoluteStart = path.resolve(basedir);
|
| 114 |
+
|
| 115 |
+
maybeRealpath(
|
| 116 |
+
realpath,
|
| 117 |
+
absoluteStart,
|
| 118 |
+
opts,
|
| 119 |
+
function (err, realStart) {
|
| 120 |
+
if (err) cb(err);
|
| 121 |
+
else validateBasedir(realStart);
|
| 122 |
+
}
|
| 123 |
+
);
|
| 124 |
+
|
| 125 |
+
function validateBasedir(basedir) {
|
| 126 |
+
if (opts.basedir) {
|
| 127 |
+
var dirError = new TypeError('Provided basedir "' + basedir + '" is not a directory' + (opts.preserveSymlinks ? '' : ', or a symlink to a directory'));
|
| 128 |
+
dirError.code = 'INVALID_BASEDIR';
|
| 129 |
+
isDirectory(basedir, function (err, result) {
|
| 130 |
+
if (err) return cb(err);
|
| 131 |
+
if (!result) { return cb(dirError); }
|
| 132 |
+
validBasedir(basedir);
|
| 133 |
+
});
|
| 134 |
+
} else {
|
| 135 |
+
validBasedir(basedir);
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
var res;
|
| 140 |
+
function validBasedir(basedir) {
|
| 141 |
+
if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(x)) {
|
| 142 |
+
res = path.resolve(basedir, x);
|
| 143 |
+
if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
|
| 144 |
+
if ((/\/$/).test(x) && res === basedir) {
|
| 145 |
+
loadAsDirectory(res, opts.package, onfile);
|
| 146 |
+
} else loadAsFile(res, opts.package, onfile);
|
| 147 |
+
} else if (includeCoreModules && isCore(x)) {
|
| 148 |
+
return cb(null, x);
|
| 149 |
+
} else loadNodeModules(x, basedir, function (err, n, pkg) {
|
| 150 |
+
if (err) cb(err);
|
| 151 |
+
else if (n) {
|
| 152 |
+
return maybeRealpath(realpath, n, opts, function (err, realN) {
|
| 153 |
+
if (err) {
|
| 154 |
+
cb(err);
|
| 155 |
+
} else {
|
| 156 |
+
cb(null, realN, pkg);
|
| 157 |
+
}
|
| 158 |
+
});
|
| 159 |
+
} else {
|
| 160 |
+
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
| 161 |
+
moduleError.code = 'MODULE_NOT_FOUND';
|
| 162 |
+
cb(moduleError);
|
| 163 |
+
}
|
| 164 |
+
});
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
function onfile(err, m, pkg) {
|
| 168 |
+
if (err) cb(err);
|
| 169 |
+
else if (m) cb(null, m, pkg);
|
| 170 |
+
else loadAsDirectory(res, function (err, d, pkg) {
|
| 171 |
+
if (err) cb(err);
|
| 172 |
+
else if (d) {
|
| 173 |
+
maybeRealpath(realpath, d, opts, function (err, realD) {
|
| 174 |
+
if (err) {
|
| 175 |
+
cb(err);
|
| 176 |
+
} else {
|
| 177 |
+
cb(null, realD, pkg);
|
| 178 |
+
}
|
| 179 |
+
});
|
| 180 |
+
} else {
|
| 181 |
+
var moduleError = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
| 182 |
+
moduleError.code = 'MODULE_NOT_FOUND';
|
| 183 |
+
cb(moduleError);
|
| 184 |
+
}
|
| 185 |
+
});
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
function loadAsFile(x, thePackage, callback) {
|
| 189 |
+
var loadAsFilePackage = thePackage;
|
| 190 |
+
var cb = callback;
|
| 191 |
+
if (typeof loadAsFilePackage === 'function') {
|
| 192 |
+
cb = loadAsFilePackage;
|
| 193 |
+
loadAsFilePackage = undefined;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
var exts = [''].concat(extensions);
|
| 197 |
+
load(exts, x, loadAsFilePackage);
|
| 198 |
+
|
| 199 |
+
function load(exts, x, loadPackage) {
|
| 200 |
+
if (exts.length === 0) return cb(null, undefined, loadPackage);
|
| 201 |
+
var file = x + exts[0];
|
| 202 |
+
|
| 203 |
+
var pkg = loadPackage;
|
| 204 |
+
if (pkg) onpkg(null, pkg);
|
| 205 |
+
else loadpkg(path.dirname(file), onpkg);
|
| 206 |
+
|
| 207 |
+
function onpkg(err, pkg_, dir) {
|
| 208 |
+
pkg = pkg_;
|
| 209 |
+
if (err) return cb(err);
|
| 210 |
+
if (dir && pkg && opts.pathFilter) {
|
| 211 |
+
var rfile = path.relative(dir, file);
|
| 212 |
+
var rel = rfile.slice(0, rfile.length - exts[0].length);
|
| 213 |
+
var r = opts.pathFilter(pkg, x, rel);
|
| 214 |
+
if (r) return load(
|
| 215 |
+
[''].concat(extensions.slice()),
|
| 216 |
+
path.resolve(dir, r),
|
| 217 |
+
pkg
|
| 218 |
+
);
|
| 219 |
+
}
|
| 220 |
+
isFile(file, onex);
|
| 221 |
+
}
|
| 222 |
+
function onex(err, ex) {
|
| 223 |
+
if (err) return cb(err);
|
| 224 |
+
if (ex) return cb(null, file, pkg);
|
| 225 |
+
load(exts.slice(1), x, pkg);
|
| 226 |
+
}
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
function loadpkg(dir, cb) {
|
| 231 |
+
if (dir === '' || dir === '/') return cb(null);
|
| 232 |
+
if (process.platform === 'win32' && (/^\w:[/\\]*$/).test(dir)) {
|
| 233 |
+
return cb(null);
|
| 234 |
+
}
|
| 235 |
+
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return cb(null);
|
| 236 |
+
|
| 237 |
+
maybeRealpath(realpath, dir, opts, function (unwrapErr, pkgdir) {
|
| 238 |
+
if (unwrapErr) return loadpkg(path.dirname(dir), cb);
|
| 239 |
+
var pkgfile = path.join(pkgdir, 'package.json');
|
| 240 |
+
isFile(pkgfile, function (err, ex) {
|
| 241 |
+
// on err, ex is false
|
| 242 |
+
if (!ex) return loadpkg(path.dirname(dir), cb);
|
| 243 |
+
|
| 244 |
+
readPackage(readFile, pkgfile, function (err, pkgParam) {
|
| 245 |
+
if (err && !(err instanceof SyntaxError)) cb(err);
|
| 246 |
+
|
| 247 |
+
var pkg = pkgParam;
|
| 248 |
+
|
| 249 |
+
if (pkg && opts.packageFilter) {
|
| 250 |
+
pkg = opts.packageFilter(pkg, pkgfile, dir);
|
| 251 |
+
}
|
| 252 |
+
cb(null, pkg, dir);
|
| 253 |
+
});
|
| 254 |
+
});
|
| 255 |
+
});
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
function loadAsDirectory(x, loadAsDirectoryPackage, callback) {
|
| 259 |
+
var cb = callback;
|
| 260 |
+
var fpkg = loadAsDirectoryPackage;
|
| 261 |
+
if (typeof fpkg === 'function') {
|
| 262 |
+
cb = fpkg;
|
| 263 |
+
fpkg = opts.package;
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
+
maybeRealpath(realpath, x, opts, function (unwrapErr, pkgdir) {
|
| 267 |
+
if (unwrapErr) return loadAsDirectory(path.dirname(x), fpkg, cb);
|
| 268 |
+
var pkgfile = path.join(pkgdir, 'package.json');
|
| 269 |
+
isFile(pkgfile, function (err, ex) {
|
| 270 |
+
if (err) return cb(err);
|
| 271 |
+
if (!ex) return loadAsFile(path.join(x, 'index'), fpkg, cb);
|
| 272 |
+
|
| 273 |
+
readPackage(readFile, pkgfile, function (err, pkgParam) {
|
| 274 |
+
if (err) return cb(err);
|
| 275 |
+
|
| 276 |
+
var pkg = pkgParam;
|
| 277 |
+
|
| 278 |
+
if (pkg && opts.packageFilter) {
|
| 279 |
+
pkg = opts.packageFilter(pkg, pkgfile, pkgdir);
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
if (pkg && pkg.main) {
|
| 283 |
+
if (typeof pkg.main !== 'string') {
|
| 284 |
+
var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
|
| 285 |
+
mainError.code = 'INVALID_PACKAGE_MAIN';
|
| 286 |
+
return cb(mainError);
|
| 287 |
+
}
|
| 288 |
+
if (pkg.main === '.' || pkg.main === './') {
|
| 289 |
+
pkg.main = 'index';
|
| 290 |
+
}
|
| 291 |
+
loadAsFile(path.resolve(x, pkg.main), pkg, function (err, m, pkg) {
|
| 292 |
+
if (err) return cb(err);
|
| 293 |
+
if (m) return cb(null, m, pkg);
|
| 294 |
+
if (!pkg) return loadAsFile(path.join(x, 'index'), pkg, cb);
|
| 295 |
+
|
| 296 |
+
var dir = path.resolve(x, pkg.main);
|
| 297 |
+
loadAsDirectory(dir, pkg, function (err, n, pkg) {
|
| 298 |
+
if (err) return cb(err);
|
| 299 |
+
if (n) return cb(null, n, pkg);
|
| 300 |
+
loadAsFile(path.join(x, 'index'), pkg, function (err, m, pkg) {
|
| 301 |
+
if (err) return cb(err);
|
| 302 |
+
if (m) return cb(null, m, pkg);
|
| 303 |
+
var incorrectMainError = new Error("Cannot find module '" + path.resolve(x, pkg.main) + "'. Please verify that the package.json has a valid \"main\" entry");
|
| 304 |
+
incorrectMainError.code = 'INCORRECT_PACKAGE_MAIN';
|
| 305 |
+
return cb(incorrectMainError);
|
| 306 |
+
});
|
| 307 |
+
});
|
| 308 |
+
});
|
| 309 |
+
return;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
loadAsFile(path.join(x, '/index'), pkg, cb);
|
| 313 |
+
});
|
| 314 |
+
});
|
| 315 |
+
});
|
| 316 |
+
}
|
| 317 |
+
|
| 318 |
+
function processDirs(cb, dirs) {
|
| 319 |
+
if (dirs.length === 0) return cb(null, undefined);
|
| 320 |
+
var dir = dirs[0];
|
| 321 |
+
|
| 322 |
+
isDirectory(path.dirname(dir), isdir);
|
| 323 |
+
|
| 324 |
+
function isdir(err, isdir) {
|
| 325 |
+
if (err) return cb(err);
|
| 326 |
+
if (!isdir) return processDirs(cb, dirs.slice(1));
|
| 327 |
+
loadAsFile(dir, opts.package, onfile);
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
function onfile(err, m, pkg) {
|
| 331 |
+
if (err) return cb(err);
|
| 332 |
+
if (m) return cb(null, m, pkg);
|
| 333 |
+
loadAsDirectory(dir, opts.package, ondir);
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
function ondir(err, n, pkg) {
|
| 337 |
+
if (err) return cb(err);
|
| 338 |
+
if (n) return cb(null, n, pkg);
|
| 339 |
+
processDirs(cb, dirs.slice(1));
|
| 340 |
+
}
|
| 341 |
+
}
|
| 342 |
+
function loadNodeModules(x, start, cb) {
|
| 343 |
+
var thunk = function () { return getPackageCandidates(x, start, opts); };
|
| 344 |
+
processDirs(
|
| 345 |
+
cb,
|
| 346 |
+
packageIterator ? packageIterator(x, start, thunk, opts) : thunk()
|
| 347 |
+
);
|
| 348 |
+
}
|
| 349 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/caller.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module.exports = function () {
|
| 2 |
+
// see https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi
|
| 3 |
+
var origPrepareStackTrace = Error.prepareStackTrace;
|
| 4 |
+
Error.prepareStackTrace = function (_, stack) { return stack; };
|
| 5 |
+
var stack = (new Error()).stack;
|
| 6 |
+
Error.prepareStackTrace = origPrepareStackTrace;
|
| 7 |
+
return stack[2].getFileName();
|
| 8 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/homedir.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var os = require('os');
|
| 4 |
+
|
| 5 |
+
// adapted from https://github.com/sindresorhus/os-homedir/blob/11e089f4754db38bb535e5a8416320c4446e8cfd/index.js
|
| 6 |
+
|
| 7 |
+
module.exports = os.homedir || function homedir() {
|
| 8 |
+
var home = process.env.HOME;
|
| 9 |
+
var user = process.env.LOGNAME || process.env.USER || process.env.LNAME || process.env.USERNAME;
|
| 10 |
+
|
| 11 |
+
if (process.platform === 'win32') {
|
| 12 |
+
return process.env.USERPROFILE || process.env.HOMEDRIVE + process.env.HOMEPATH || home || null;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
if (process.platform === 'darwin') {
|
| 16 |
+
return home || (user ? '/Users/' + user : null);
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
if (process.platform === 'linux') {
|
| 20 |
+
return home || (process.getuid() === 0 ? '/root' : (user ? '/home/' + user : null)); // eslint-disable-line no-extra-parens
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
return home || null;
|
| 24 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/node-modules-paths.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var path = require('path');
|
| 2 |
+
var parse = path.parse || require('path-parse'); // eslint-disable-line global-require
|
| 3 |
+
|
| 4 |
+
var getNodeModulesDirs = function getNodeModulesDirs(absoluteStart, modules) {
|
| 5 |
+
var prefix = '/';
|
| 6 |
+
if ((/^([A-Za-z]:)/).test(absoluteStart)) {
|
| 7 |
+
prefix = '';
|
| 8 |
+
} else if ((/^\\\\/).test(absoluteStart)) {
|
| 9 |
+
prefix = '\\\\';
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
var paths = [absoluteStart];
|
| 13 |
+
var parsed = parse(absoluteStart);
|
| 14 |
+
while (parsed.dir !== paths[paths.length - 1]) {
|
| 15 |
+
paths.push(parsed.dir);
|
| 16 |
+
parsed = parse(parsed.dir);
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
return paths.reduce(function (dirs, aPath) {
|
| 20 |
+
return dirs.concat(modules.map(function (moduleDir) {
|
| 21 |
+
return path.resolve(prefix, aPath, moduleDir);
|
| 22 |
+
}));
|
| 23 |
+
}, []);
|
| 24 |
+
};
|
| 25 |
+
|
| 26 |
+
module.exports = function nodeModulesPaths(start, opts, request) {
|
| 27 |
+
var modules = opts && opts.moduleDirectory
|
| 28 |
+
? [].concat(opts.moduleDirectory)
|
| 29 |
+
: ['node_modules'];
|
| 30 |
+
|
| 31 |
+
if (opts && typeof opts.paths === 'function') {
|
| 32 |
+
return opts.paths(
|
| 33 |
+
request,
|
| 34 |
+
start,
|
| 35 |
+
function () { return getNodeModulesDirs(start, modules); },
|
| 36 |
+
opts
|
| 37 |
+
);
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
var dirs = getNodeModulesDirs(start, modules);
|
| 41 |
+
return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
|
| 42 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/normalize-options.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module.exports = function (x, opts) {
|
| 2 |
+
/**
|
| 3 |
+
* This file is purposefully a passthrough. It's expected that third-party
|
| 4 |
+
* environments will override it at runtime in order to inject special logic
|
| 5 |
+
* into `resolve` (by manipulating the options). One such example is the PnP
|
| 6 |
+
* code path in Yarn.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
return opts || {};
|
| 10 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/lib/sync.js
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var isCore = require('is-core-module');
|
| 2 |
+
var fs = require('fs');
|
| 3 |
+
var path = require('path');
|
| 4 |
+
var getHomedir = require('./homedir');
|
| 5 |
+
var caller = require('./caller');
|
| 6 |
+
var nodeModulesPaths = require('./node-modules-paths');
|
| 7 |
+
var normalizeOptions = require('./normalize-options');
|
| 8 |
+
|
| 9 |
+
var realpathFS = process.platform !== 'win32' && fs.realpathSync && typeof fs.realpathSync.native === 'function' ? fs.realpathSync.native : fs.realpathSync;
|
| 10 |
+
|
| 11 |
+
var homedir = getHomedir();
|
| 12 |
+
var defaultPaths = function () {
|
| 13 |
+
return [
|
| 14 |
+
path.join(homedir, '.node_modules'),
|
| 15 |
+
path.join(homedir, '.node_libraries')
|
| 16 |
+
];
|
| 17 |
+
};
|
| 18 |
+
|
| 19 |
+
var defaultIsFile = function isFile(file) {
|
| 20 |
+
try {
|
| 21 |
+
var stat = fs.statSync(file, { throwIfNoEntry: false });
|
| 22 |
+
} catch (e) {
|
| 23 |
+
if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
|
| 24 |
+
throw e;
|
| 25 |
+
}
|
| 26 |
+
return !!stat && (stat.isFile() || stat.isFIFO());
|
| 27 |
+
};
|
| 28 |
+
|
| 29 |
+
var defaultIsDir = function isDirectory(dir) {
|
| 30 |
+
try {
|
| 31 |
+
var stat = fs.statSync(dir, { throwIfNoEntry: false });
|
| 32 |
+
} catch (e) {
|
| 33 |
+
if (e && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) return false;
|
| 34 |
+
throw e;
|
| 35 |
+
}
|
| 36 |
+
return !!stat && stat.isDirectory();
|
| 37 |
+
};
|
| 38 |
+
|
| 39 |
+
var defaultRealpathSync = function realpathSync(x) {
|
| 40 |
+
try {
|
| 41 |
+
return realpathFS(x);
|
| 42 |
+
} catch (realpathErr) {
|
| 43 |
+
if (realpathErr.code !== 'ENOENT') {
|
| 44 |
+
throw realpathErr;
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
return x;
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
var maybeRealpathSync = function maybeRealpathSync(realpathSync, x, opts) {
|
| 51 |
+
if (!opts || !opts.preserveSymlinks) {
|
| 52 |
+
return realpathSync(x);
|
| 53 |
+
}
|
| 54 |
+
return x;
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
var defaultReadPackageSync = function defaultReadPackageSync(readFileSync, pkgfile) {
|
| 58 |
+
return JSON.parse(readFileSync(pkgfile));
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
var getPackageCandidates = function getPackageCandidates(x, start, opts) {
|
| 62 |
+
var dirs = nodeModulesPaths(start, opts, x);
|
| 63 |
+
for (var i = 0; i < dirs.length; i++) {
|
| 64 |
+
dirs[i] = path.join(dirs[i], x);
|
| 65 |
+
}
|
| 66 |
+
return dirs;
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
module.exports = function resolveSync(x, options) {
|
| 70 |
+
if (typeof x !== 'string') {
|
| 71 |
+
throw new TypeError('Path must be a string.');
|
| 72 |
+
}
|
| 73 |
+
var opts = normalizeOptions(x, options);
|
| 74 |
+
|
| 75 |
+
var isFile = opts.isFile || defaultIsFile;
|
| 76 |
+
var isDirectory = opts.isDirectory || defaultIsDir;
|
| 77 |
+
var readFileSync = opts.readFileSync || fs.readFileSync;
|
| 78 |
+
var realpathSync = opts.realpathSync || defaultRealpathSync;
|
| 79 |
+
var readPackageSync = opts.readPackageSync || defaultReadPackageSync;
|
| 80 |
+
if (opts.readFileSync && opts.readPackageSync) {
|
| 81 |
+
throw new TypeError('`readFileSync` and `readPackageSync` are mutually exclusive.');
|
| 82 |
+
}
|
| 83 |
+
var packageIterator = opts.packageIterator;
|
| 84 |
+
|
| 85 |
+
var extensions = opts.extensions || ['.js'];
|
| 86 |
+
var includeCoreModules = opts.includeCoreModules !== false;
|
| 87 |
+
var basedir = opts.basedir || path.dirname(caller());
|
| 88 |
+
var parent = opts.filename || basedir;
|
| 89 |
+
|
| 90 |
+
opts.paths = opts.paths || defaultPaths();
|
| 91 |
+
|
| 92 |
+
// ensure that `basedir` is an absolute path at this point, resolving against the process' current working directory
|
| 93 |
+
var absoluteStart = maybeRealpathSync(realpathSync, path.resolve(basedir), opts);
|
| 94 |
+
|
| 95 |
+
if (opts.basedir && !isDirectory(absoluteStart)) {
|
| 96 |
+
var dirError = new TypeError('Provided basedir "' + opts.basedir + '" is not a directory' + (opts.preserveSymlinks ? '' : ', or a symlink to a directory'));
|
| 97 |
+
dirError.code = 'INVALID_BASEDIR';
|
| 98 |
+
throw dirError;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
if ((/^(?:\.\.?(?:\/|$)|\/|([A-Za-z]:)?[/\\])/).test(x)) {
|
| 102 |
+
var res = path.resolve(absoluteStart, x);
|
| 103 |
+
if (x === '.' || x === '..' || x.slice(-1) === '/') res += '/';
|
| 104 |
+
var m = loadAsFileSync(res) || loadAsDirectorySync(res);
|
| 105 |
+
if (m) return maybeRealpathSync(realpathSync, m, opts);
|
| 106 |
+
} else if (includeCoreModules && isCore(x)) {
|
| 107 |
+
return x;
|
| 108 |
+
} else {
|
| 109 |
+
var n = loadNodeModulesSync(x, absoluteStart);
|
| 110 |
+
if (n) return maybeRealpathSync(realpathSync, n, opts);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
var err = new Error("Cannot find module '" + x + "' from '" + parent + "'");
|
| 114 |
+
err.code = 'MODULE_NOT_FOUND';
|
| 115 |
+
throw err;
|
| 116 |
+
|
| 117 |
+
function loadAsFileSync(x) {
|
| 118 |
+
var pkg = loadpkg(path.dirname(x));
|
| 119 |
+
|
| 120 |
+
if (pkg && pkg.dir && pkg.pkg && opts.pathFilter) {
|
| 121 |
+
var rfile = path.relative(pkg.dir, x);
|
| 122 |
+
var r = opts.pathFilter(pkg.pkg, x, rfile);
|
| 123 |
+
if (r) {
|
| 124 |
+
x = path.resolve(pkg.dir, r); // eslint-disable-line no-param-reassign
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
if (isFile(x)) {
|
| 129 |
+
return x;
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
for (var i = 0; i < extensions.length; i++) {
|
| 133 |
+
var file = x + extensions[i];
|
| 134 |
+
if (isFile(file)) {
|
| 135 |
+
return file;
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
function loadpkg(dir) {
|
| 141 |
+
if (dir === '' || dir === '/') return;
|
| 142 |
+
if (process.platform === 'win32' && (/^\w:[/\\]*$/).test(dir)) {
|
| 143 |
+
return;
|
| 144 |
+
}
|
| 145 |
+
if ((/[/\\]node_modules[/\\]*$/).test(dir)) return;
|
| 146 |
+
|
| 147 |
+
var pkgfile = path.join(isDirectory(dir) ? maybeRealpathSync(realpathSync, dir, opts) : dir, 'package.json');
|
| 148 |
+
|
| 149 |
+
if (!isFile(pkgfile)) {
|
| 150 |
+
return loadpkg(path.dirname(dir));
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
var pkg;
|
| 154 |
+
try {
|
| 155 |
+
pkg = readPackageSync(readFileSync, pkgfile);
|
| 156 |
+
} catch (e) {
|
| 157 |
+
if (!(e instanceof SyntaxError)) {
|
| 158 |
+
throw e;
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
if (pkg && opts.packageFilter) {
|
| 163 |
+
pkg = opts.packageFilter(pkg, pkgfile, dir);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
return { pkg: pkg, dir: dir };
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
function loadAsDirectorySync(x) {
|
| 170 |
+
var pkgfile = path.join(isDirectory(x) ? maybeRealpathSync(realpathSync, x, opts) : x, '/package.json');
|
| 171 |
+
if (isFile(pkgfile)) {
|
| 172 |
+
try {
|
| 173 |
+
var pkg = readPackageSync(readFileSync, pkgfile);
|
| 174 |
+
} catch (e) {}
|
| 175 |
+
|
| 176 |
+
if (pkg && opts.packageFilter) {
|
| 177 |
+
pkg = opts.packageFilter(pkg, pkgfile, x);
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
if (pkg && pkg.main) {
|
| 181 |
+
if (typeof pkg.main !== 'string') {
|
| 182 |
+
var mainError = new TypeError('package “' + pkg.name + '” `main` must be a string');
|
| 183 |
+
mainError.code = 'INVALID_PACKAGE_MAIN';
|
| 184 |
+
throw mainError;
|
| 185 |
+
}
|
| 186 |
+
if (pkg.main === '.' || pkg.main === './') {
|
| 187 |
+
pkg.main = 'index';
|
| 188 |
+
}
|
| 189 |
+
try {
|
| 190 |
+
var mainPath = path.resolve(x, pkg.main);
|
| 191 |
+
var m = loadAsFileSync(mainPath);
|
| 192 |
+
if (m) return m;
|
| 193 |
+
var n = loadAsDirectorySync(mainPath);
|
| 194 |
+
if (n) return n;
|
| 195 |
+
var checkIndex = loadAsFileSync(path.resolve(x, 'index'));
|
| 196 |
+
if (checkIndex) return checkIndex;
|
| 197 |
+
} catch (e) { }
|
| 198 |
+
var incorrectMainError = new Error("Cannot find module '" + path.resolve(x, pkg.main) + "'. Please verify that the package.json has a valid \"main\" entry");
|
| 199 |
+
incorrectMainError.code = 'INCORRECT_PACKAGE_MAIN';
|
| 200 |
+
throw incorrectMainError;
|
| 201 |
+
}
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
return loadAsFileSync(path.join(x, '/index'));
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
function loadNodeModulesSync(x, start) {
|
| 208 |
+
var thunk = function () { return getPackageCandidates(x, start, opts); };
|
| 209 |
+
var dirs = packageIterator ? packageIterator(x, start, thunk, opts) : thunk();
|
| 210 |
+
|
| 211 |
+
for (var i = 0; i < dirs.length; i++) {
|
| 212 |
+
var dir = dirs[i];
|
| 213 |
+
if (isDirectory(path.dirname(dir))) {
|
| 214 |
+
var m = loadAsFileSync(dir);
|
| 215 |
+
if (m) return m;
|
| 216 |
+
var n = loadAsDirectorySync(dir);
|
| 217 |
+
if (n) return n;
|
| 218 |
+
}
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
};
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/dotdot.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var path = require('path');
|
| 2 |
+
var test = require('tape');
|
| 3 |
+
var resolve = require('../');
|
| 4 |
+
|
| 5 |
+
test('dotdot', function (t) {
|
| 6 |
+
t.plan(4);
|
| 7 |
+
var dir = path.join(__dirname, '/dotdot/abc');
|
| 8 |
+
|
| 9 |
+
resolve('..', { basedir: dir }, function (err, res, pkg) {
|
| 10 |
+
t.ifError(err);
|
| 11 |
+
t.equal(res, path.join(__dirname, 'dotdot/index.js'));
|
| 12 |
+
});
|
| 13 |
+
|
| 14 |
+
resolve('.', { basedir: dir }, function (err, res, pkg) {
|
| 15 |
+
t.ifError(err);
|
| 16 |
+
t.equal(res, path.join(dir, 'index.js'));
|
| 17 |
+
});
|
| 18 |
+
});
|
| 19 |
+
|
| 20 |
+
test('dotdot sync', function (t) {
|
| 21 |
+
t.plan(2);
|
| 22 |
+
var dir = path.join(__dirname, '/dotdot/abc');
|
| 23 |
+
|
| 24 |
+
var a = resolve.sync('..', { basedir: dir });
|
| 25 |
+
t.equal(a, path.join(__dirname, 'dotdot/index.js'));
|
| 26 |
+
|
| 27 |
+
var b = resolve.sync('.', { basedir: dir });
|
| 28 |
+
t.equal(b, path.join(dir, 'index.js'));
|
| 29 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/dotdot/abc/index.js
ADDED
|
File without changes
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/dotdot/index.js
ADDED
|
File without changes
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/faulty_basedir.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var test = require('tape');
|
| 2 |
+
var path = require('path');
|
| 3 |
+
var resolve = require('../');
|
| 4 |
+
|
| 5 |
+
test('faulty basedir must produce error in windows', { skip: process.platform !== 'win32' }, function (t) {
|
| 6 |
+
t.plan(1);
|
| 7 |
+
|
| 8 |
+
var resolverDir = 'C:\\a\\b\\c\\d';
|
| 9 |
+
|
| 10 |
+
resolve('tape/lib/test.js', { basedir: resolverDir }, function (err, res, pkg) {
|
| 11 |
+
t.equal(!!err, true);
|
| 12 |
+
});
|
| 13 |
+
});
|
| 14 |
+
|
| 15 |
+
test('non-existent basedir should not throw when preserveSymlinks is false', function (t) {
|
| 16 |
+
t.plan(2);
|
| 17 |
+
|
| 18 |
+
var opts = {
|
| 19 |
+
basedir: path.join(path.sep, 'unreal', 'path', 'that', 'does', 'not', 'exist'),
|
| 20 |
+
preserveSymlinks: false
|
| 21 |
+
};
|
| 22 |
+
|
| 23 |
+
var module = './dotdot/abc';
|
| 24 |
+
|
| 25 |
+
resolve(module, opts, function (err, res) {
|
| 26 |
+
t.equal(err.code, 'INVALID_BASEDIR');
|
| 27 |
+
t.equal(res, undefined);
|
| 28 |
+
});
|
| 29 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/filter.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var path = require('path');
|
| 2 |
+
var test = require('tape');
|
| 3 |
+
var resolve = require('../');
|
| 4 |
+
|
| 5 |
+
test('filter', function (t) {
|
| 6 |
+
t.plan(5);
|
| 7 |
+
var dir = path.join(__dirname, 'resolver');
|
| 8 |
+
var packageFilterArgs;
|
| 9 |
+
resolve('./baz', {
|
| 10 |
+
basedir: dir,
|
| 11 |
+
packageFilter: function (pkg, pkgfile, dir) {
|
| 12 |
+
pkg.main = 'doom'; // eslint-disable-line no-param-reassign
|
| 13 |
+
packageFilterArgs = [pkg, pkgfile, dir];
|
| 14 |
+
return pkg;
|
| 15 |
+
}
|
| 16 |
+
}, function (err, res, pkg) {
|
| 17 |
+
if (err) t.fail(err);
|
| 18 |
+
|
| 19 |
+
t.equal(res, path.join(dir, 'baz/doom.js'), 'changing the package "main" works');
|
| 20 |
+
|
| 21 |
+
var packageData = packageFilterArgs[0];
|
| 22 |
+
t.equal(pkg, packageData, 'first packageFilter argument is "pkg"');
|
| 23 |
+
t.equal(packageData.main, 'doom', 'package "main" was altered');
|
| 24 |
+
|
| 25 |
+
var packageFile = packageFilterArgs[1];
|
| 26 |
+
t.equal(
|
| 27 |
+
packageFile,
|
| 28 |
+
path.join(dir, 'baz/package.json'),
|
| 29 |
+
'second packageFilter argument is "pkgfile"'
|
| 30 |
+
);
|
| 31 |
+
|
| 32 |
+
var packageFileDir = packageFilterArgs[2];
|
| 33 |
+
t.equal(packageFileDir, path.join(dir, 'baz'), 'third packageFilter argument is "dir"');
|
| 34 |
+
|
| 35 |
+
t.end();
|
| 36 |
+
});
|
| 37 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/filter_sync.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var path = require('path');
|
| 2 |
+
var test = require('tape');
|
| 3 |
+
var resolve = require('../');
|
| 4 |
+
|
| 5 |
+
test('filter', function (t) {
|
| 6 |
+
var dir = path.join(__dirname, 'resolver');
|
| 7 |
+
var packageFilterArgs;
|
| 8 |
+
var res = resolve.sync('./baz', {
|
| 9 |
+
basedir: dir,
|
| 10 |
+
packageFilter: function (pkg, pkgfile, dir) {
|
| 11 |
+
pkg.main = 'doom'; // eslint-disable-line no-param-reassign
|
| 12 |
+
packageFilterArgs = [pkg, pkgfile, dir];
|
| 13 |
+
return pkg;
|
| 14 |
+
}
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
t.equal(res, path.join(dir, 'baz/doom.js'), 'changing the package "main" works');
|
| 18 |
+
|
| 19 |
+
var packageData = packageFilterArgs[0];
|
| 20 |
+
t.equal(packageData.main, 'doom', 'package "main" was altered');
|
| 21 |
+
|
| 22 |
+
var packageFile = packageFilterArgs[1];
|
| 23 |
+
t.equal(
|
| 24 |
+
packageFile,
|
| 25 |
+
path.join(dir, 'baz/package.json'),
|
| 26 |
+
'second packageFilter argument is "pkgfile"'
|
| 27 |
+
);
|
| 28 |
+
|
| 29 |
+
var packageDir = packageFilterArgs[2];
|
| 30 |
+
t.equal(packageDir, path.join(dir, 'baz'), 'third packageFilter argument is "dir"');
|
| 31 |
+
|
| 32 |
+
t.end();
|
| 33 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/home_paths.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var fs = require('fs');
|
| 4 |
+
var homedir = require('../lib/homedir');
|
| 5 |
+
var path = require('path');
|
| 6 |
+
|
| 7 |
+
var test = require('tape');
|
| 8 |
+
var mkdirp = require('mkdirp');
|
| 9 |
+
var rimraf = require('rimraf');
|
| 10 |
+
var mv = require('mv');
|
| 11 |
+
var copyDir = require('copy-dir');
|
| 12 |
+
var tmp = require('tmp');
|
| 13 |
+
|
| 14 |
+
var HOME = homedir();
|
| 15 |
+
|
| 16 |
+
var hnm = path.join(HOME, '.node_modules');
|
| 17 |
+
var hnl = path.join(HOME, '.node_libraries');
|
| 18 |
+
|
| 19 |
+
var resolve = require('../async');
|
| 20 |
+
|
| 21 |
+
function makeDir(t, dir, cb) {
|
| 22 |
+
mkdirp(dir, function (err) {
|
| 23 |
+
if (err) {
|
| 24 |
+
cb(err);
|
| 25 |
+
} else {
|
| 26 |
+
t.teardown(function cleanup() {
|
| 27 |
+
rimraf.sync(dir);
|
| 28 |
+
});
|
| 29 |
+
cb();
|
| 30 |
+
}
|
| 31 |
+
});
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function makeTempDir(t, dir, cb) {
|
| 35 |
+
if (fs.existsSync(dir)) {
|
| 36 |
+
var tmpResult = tmp.dirSync();
|
| 37 |
+
t.teardown(tmpResult.removeCallback);
|
| 38 |
+
var backup = path.join(tmpResult.name, path.basename(dir));
|
| 39 |
+
mv(dir, backup, function (err) {
|
| 40 |
+
if (err) {
|
| 41 |
+
cb(err);
|
| 42 |
+
} else {
|
| 43 |
+
t.teardown(function () {
|
| 44 |
+
mv(backup, dir, cb);
|
| 45 |
+
});
|
| 46 |
+
makeDir(t, dir, cb);
|
| 47 |
+
}
|
| 48 |
+
});
|
| 49 |
+
} else {
|
| 50 |
+
makeDir(t, dir, cb);
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
test('homedir module paths', function (t) {
|
| 55 |
+
t.plan(7);
|
| 56 |
+
|
| 57 |
+
makeTempDir(t, hnm, function (err) {
|
| 58 |
+
t.error(err, 'no error with HNM temp dir');
|
| 59 |
+
if (err) {
|
| 60 |
+
return t.end();
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
var bazHNMDir = path.join(hnm, 'baz');
|
| 64 |
+
var dotMainDir = path.join(hnm, 'dot_main');
|
| 65 |
+
copyDir.sync(path.join(__dirname, 'resolver/baz'), bazHNMDir);
|
| 66 |
+
copyDir.sync(path.join(__dirname, 'resolver/dot_main'), dotMainDir);
|
| 67 |
+
|
| 68 |
+
var bazPkg = { name: 'baz', main: 'quux.js' };
|
| 69 |
+
var dotMainPkg = { main: 'index' };
|
| 70 |
+
|
| 71 |
+
var bazHNMmain = path.join(bazHNMDir, 'quux.js');
|
| 72 |
+
t.equal(require.resolve('baz'), bazHNMmain, 'sanity check: require.resolve finds HNM `baz`');
|
| 73 |
+
var dotMainMain = path.join(dotMainDir, 'index.js');
|
| 74 |
+
t.equal(require.resolve('dot_main'), dotMainMain, 'sanity check: require.resolve finds `dot_main`');
|
| 75 |
+
|
| 76 |
+
makeTempDir(t, hnl, function (err) {
|
| 77 |
+
t.error(err, 'no error with HNL temp dir');
|
| 78 |
+
if (err) {
|
| 79 |
+
return t.end();
|
| 80 |
+
}
|
| 81 |
+
var bazHNLDir = path.join(hnl, 'baz');
|
| 82 |
+
copyDir.sync(path.join(__dirname, 'resolver/baz'), bazHNLDir);
|
| 83 |
+
|
| 84 |
+
var dotSlashMainDir = path.join(hnl, 'dot_slash_main');
|
| 85 |
+
var dotSlashMainMain = path.join(dotSlashMainDir, 'index.js');
|
| 86 |
+
var dotSlashMainPkg = { main: 'index' };
|
| 87 |
+
copyDir.sync(path.join(__dirname, 'resolver/dot_slash_main'), dotSlashMainDir);
|
| 88 |
+
|
| 89 |
+
t.equal(require.resolve('baz'), bazHNMmain, 'sanity check: require.resolve finds HNM `baz`');
|
| 90 |
+
t.equal(require.resolve('dot_slash_main'), dotSlashMainMain, 'sanity check: require.resolve finds HNL `dot_slash_main`');
|
| 91 |
+
|
| 92 |
+
t.test('with temp dirs', function (st) {
|
| 93 |
+
st.plan(3);
|
| 94 |
+
|
| 95 |
+
st.test('just in `$HOME/.node_modules`', function (s2t) {
|
| 96 |
+
s2t.plan(3);
|
| 97 |
+
|
| 98 |
+
resolve('dot_main', function (err, res, pkg) {
|
| 99 |
+
s2t.error(err, 'no error resolving `dot_main`');
|
| 100 |
+
s2t.equal(res, dotMainMain, '`dot_main` resolves in `$HOME/.node_modules`');
|
| 101 |
+
s2t.deepEqual(pkg, dotMainPkg);
|
| 102 |
+
});
|
| 103 |
+
});
|
| 104 |
+
|
| 105 |
+
st.test('just in `$HOME/.node_libraries`', function (s2t) {
|
| 106 |
+
s2t.plan(3);
|
| 107 |
+
|
| 108 |
+
resolve('dot_slash_main', function (err, res, pkg) {
|
| 109 |
+
s2t.error(err, 'no error resolving `dot_slash_main`');
|
| 110 |
+
s2t.equal(res, dotSlashMainMain, '`dot_slash_main` resolves in `$HOME/.node_libraries`');
|
| 111 |
+
s2t.deepEqual(pkg, dotSlashMainPkg);
|
| 112 |
+
});
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
st.test('in `$HOME/.node_libraries` and `$HOME/.node_modules`', function (s2t) {
|
| 116 |
+
s2t.plan(3);
|
| 117 |
+
|
| 118 |
+
resolve('baz', function (err, res, pkg) {
|
| 119 |
+
s2t.error(err, 'no error resolving `baz`');
|
| 120 |
+
s2t.equal(res, bazHNMmain, '`baz` resolves in `$HOME/.node_modules` when in both');
|
| 121 |
+
s2t.deepEqual(pkg, bazPkg);
|
| 122 |
+
});
|
| 123 |
+
});
|
| 124 |
+
});
|
| 125 |
+
});
|
| 126 |
+
});
|
| 127 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/home_paths_sync.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'use strict';
|
| 2 |
+
|
| 3 |
+
var fs = require('fs');
|
| 4 |
+
var homedir = require('../lib/homedir');
|
| 5 |
+
var path = require('path');
|
| 6 |
+
|
| 7 |
+
var test = require('tape');
|
| 8 |
+
var mkdirp = require('mkdirp');
|
| 9 |
+
var rimraf = require('rimraf');
|
| 10 |
+
var mv = require('mv');
|
| 11 |
+
var copyDir = require('copy-dir');
|
| 12 |
+
var tmp = require('tmp');
|
| 13 |
+
|
| 14 |
+
var HOME = homedir();
|
| 15 |
+
|
| 16 |
+
var hnm = path.join(HOME, '.node_modules');
|
| 17 |
+
var hnl = path.join(HOME, '.node_libraries');
|
| 18 |
+
|
| 19 |
+
var resolve = require('../sync');
|
| 20 |
+
|
| 21 |
+
function makeDir(t, dir, cb) {
|
| 22 |
+
mkdirp(dir, function (err) {
|
| 23 |
+
if (err) {
|
| 24 |
+
cb(err);
|
| 25 |
+
} else {
|
| 26 |
+
t.teardown(function cleanup() {
|
| 27 |
+
rimraf.sync(dir);
|
| 28 |
+
});
|
| 29 |
+
cb();
|
| 30 |
+
}
|
| 31 |
+
});
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
function makeTempDir(t, dir, cb) {
|
| 35 |
+
if (fs.existsSync(dir)) {
|
| 36 |
+
var tmpResult = tmp.dirSync();
|
| 37 |
+
t.teardown(tmpResult.removeCallback);
|
| 38 |
+
var backup = path.join(tmpResult.name, path.basename(dir));
|
| 39 |
+
mv(dir, backup, function (err) {
|
| 40 |
+
if (err) {
|
| 41 |
+
cb(err);
|
| 42 |
+
} else {
|
| 43 |
+
t.teardown(function () {
|
| 44 |
+
mv(backup, dir, cb);
|
| 45 |
+
});
|
| 46 |
+
makeDir(t, dir, cb);
|
| 47 |
+
}
|
| 48 |
+
});
|
| 49 |
+
} else {
|
| 50 |
+
makeDir(t, dir, cb);
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
test('homedir module paths', function (t) {
|
| 55 |
+
t.plan(7);
|
| 56 |
+
|
| 57 |
+
makeTempDir(t, hnm, function (err) {
|
| 58 |
+
t.error(err, 'no error with HNM temp dir');
|
| 59 |
+
if (err) {
|
| 60 |
+
return t.end();
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
var bazHNMDir = path.join(hnm, 'baz');
|
| 64 |
+
var dotMainDir = path.join(hnm, 'dot_main');
|
| 65 |
+
copyDir.sync(path.join(__dirname, 'resolver/baz'), bazHNMDir);
|
| 66 |
+
copyDir.sync(path.join(__dirname, 'resolver/dot_main'), dotMainDir);
|
| 67 |
+
|
| 68 |
+
var bazHNMmain = path.join(bazHNMDir, 'quux.js');
|
| 69 |
+
t.equal(require.resolve('baz'), bazHNMmain, 'sanity check: require.resolve finds HNM `baz`');
|
| 70 |
+
var dotMainMain = path.join(dotMainDir, 'index.js');
|
| 71 |
+
t.equal(require.resolve('dot_main'), dotMainMain, 'sanity check: require.resolve finds `dot_main`');
|
| 72 |
+
|
| 73 |
+
makeTempDir(t, hnl, function (err) {
|
| 74 |
+
t.error(err, 'no error with HNL temp dir');
|
| 75 |
+
if (err) {
|
| 76 |
+
return t.end();
|
| 77 |
+
}
|
| 78 |
+
var bazHNLDir = path.join(hnl, 'baz');
|
| 79 |
+
copyDir.sync(path.join(__dirname, 'resolver/baz'), bazHNLDir);
|
| 80 |
+
|
| 81 |
+
var dotSlashMainDir = path.join(hnl, 'dot_slash_main');
|
| 82 |
+
var dotSlashMainMain = path.join(dotSlashMainDir, 'index.js');
|
| 83 |
+
copyDir.sync(path.join(__dirname, 'resolver/dot_slash_main'), dotSlashMainDir);
|
| 84 |
+
|
| 85 |
+
t.equal(require.resolve('baz'), bazHNMmain, 'sanity check: require.resolve finds HNM `baz`');
|
| 86 |
+
t.equal(require.resolve('dot_slash_main'), dotSlashMainMain, 'sanity check: require.resolve finds HNL `dot_slash_main`');
|
| 87 |
+
|
| 88 |
+
t.test('with temp dirs', function (st) {
|
| 89 |
+
st.plan(3);
|
| 90 |
+
|
| 91 |
+
st.test('just in `$HOME/.node_modules`', function (s2t) {
|
| 92 |
+
s2t.plan(1);
|
| 93 |
+
|
| 94 |
+
var res = resolve('dot_main');
|
| 95 |
+
s2t.equal(res, dotMainMain, '`dot_main` resolves in `$HOME/.node_modules`');
|
| 96 |
+
});
|
| 97 |
+
|
| 98 |
+
st.test('just in `$HOME/.node_libraries`', function (s2t) {
|
| 99 |
+
s2t.plan(1);
|
| 100 |
+
|
| 101 |
+
var res = resolve('dot_slash_main');
|
| 102 |
+
s2t.equal(res, dotSlashMainMain, '`dot_slash_main` resolves in `$HOME/.node_libraries`');
|
| 103 |
+
});
|
| 104 |
+
|
| 105 |
+
st.test('in `$HOME/.node_libraries` and `$HOME/.node_modules`', function (s2t) {
|
| 106 |
+
s2t.plan(1);
|
| 107 |
+
|
| 108 |
+
var res = resolve('baz');
|
| 109 |
+
s2t.equal(res, bazHNMmain, '`baz` resolves in `$HOME/.node_modules` when in both');
|
| 110 |
+
});
|
| 111 |
+
});
|
| 112 |
+
});
|
| 113 |
+
});
|
| 114 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/mock.js
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var path = require('path');
|
| 2 |
+
var test = require('tape');
|
| 3 |
+
var resolve = require('../');
|
| 4 |
+
|
| 5 |
+
test('mock', function (t) {
|
| 6 |
+
t.plan(8);
|
| 7 |
+
|
| 8 |
+
var files = {};
|
| 9 |
+
files[path.resolve('/foo/bar/baz.js')] = 'beep';
|
| 10 |
+
|
| 11 |
+
var dirs = {};
|
| 12 |
+
dirs[path.resolve('/foo/bar')] = true;
|
| 13 |
+
|
| 14 |
+
function opts(basedir) {
|
| 15 |
+
return {
|
| 16 |
+
basedir: path.resolve(basedir),
|
| 17 |
+
isFile: function (file, cb) {
|
| 18 |
+
cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
|
| 19 |
+
},
|
| 20 |
+
isDirectory: function (dir, cb) {
|
| 21 |
+
cb(null, !!dirs[path.resolve(dir)]);
|
| 22 |
+
},
|
| 23 |
+
readFile: function (file, cb) {
|
| 24 |
+
cb(null, files[path.resolve(file)]);
|
| 25 |
+
},
|
| 26 |
+
realpath: function (file, cb) {
|
| 27 |
+
cb(null, file);
|
| 28 |
+
}
|
| 29 |
+
};
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
resolve('./baz', opts('/foo/bar'), function (err, res, pkg) {
|
| 33 |
+
if (err) return t.fail(err);
|
| 34 |
+
t.equal(res, path.resolve('/foo/bar/baz.js'));
|
| 35 |
+
t.equal(pkg, undefined);
|
| 36 |
+
});
|
| 37 |
+
|
| 38 |
+
resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) {
|
| 39 |
+
if (err) return t.fail(err);
|
| 40 |
+
t.equal(res, path.resolve('/foo/bar/baz.js'));
|
| 41 |
+
t.equal(pkg, undefined);
|
| 42 |
+
});
|
| 43 |
+
|
| 44 |
+
resolve('baz', opts('/foo/bar'), function (err, res) {
|
| 45 |
+
t.equal(err.message, "Cannot find module 'baz' from '" + path.resolve('/foo/bar') + "'");
|
| 46 |
+
t.equal(err.code, 'MODULE_NOT_FOUND');
|
| 47 |
+
});
|
| 48 |
+
|
| 49 |
+
resolve('../baz', opts('/foo/bar'), function (err, res) {
|
| 50 |
+
t.equal(err.message, "Cannot find module '../baz' from '" + path.resolve('/foo/bar') + "'");
|
| 51 |
+
t.equal(err.code, 'MODULE_NOT_FOUND');
|
| 52 |
+
});
|
| 53 |
+
});
|
| 54 |
+
|
| 55 |
+
test('mock from package', function (t) {
|
| 56 |
+
t.plan(8);
|
| 57 |
+
|
| 58 |
+
var files = {};
|
| 59 |
+
files[path.resolve('/foo/bar/baz.js')] = 'beep';
|
| 60 |
+
|
| 61 |
+
var dirs = {};
|
| 62 |
+
dirs[path.resolve('/foo/bar')] = true;
|
| 63 |
+
|
| 64 |
+
function opts(basedir) {
|
| 65 |
+
return {
|
| 66 |
+
basedir: path.resolve(basedir),
|
| 67 |
+
isFile: function (file, cb) {
|
| 68 |
+
cb(null, Object.prototype.hasOwnProperty.call(files, file));
|
| 69 |
+
},
|
| 70 |
+
isDirectory: function (dir, cb) {
|
| 71 |
+
cb(null, !!dirs[path.resolve(dir)]);
|
| 72 |
+
},
|
| 73 |
+
'package': { main: 'bar' },
|
| 74 |
+
readFile: function (file, cb) {
|
| 75 |
+
cb(null, files[file]);
|
| 76 |
+
},
|
| 77 |
+
realpath: function (file, cb) {
|
| 78 |
+
cb(null, file);
|
| 79 |
+
}
|
| 80 |
+
};
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
resolve('./baz', opts('/foo/bar'), function (err, res, pkg) {
|
| 84 |
+
if (err) return t.fail(err);
|
| 85 |
+
t.equal(res, path.resolve('/foo/bar/baz.js'));
|
| 86 |
+
t.equal(pkg && pkg.main, 'bar');
|
| 87 |
+
});
|
| 88 |
+
|
| 89 |
+
resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) {
|
| 90 |
+
if (err) return t.fail(err);
|
| 91 |
+
t.equal(res, path.resolve('/foo/bar/baz.js'));
|
| 92 |
+
t.equal(pkg && pkg.main, 'bar');
|
| 93 |
+
});
|
| 94 |
+
|
| 95 |
+
resolve('baz', opts('/foo/bar'), function (err, res) {
|
| 96 |
+
t.equal(err.message, "Cannot find module 'baz' from '" + path.resolve('/foo/bar') + "'");
|
| 97 |
+
t.equal(err.code, 'MODULE_NOT_FOUND');
|
| 98 |
+
});
|
| 99 |
+
|
| 100 |
+
resolve('../baz', opts('/foo/bar'), function (err, res) {
|
| 101 |
+
t.equal(err.message, "Cannot find module '../baz' from '" + path.resolve('/foo/bar') + "'");
|
| 102 |
+
t.equal(err.code, 'MODULE_NOT_FOUND');
|
| 103 |
+
});
|
| 104 |
+
});
|
| 105 |
+
|
| 106 |
+
test('mock package', function (t) {
|
| 107 |
+
t.plan(2);
|
| 108 |
+
|
| 109 |
+
var files = {};
|
| 110 |
+
files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep';
|
| 111 |
+
files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
|
| 112 |
+
main: './baz.js'
|
| 113 |
+
});
|
| 114 |
+
|
| 115 |
+
var dirs = {};
|
| 116 |
+
dirs[path.resolve('/foo')] = true;
|
| 117 |
+
dirs[path.resolve('/foo/node_modules')] = true;
|
| 118 |
+
|
| 119 |
+
function opts(basedir) {
|
| 120 |
+
return {
|
| 121 |
+
basedir: path.resolve(basedir),
|
| 122 |
+
isFile: function (file, cb) {
|
| 123 |
+
cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
|
| 124 |
+
},
|
| 125 |
+
isDirectory: function (dir, cb) {
|
| 126 |
+
cb(null, !!dirs[path.resolve(dir)]);
|
| 127 |
+
},
|
| 128 |
+
readFile: function (file, cb) {
|
| 129 |
+
cb(null, files[path.resolve(file)]);
|
| 130 |
+
},
|
| 131 |
+
realpath: function (file, cb) {
|
| 132 |
+
cb(null, file);
|
| 133 |
+
}
|
| 134 |
+
};
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
resolve('bar', opts('/foo'), function (err, res, pkg) {
|
| 138 |
+
if (err) return t.fail(err);
|
| 139 |
+
t.equal(res, path.resolve('/foo/node_modules/bar/baz.js'));
|
| 140 |
+
t.equal(pkg && pkg.main, './baz.js');
|
| 141 |
+
});
|
| 142 |
+
});
|
| 143 |
+
|
| 144 |
+
test('mock package from package', function (t) {
|
| 145 |
+
t.plan(2);
|
| 146 |
+
|
| 147 |
+
var files = {};
|
| 148 |
+
files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep';
|
| 149 |
+
files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
|
| 150 |
+
main: './baz.js'
|
| 151 |
+
});
|
| 152 |
+
|
| 153 |
+
var dirs = {};
|
| 154 |
+
dirs[path.resolve('/foo')] = true;
|
| 155 |
+
dirs[path.resolve('/foo/node_modules')] = true;
|
| 156 |
+
|
| 157 |
+
function opts(basedir) {
|
| 158 |
+
return {
|
| 159 |
+
basedir: path.resolve(basedir),
|
| 160 |
+
isFile: function (file, cb) {
|
| 161 |
+
cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
|
| 162 |
+
},
|
| 163 |
+
isDirectory: function (dir, cb) {
|
| 164 |
+
cb(null, !!dirs[path.resolve(dir)]);
|
| 165 |
+
},
|
| 166 |
+
'package': { main: 'bar' },
|
| 167 |
+
readFile: function (file, cb) {
|
| 168 |
+
cb(null, files[path.resolve(file)]);
|
| 169 |
+
},
|
| 170 |
+
realpath: function (file, cb) {
|
| 171 |
+
cb(null, file);
|
| 172 |
+
}
|
| 173 |
+
};
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
resolve('bar', opts('/foo'), function (err, res, pkg) {
|
| 177 |
+
if (err) return t.fail(err);
|
| 178 |
+
t.equal(res, path.resolve('/foo/node_modules/bar/baz.js'));
|
| 179 |
+
t.equal(pkg && pkg.main, './baz.js');
|
| 180 |
+
});
|
| 181 |
+
});
|
| 182 |
+
|
| 183 |
+
test('symlinked', function (t) {
|
| 184 |
+
t.plan(4);
|
| 185 |
+
|
| 186 |
+
var files = {};
|
| 187 |
+
files[path.resolve('/foo/bar/baz.js')] = 'beep';
|
| 188 |
+
files[path.resolve('/foo/bar/symlinked/baz.js')] = 'beep';
|
| 189 |
+
|
| 190 |
+
var dirs = {};
|
| 191 |
+
dirs[path.resolve('/foo/bar')] = true;
|
| 192 |
+
dirs[path.resolve('/foo/bar/symlinked')] = true;
|
| 193 |
+
|
| 194 |
+
function opts(basedir) {
|
| 195 |
+
return {
|
| 196 |
+
preserveSymlinks: false,
|
| 197 |
+
basedir: path.resolve(basedir),
|
| 198 |
+
isFile: function (file, cb) {
|
| 199 |
+
cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
|
| 200 |
+
},
|
| 201 |
+
isDirectory: function (dir, cb) {
|
| 202 |
+
cb(null, !!dirs[path.resolve(dir)]);
|
| 203 |
+
},
|
| 204 |
+
readFile: function (file, cb) {
|
| 205 |
+
cb(null, files[path.resolve(file)]);
|
| 206 |
+
},
|
| 207 |
+
realpath: function (file, cb) {
|
| 208 |
+
var resolved = path.resolve(file);
|
| 209 |
+
|
| 210 |
+
if (resolved.indexOf('symlinked') >= 0) {
|
| 211 |
+
cb(null, resolved);
|
| 212 |
+
return;
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
var ext = path.extname(resolved);
|
| 216 |
+
|
| 217 |
+
if (ext) {
|
| 218 |
+
var dir = path.dirname(resolved);
|
| 219 |
+
var base = path.basename(resolved);
|
| 220 |
+
cb(null, path.join(dir, 'symlinked', base));
|
| 221 |
+
} else {
|
| 222 |
+
cb(null, path.join(resolved, 'symlinked'));
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
};
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
resolve('./baz', opts('/foo/bar'), function (err, res, pkg) {
|
| 229 |
+
if (err) return t.fail(err);
|
| 230 |
+
t.equal(res, path.resolve('/foo/bar/symlinked/baz.js'));
|
| 231 |
+
t.equal(pkg, undefined);
|
| 232 |
+
});
|
| 233 |
+
|
| 234 |
+
resolve('./baz.js', opts('/foo/bar'), function (err, res, pkg) {
|
| 235 |
+
if (err) return t.fail(err);
|
| 236 |
+
t.equal(res, path.resolve('/foo/bar/symlinked/baz.js'));
|
| 237 |
+
t.equal(pkg, undefined);
|
| 238 |
+
});
|
| 239 |
+
});
|
| 240 |
+
|
| 241 |
+
test('readPackage', function (t) {
|
| 242 |
+
t.plan(3);
|
| 243 |
+
|
| 244 |
+
var files = {};
|
| 245 |
+
files[path.resolve('/foo/node_modules/bar/something-else.js')] = 'beep';
|
| 246 |
+
files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
|
| 247 |
+
main: './baz.js'
|
| 248 |
+
});
|
| 249 |
+
files[path.resolve('/foo/node_modules/bar/baz.js')] = 'boop';
|
| 250 |
+
|
| 251 |
+
var dirs = {};
|
| 252 |
+
dirs[path.resolve('/foo')] = true;
|
| 253 |
+
dirs[path.resolve('/foo/node_modules')] = true;
|
| 254 |
+
|
| 255 |
+
function opts(basedir) {
|
| 256 |
+
return {
|
| 257 |
+
basedir: path.resolve(basedir),
|
| 258 |
+
isFile: function (file, cb) {
|
| 259 |
+
cb(null, Object.prototype.hasOwnProperty.call(files, path.resolve(file)));
|
| 260 |
+
},
|
| 261 |
+
isDirectory: function (dir, cb) {
|
| 262 |
+
cb(null, !!dirs[path.resolve(dir)]);
|
| 263 |
+
},
|
| 264 |
+
'package': { main: 'bar' },
|
| 265 |
+
readFile: function (file, cb) {
|
| 266 |
+
cb(null, files[path.resolve(file)]);
|
| 267 |
+
},
|
| 268 |
+
realpath: function (file, cb) {
|
| 269 |
+
cb(null, file);
|
| 270 |
+
}
|
| 271 |
+
};
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
t.test('with readFile', function (st) {
|
| 275 |
+
st.plan(3);
|
| 276 |
+
|
| 277 |
+
resolve('bar', opts('/foo'), function (err, res, pkg) {
|
| 278 |
+
st.error(err);
|
| 279 |
+
st.equal(res, path.resolve('/foo/node_modules/bar/baz.js'));
|
| 280 |
+
st.equal(pkg && pkg.main, './baz.js');
|
| 281 |
+
});
|
| 282 |
+
});
|
| 283 |
+
|
| 284 |
+
var readPackage = function (readFile, file, cb) {
|
| 285 |
+
var barPackage = path.join('bar', 'package.json');
|
| 286 |
+
if (file.slice(-barPackage.length) === barPackage) {
|
| 287 |
+
cb(null, { main: './something-else.js' });
|
| 288 |
+
} else {
|
| 289 |
+
cb(null, JSON.parse(files[path.resolve(file)]));
|
| 290 |
+
}
|
| 291 |
+
};
|
| 292 |
+
|
| 293 |
+
t.test('with readPackage', function (st) {
|
| 294 |
+
st.plan(3);
|
| 295 |
+
|
| 296 |
+
var options = opts('/foo');
|
| 297 |
+
delete options.readFile;
|
| 298 |
+
options.readPackage = readPackage;
|
| 299 |
+
resolve('bar', options, function (err, res, pkg) {
|
| 300 |
+
st.error(err);
|
| 301 |
+
st.equal(res, path.resolve('/foo/node_modules/bar/something-else.js'));
|
| 302 |
+
st.equal(pkg && pkg.main, './something-else.js');
|
| 303 |
+
});
|
| 304 |
+
});
|
| 305 |
+
|
| 306 |
+
t.test('with readFile and readPackage', function (st) {
|
| 307 |
+
st.plan(1);
|
| 308 |
+
|
| 309 |
+
var options = opts('/foo');
|
| 310 |
+
options.readPackage = readPackage;
|
| 311 |
+
resolve('bar', options, function (err) {
|
| 312 |
+
st.throws(function () { throw err; }, TypeError, 'errors when both readFile and readPackage are provided');
|
| 313 |
+
});
|
| 314 |
+
});
|
| 315 |
+
});
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/mock_sync.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var path = require('path');
|
| 2 |
+
var test = require('tape');
|
| 3 |
+
var resolve = require('../');
|
| 4 |
+
|
| 5 |
+
test('mock', function (t) {
|
| 6 |
+
t.plan(4);
|
| 7 |
+
|
| 8 |
+
var files = {};
|
| 9 |
+
files[path.resolve('/foo/bar/baz.js')] = 'beep';
|
| 10 |
+
|
| 11 |
+
var dirs = {};
|
| 12 |
+
dirs[path.resolve('/foo/bar')] = true;
|
| 13 |
+
dirs[path.resolve('/foo/node_modules')] = true;
|
| 14 |
+
|
| 15 |
+
function opts(basedir) {
|
| 16 |
+
return {
|
| 17 |
+
basedir: path.resolve(basedir),
|
| 18 |
+
isFile: function (file) {
|
| 19 |
+
return Object.prototype.hasOwnProperty.call(files, path.resolve(file));
|
| 20 |
+
},
|
| 21 |
+
isDirectory: function (dir) {
|
| 22 |
+
return !!dirs[path.resolve(dir)];
|
| 23 |
+
},
|
| 24 |
+
readFileSync: function (file) {
|
| 25 |
+
return files[path.resolve(file)];
|
| 26 |
+
},
|
| 27 |
+
realpathSync: function (file) {
|
| 28 |
+
return file;
|
| 29 |
+
}
|
| 30 |
+
};
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
t.equal(
|
| 34 |
+
resolve.sync('./baz', opts('/foo/bar')),
|
| 35 |
+
path.resolve('/foo/bar/baz.js')
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
+
t.equal(
|
| 39 |
+
resolve.sync('./baz.js', opts('/foo/bar')),
|
| 40 |
+
path.resolve('/foo/bar/baz.js')
|
| 41 |
+
);
|
| 42 |
+
|
| 43 |
+
t.throws(function () {
|
| 44 |
+
resolve.sync('baz', opts('/foo/bar'));
|
| 45 |
+
});
|
| 46 |
+
|
| 47 |
+
t.throws(function () {
|
| 48 |
+
resolve.sync('../baz', opts('/foo/bar'));
|
| 49 |
+
});
|
| 50 |
+
});
|
| 51 |
+
|
| 52 |
+
test('mock package', function (t) {
|
| 53 |
+
t.plan(1);
|
| 54 |
+
|
| 55 |
+
var files = {};
|
| 56 |
+
files[path.resolve('/foo/node_modules/bar/baz.js')] = 'beep';
|
| 57 |
+
files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
|
| 58 |
+
main: './baz.js'
|
| 59 |
+
});
|
| 60 |
+
|
| 61 |
+
var dirs = {};
|
| 62 |
+
dirs[path.resolve('/foo')] = true;
|
| 63 |
+
dirs[path.resolve('/foo/node_modules')] = true;
|
| 64 |
+
|
| 65 |
+
function opts(basedir) {
|
| 66 |
+
return {
|
| 67 |
+
basedir: path.resolve(basedir),
|
| 68 |
+
isFile: function (file) {
|
| 69 |
+
return Object.prototype.hasOwnProperty.call(files, path.resolve(file));
|
| 70 |
+
},
|
| 71 |
+
isDirectory: function (dir) {
|
| 72 |
+
return !!dirs[path.resolve(dir)];
|
| 73 |
+
},
|
| 74 |
+
readFileSync: function (file) {
|
| 75 |
+
return files[path.resolve(file)];
|
| 76 |
+
},
|
| 77 |
+
realpathSync: function (file) {
|
| 78 |
+
return file;
|
| 79 |
+
}
|
| 80 |
+
};
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
t.equal(
|
| 84 |
+
resolve.sync('bar', opts('/foo')),
|
| 85 |
+
path.resolve('/foo/node_modules/bar/baz.js')
|
| 86 |
+
);
|
| 87 |
+
});
|
| 88 |
+
|
| 89 |
+
test('symlinked', function (t) {
|
| 90 |
+
t.plan(2);
|
| 91 |
+
|
| 92 |
+
var files = {};
|
| 93 |
+
files[path.resolve('/foo/bar/baz.js')] = 'beep';
|
| 94 |
+
files[path.resolve('/foo/bar/symlinked/baz.js')] = 'beep';
|
| 95 |
+
|
| 96 |
+
var dirs = {};
|
| 97 |
+
dirs[path.resolve('/foo/bar')] = true;
|
| 98 |
+
dirs[path.resolve('/foo/bar/symlinked')] = true;
|
| 99 |
+
|
| 100 |
+
function opts(basedir) {
|
| 101 |
+
return {
|
| 102 |
+
preserveSymlinks: false,
|
| 103 |
+
basedir: path.resolve(basedir),
|
| 104 |
+
isFile: function (file) {
|
| 105 |
+
return Object.prototype.hasOwnProperty.call(files, path.resolve(file));
|
| 106 |
+
},
|
| 107 |
+
isDirectory: function (dir) {
|
| 108 |
+
return !!dirs[path.resolve(dir)];
|
| 109 |
+
},
|
| 110 |
+
readFileSync: function (file) {
|
| 111 |
+
return files[path.resolve(file)];
|
| 112 |
+
},
|
| 113 |
+
realpathSync: function (file) {
|
| 114 |
+
var resolved = path.resolve(file);
|
| 115 |
+
|
| 116 |
+
if (resolved.indexOf('symlinked') >= 0) {
|
| 117 |
+
return resolved;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
var ext = path.extname(resolved);
|
| 121 |
+
|
| 122 |
+
if (ext) {
|
| 123 |
+
var dir = path.dirname(resolved);
|
| 124 |
+
var base = path.basename(resolved);
|
| 125 |
+
return path.join(dir, 'symlinked', base);
|
| 126 |
+
}
|
| 127 |
+
return path.join(resolved, 'symlinked');
|
| 128 |
+
}
|
| 129 |
+
};
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
t.equal(
|
| 133 |
+
resolve.sync('./baz', opts('/foo/bar')),
|
| 134 |
+
path.resolve('/foo/bar/symlinked/baz.js')
|
| 135 |
+
);
|
| 136 |
+
|
| 137 |
+
t.equal(
|
| 138 |
+
resolve.sync('./baz.js', opts('/foo/bar')),
|
| 139 |
+
path.resolve('/foo/bar/symlinked/baz.js')
|
| 140 |
+
);
|
| 141 |
+
});
|
| 142 |
+
|
| 143 |
+
test('readPackageSync', function (t) {
|
| 144 |
+
t.plan(3);
|
| 145 |
+
|
| 146 |
+
var files = {};
|
| 147 |
+
files[path.resolve('/foo/node_modules/bar/something-else.js')] = 'beep';
|
| 148 |
+
files[path.resolve('/foo/node_modules/bar/package.json')] = JSON.stringify({
|
| 149 |
+
main: './baz.js'
|
| 150 |
+
});
|
| 151 |
+
files[path.resolve('/foo/node_modules/bar/baz.js')] = 'boop';
|
| 152 |
+
|
| 153 |
+
var dirs = {};
|
| 154 |
+
dirs[path.resolve('/foo')] = true;
|
| 155 |
+
dirs[path.resolve('/foo/node_modules')] = true;
|
| 156 |
+
|
| 157 |
+
function opts(basedir, useReadPackage) {
|
| 158 |
+
return {
|
| 159 |
+
basedir: path.resolve(basedir),
|
| 160 |
+
isFile: function (file) {
|
| 161 |
+
return Object.prototype.hasOwnProperty.call(files, path.resolve(file));
|
| 162 |
+
},
|
| 163 |
+
isDirectory: function (dir) {
|
| 164 |
+
return !!dirs[path.resolve(dir)];
|
| 165 |
+
},
|
| 166 |
+
readFileSync: useReadPackage ? null : function (file) {
|
| 167 |
+
return files[path.resolve(file)];
|
| 168 |
+
},
|
| 169 |
+
realpathSync: function (file) {
|
| 170 |
+
return file;
|
| 171 |
+
}
|
| 172 |
+
};
|
| 173 |
+
}
|
| 174 |
+
t.test('with readFile', function (st) {
|
| 175 |
+
st.plan(1);
|
| 176 |
+
|
| 177 |
+
st.equal(
|
| 178 |
+
resolve.sync('bar', opts('/foo')),
|
| 179 |
+
path.resolve('/foo/node_modules/bar/baz.js')
|
| 180 |
+
);
|
| 181 |
+
});
|
| 182 |
+
|
| 183 |
+
var readPackageSync = function (readFileSync, file) {
|
| 184 |
+
if (file.indexOf(path.join('bar', 'package.json')) >= 0) {
|
| 185 |
+
return { main: './something-else.js' };
|
| 186 |
+
}
|
| 187 |
+
return JSON.parse(files[path.resolve(file)]);
|
| 188 |
+
};
|
| 189 |
+
|
| 190 |
+
t.test('with readPackage', function (st) {
|
| 191 |
+
st.plan(1);
|
| 192 |
+
|
| 193 |
+
var options = opts('/foo');
|
| 194 |
+
delete options.readFileSync;
|
| 195 |
+
options.readPackageSync = readPackageSync;
|
| 196 |
+
|
| 197 |
+
st.equal(
|
| 198 |
+
resolve.sync('bar', options),
|
| 199 |
+
path.resolve('/foo/node_modules/bar/something-else.js')
|
| 200 |
+
);
|
| 201 |
+
});
|
| 202 |
+
|
| 203 |
+
t.test('with readFile and readPackage', function (st) {
|
| 204 |
+
st.plan(1);
|
| 205 |
+
|
| 206 |
+
var options = opts('/foo');
|
| 207 |
+
options.readPackageSync = readPackageSync;
|
| 208 |
+
st.throws(
|
| 209 |
+
function () { resolve.sync('bar', options); },
|
| 210 |
+
TypeError,
|
| 211 |
+
'errors when both readFile and readPackage are provided'
|
| 212 |
+
);
|
| 213 |
+
});
|
| 214 |
+
});
|
| 215 |
+
|
novas/novacore-zephyr/groq-code-cli/node_modules/resolve/test/module_dir.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
var path = require('path');
|
| 2 |
+
var test = require('tape');
|
| 3 |
+
var resolve = require('../');
|
| 4 |
+
|
| 5 |
+
test('moduleDirectory strings', function (t) {
|
| 6 |
+
t.plan(4);
|
| 7 |
+
var dir = path.join(__dirname, 'module_dir');
|
| 8 |
+
var xopts = {
|
| 9 |
+
basedir: dir,
|
| 10 |
+
moduleDirectory: 'xmodules'
|
| 11 |
+
};
|
| 12 |
+
resolve('aaa', xopts, function (err, res, pkg) {
|
| 13 |
+
t.ifError(err);
|
| 14 |
+
t.equal(res, path.join(dir, '/xmodules/aaa/index.js'));
|
| 15 |
+
});
|
| 16 |
+
|
| 17 |
+
var yopts = {
|
| 18 |
+
basedir: dir,
|
| 19 |
+
moduleDirectory: 'ymodules'
|
| 20 |
+
};
|
| 21 |
+
resolve('aaa', yopts, function (err, res, pkg) {
|
| 22 |
+
t.ifError(err);
|
| 23 |
+
t.equal(res, path.join(dir, '/ymodules/aaa/index.js'));
|
| 24 |
+
});
|
| 25 |
+
});
|
| 26 |
+
|
| 27 |
+
test('moduleDirectory array', function (t) {
|
| 28 |
+
t.plan(6);
|
| 29 |
+
var dir = path.join(__dirname, 'module_dir');
|
| 30 |
+
var aopts = {
|
| 31 |
+
basedir: dir,
|
| 32 |
+
moduleDirectory: ['xmodules', 'ymodules', 'zmodules']
|
| 33 |
+
};
|
| 34 |
+
resolve('aaa', aopts, function (err, res, pkg) {
|
| 35 |
+
t.ifError(err);
|
| 36 |
+
t.equal(res, path.join(dir, '/xmodules/aaa/index.js'));
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
var bopts = {
|
| 40 |
+
basedir: dir,
|
| 41 |
+
moduleDirectory: ['zmodules', 'ymodules', 'xmodules']
|
| 42 |
+
};
|
| 43 |
+
resolve('aaa', bopts, function (err, res, pkg) {
|
| 44 |
+
t.ifError(err);
|
| 45 |
+
t.equal(res, path.join(dir, '/ymodules/aaa/index.js'));
|
| 46 |
+
});
|
| 47 |
+
|
| 48 |
+
var copts = {
|
| 49 |
+
basedir: dir,
|
| 50 |
+
moduleDirectory: ['xmodules', 'ymodules', 'zmodules']
|
| 51 |
+
};
|
| 52 |
+
resolve('bbb', copts, function (err, res, pkg) {
|
| 53 |
+
t.ifError(err);
|
| 54 |
+
t.equal(res, path.join(dir, '/zmodules/bbb/main.js'));
|
| 55 |
+
});
|
| 56 |
+
});
|