1
0
Fork 0

fixed jslint warnings

This commit is contained in:
Jan Steemann 2014-01-15 18:06:17 +01:00
parent 69a6e6449e
commit 72902b2e62
1 changed files with 83 additions and 240 deletions

View File

@ -37,11 +37,6 @@ var ShapedJson = INTERNAL.ShapedJson;
// --SECTION-- private variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief cache for compiled regexes
////////////////////////////////////////////////////////////////////////////////
@ -65,19 +60,30 @@ var TYPEWEIGHT_STRING = 4;
var TYPEWEIGHT_LIST = 8;
var TYPEWEIGHT_DOCUMENT = 16;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- helper functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
/// @brief throw a runtime exception
////////////////////////////////////////////////////////////////////////////////
function THROW (error, data) {
"use strict";
var err = new ArangoError();
err.errorNum = error.code;
if (data) {
err.errorMessage = error.message.replace(/%s/, data);
}
else {
err.errorMessage = error.message;
}
throw err;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return a database-specific function prefix
////////////////////////////////////////////////////////////////////////////////
@ -86,6 +92,72 @@ function DB_PREFIX () {
return INTERNAL.db._name();
}
////////////////////////////////////////////////////////////////////////////////
/// @brief reset the regex cache
////////////////////////////////////////////////////////////////////////////////
function resetRegexCache () {
"use strict";
RegexCache = { 'i' : { }, '' : { } };
}
////////////////////////////////////////////////////////////////////////////////
/// @brief reset the user functions and reload them from the database
////////////////////////////////////////////////////////////////////////////////
function reloadUserFunctions () {
"use strict";
var c;
c = INTERNAL.db._collection("_aqlfunctions");
if (c === null) {
return;
}
var foundError = false;
var prefix = DB_PREFIX();
UserFunctions[prefix] = { };
c.toArray().forEach(function (f) {
var code = "(function() { var callback = " + f.code + "; return callback; })();";
var key = f._key.replace(/:{1,}/g, '::');
try {
var res = INTERNAL.executeScript(code, undefined, "(user function " + key + ")");
UserFunctions[prefix][key.toUpperCase()] = {
name: key,
func: res,
isDeterministic: f.isDeterministic || false
};
}
catch (err) {
foundError = true;
}
});
if (foundError) {
THROW(INTERNAL.errors.ERROR_QUERY_FUNCTION_INVALID_CODE);
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief reset the query engine
////////////////////////////////////////////////////////////////////////////////
function resetEngine () {
"use strict";
resetRegexCache();
reloadUserFunctions();
}
////////////////////////////////////////////////////////////////////////////////
/// @brief normalise a function name
////////////////////////////////////////////////////////////////////////////////
@ -126,26 +198,6 @@ function FILTER (list, examples) {
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief throw a runtime exception
////////////////////////////////////////////////////////////////////////////////
function THROW (error, data) {
"use strict";
var err = new ArangoError();
err.errorNum = error.code;
if (data) {
err.errorMessage = error.message.replace(/%s/, data);
}
else {
err.errorMessage = error.message;
}
throw err;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief find a fulltext index for a certain attribute & collection
////////////////////////////////////////////////////////////////////////////////
@ -1035,19 +1087,10 @@ function COLLECTIONS () {
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- logical operations
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief execute ternary operator
///
@ -1202,19 +1245,10 @@ function LOGICAL_NOT (lhs) {
return ! lhs;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- comparison operations
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief perform equality check
///
@ -1666,19 +1700,10 @@ function RELATIONAL_IN (lhs, rhs) {
return false;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- arithmetic operations
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief perform unary plus operation
///
@ -1839,19 +1864,10 @@ function ARITHMETIC_MODULUS (lhs, rhs) {
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- string functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief perform string concatenation
///
@ -2120,19 +2136,10 @@ function STRING_TRIM (value, type) {
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- typecast functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief cast to a bool
///
@ -2228,19 +2235,10 @@ function CAST_LIST (value) {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- typecheck functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief test if value is of type null
///
@ -2313,19 +2311,10 @@ function IS_DOCUMENT (value) {
return (TYPEWEIGHT(value) === TYPEWEIGHT_DOCUMENT);
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- numeric functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief integer closest to value, not greater than value
////////////////////////////////////////////////////////////////////////////////
@ -2406,19 +2395,10 @@ function NUMBER_SQRT (value) {
return NUMERIC_VALUE(Math.sqrt(value));
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- high level query functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief sort the results
////////////////////////////////////////////////////////////////////////////////
@ -2510,19 +2490,10 @@ function LIMIT (value, offset, count) {
return value.slice(offset, offset + count);
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- list processing functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief get the length of a list, document or string
////////////////////////////////////////////////////////////////////////////////
@ -3082,19 +3053,10 @@ function STDDEV_POPULATION (values) {
return NUMERIC_VALUE(Math.sqrt(result.value / result.n));
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- geo functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief return at most <limit> documents near a certain point
////////////////////////////////////////////////////////////////////////////////
@ -3156,19 +3118,10 @@ function GEO_WITHIN (collection, latitude, longitude, radius, distanceAttribute)
return documents;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- fulltext functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief return documents that match a fulltext query
////////////////////////////////////////////////////////////////////////////////
@ -3185,19 +3138,10 @@ function FULLTEXT (collection, attribute, query) {
return result.documents;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- misc functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief return the first alternative that's not null until there are no more
/// alternatives. if neither of the alternatives is a value other than null,
@ -3538,19 +3482,10 @@ function FAIL (message) {
THROW(INTERNAL.errors.ERROR_QUERY_FAIL_CALLED, "");
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- graph functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief find all paths through a graph, INTERNAL part called recursively
////////////////////////////////////////////////////////////////////////////////
@ -3967,97 +3902,10 @@ function GRAPH_NEIGHBORS (vertexCollection,
return result;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- setup / reset functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief reset the regex cache
////////////////////////////////////////////////////////////////////////////////
function resetRegexCache () {
"use strict";
RegexCache = { 'i' : { }, '' : { } };
}
////////////////////////////////////////////////////////////////////////////////
/// @brief reset the user functions and reload them from the database
////////////////////////////////////////////////////////////////////////////////
function reloadUserFunctions () {
"use strict";
var c;
c = INTERNAL.db._collection("_aqlfunctions");
if (c === null) {
return;
}
var foundError = false;
var prefix = DB_PREFIX();
UserFunctions[prefix] = { };
c.toArray().forEach(function (f) {
var code = "(function() { var callback = " + f.code + "; return callback; })();";
var key = f._key.replace(/:{1,}/g, '::');
try {
var res = INTERNAL.executeScript(code, undefined, "(user function " + key + ")");
UserFunctions[prefix][key.toUpperCase()] = {
name: key,
func: res,
isDeterministic: f.isDeterministic || false
};
}
catch (err) {
foundError = true;
}
});
if (foundError) {
THROW(INTERNAL.errors.ERROR_QUERY_FUNCTION_INVALID_CODE);
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief reset the query engine
////////////////////////////////////////////////////////////////////////////////
function resetEngine () {
"use strict";
resetRegexCache();
reloadUserFunctions();
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- MODULE EXPORTS
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
exports.FCALL = FCALL;
exports.FCALL_USER = FCALL_USER;
exports.KEYS = KEYS;
@ -4177,11 +4025,6 @@ exports.reload = reloadUserFunctions;
// initialise the query engine
resetEngine();
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------