1
0
Fork 0

fixed jslint warnings

This commit is contained in:
Jan Steemann 2014-01-15 18:06:17 +01:00
parent e68a98e837
commit 657406bb70
1 changed files with 83 additions and 240 deletions

View File

@ -37,11 +37,6 @@ var ShapedJson = INTERNAL.ShapedJson;
// --SECTION-- private variables // --SECTION-- private variables
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief cache for compiled regexes /// @brief cache for compiled regexes
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -65,19 +60,30 @@ var TYPEWEIGHT_STRING = 4;
var TYPEWEIGHT_LIST = 8; var TYPEWEIGHT_LIST = 8;
var TYPEWEIGHT_DOCUMENT = 16; var TYPEWEIGHT_DOCUMENT = 16;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- helper functions // --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 /// @brief return a database-specific function prefix
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -86,6 +92,72 @@ function DB_PREFIX () {
return INTERNAL.db._name(); 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 /// @brief normalise a function name
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -126,26 +198,6 @@ function FILTER (list, examples) {
return result; 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 /// @brief find a fulltext index for a certain attribute & collection
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -1035,19 +1087,10 @@ function COLLECTIONS () {
return result; return result;
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- logical operations // --SECTION-- logical operations
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief execute ternary operator /// @brief execute ternary operator
/// ///
@ -1202,19 +1245,10 @@ function LOGICAL_NOT (lhs) {
return ! lhs; return ! lhs;
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- comparison operations // --SECTION-- comparison operations
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief perform equality check /// @brief perform equality check
/// ///
@ -1665,19 +1699,10 @@ function RELATIONAL_IN (lhs, rhs) {
return false; return false;
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- arithmetic operations // --SECTION-- arithmetic operations
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief perform unary plus operation /// @brief perform unary plus operation
/// ///
@ -1838,19 +1863,10 @@ function ARITHMETIC_MODULUS (lhs, rhs) {
return result; return result;
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- string functions // --SECTION-- string functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief perform string concatenation /// @brief perform string concatenation
/// ///
@ -2119,19 +2135,10 @@ function STRING_TRIM (value, type) {
return result; return result;
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- typecast functions // --SECTION-- typecast functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief cast to a bool /// @brief cast to a bool
/// ///
@ -2227,19 +2234,10 @@ function CAST_LIST (value) {
} }
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- typecheck functions // --SECTION-- typecheck functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief test if value is of type null /// @brief test if value is of type null
/// ///
@ -2312,19 +2310,10 @@ function IS_DOCUMENT (value) {
return (TYPEWEIGHT(value) === TYPEWEIGHT_DOCUMENT); return (TYPEWEIGHT(value) === TYPEWEIGHT_DOCUMENT);
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- numeric functions // --SECTION-- numeric functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief integer closest to value, not greater than value /// @brief integer closest to value, not greater than value
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -2405,19 +2394,10 @@ function NUMBER_SQRT (value) {
return NUMERIC_VALUE(Math.sqrt(value)); return NUMERIC_VALUE(Math.sqrt(value));
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- high level query functions // --SECTION-- high level query functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief sort the results /// @brief sort the results
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -2509,19 +2489,10 @@ function LIMIT (value, offset, count) {
return value.slice(offset, offset + count); return value.slice(offset, offset + count);
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- list processing functions // --SECTION-- list processing functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief get the length of a list, document or string /// @brief get the length of a list, document or string
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -3119,19 +3090,10 @@ function STDDEV_POPULATION (values) {
return NUMERIC_VALUE(Math.sqrt(result.value / result.n)); return NUMERIC_VALUE(Math.sqrt(result.value / result.n));
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- geo functions // --SECTION-- geo functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief return at most <limit> documents near a certain point /// @brief return at most <limit> documents near a certain point
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -3193,19 +3155,10 @@ function GEO_WITHIN (collection, latitude, longitude, radius, distanceAttribute)
return documents; return documents;
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- fulltext functions // --SECTION-- fulltext functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief return documents that match a fulltext query /// @brief return documents that match a fulltext query
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -3222,19 +3175,10 @@ function FULLTEXT (collection, attribute, query) {
return result.documents; return result.documents;
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- misc functions // --SECTION-- misc functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief return the first alternative that's not null until there are no more /// @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, /// alternatives. if neither of the alternatives is a value other than null,
@ -3575,19 +3519,10 @@ function FAIL (message) {
THROW(INTERNAL.errors.ERROR_QUERY_FAIL_CALLED, ""); THROW(INTERNAL.errors.ERROR_QUERY_FAIL_CALLED, "");
} }
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- graph functions // --SECTION-- graph functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief find all paths through a graph, INTERNAL part called recursively /// @brief find all paths through a graph, INTERNAL part called recursively
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -4004,97 +3939,10 @@ function GRAPH_NEIGHBORS (vertexCollection,
return result; 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 // --SECTION-- MODULE EXPORTS
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup Ahuacatl
/// @{
////////////////////////////////////////////////////////////////////////////////
exports.FCALL = FCALL; exports.FCALL = FCALL;
exports.FCALL_USER = FCALL_USER; exports.FCALL_USER = FCALL_USER;
exports.KEYS = KEYS; exports.KEYS = KEYS;
@ -4216,11 +4064,6 @@ exports.reload = reloadUserFunctions;
// initialise the query engine // initialise the query engine
resetEngine(); resetEngine();
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE // --SECTION-- END-OF-FILE
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------