Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}];
// AngularStub creates this variable to check the injections
lib.constants.MODULE = '$module';
var node = TestHelper.createFunctionNode(this.functionName, this.functionParams, annotationTags);
var code = Generator.generateCodeForNode(node);
var expectedParams = '[\'%1\']'.replace('%1', this.functionParams.join('\',\''));
var expectedCode = "%module.%type('%name', %value);\n%value.$inject=%injection;"
.replace('%module', '$module')
.replace('%type', dependencyType)
.replace('%name', this.dependencyName)
.replace(/%value/g, this.functionName)
.replace('%injection', expectedParams);
var codeTokens = esprima.tokenize(code),
expectedTokens = esprima.tokenize(expectedCode);
compareTokens(codeTokens, expectedTokens);
}
});
function handleFile(err, file) {
try {
esprima.tokenize(file, { loc: true, range: true, comment: true }, handleToken(instance, filePath));
} catch (err) { } // eslint-disable-line
next();
}
}
function tokenize(source) {
source = removeShebangLine(source);
/* TODO: retry on illegal tokens. */
const sourceType = deduceSourceType(source);
const tokens = esprima.tokenize(source, {
sourceType,
loc: true,
tolerant: true
});
return tokens;
}
function tokenize(source) {
source = removeShebangLine(source);
/* TODO: retry on illegal tokens. */
const sourceType = deduceSourceType(source);
const tokens = esprima.tokenize(source, {
sourceType,
loc: true,
tolerant: true
});
return tokens;
}
export function parseQueryForOverrides(queryText: string): Record {
const tokens: esprima.Token[] = esprima.tokenize(queryText, {comment: true})
let overrides: Record = {}
if (tokens.length > 0 && tokens[0].type === 'BlockComment') {
const firstBlockComment: string = tokens[0].value
const firstBlockCommentLine: string =
firstBlockComment.split(/\n+/)[0]
.replace(/\t+/g, '')
.trim()
if (firstBlockCommentLine.match(MLSETTINGSFLAG)) {
const overridePayload: string = firstBlockComment
.replace(MLSETTINGSFLAG, '')
.trim()
overrides = JSON.parse(overridePayload)
}
}
return overrides
}
return new Promise((resolve, reject) => {
if (!expression) return reject(new Error('Expression - eval() - expression is required'));
let astTokens = esprima.tokenize(expression);
let startTime = process.hrtime();
_eval(expression, scope)
.then(result => {
let time = _getTime(startTime);
let expressionResult = {
result: result,
time: time,
mongoMethodName: _getMongoMethodName(astTokens),
mongoCollectionName: _getMongoCollectionName(expression, astTokens)
};
if (_.isArray(expressionResult.result)) {
expressionResult.keyValueResults = keyValueUtils.convert(expressionResult.result);
function getTokens (string) {
let tokens = null
try { tokens = esprima.tokenize('`'+ string +'`') }
catch (e) { tokens = [] }
return tokens
}
}
}
else {
return '["' + context.items.type + '"]';
}
}
else {
return "[]";
}
}
else {
return schema;
}
}
var src = "a=" + resolveNested(schema, def, required);
var tokens = esprima.tokenize(src, { comment: true });
tmp = format(tokens, indent_num);
return unEscapeComment(tmp);
}
function getEsprimaTokens(code) {
var tokens = esprima.tokenize(code, {loc: true});
tokens.forEach(function(token) {
token.type = typeMap[token.type];
});
return tokens;
}
function jsTokensTokenize(string) {