mirror of https://gitee.com/bigwinds/arangodb
Revert "Monkeypatches have their own module now."
This reverts commit d01b16a930cfc5a47174d7e24a1742c20f874318. Conflicts: js/common/modules/monkeypatches.js
This commit is contained in:
parent
455befdbf6
commit
15eddecc34
|
@ -6,7 +6,7 @@
|
||||||
/*global require, WeakDictionary, exports */
|
/*global require, WeakDictionary, exports */
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Graph interface to the database
|
/// @brief JavaScript actions functions
|
||||||
///
|
///
|
||||||
/// @file
|
/// @file
|
||||||
///
|
///
|
||||||
|
@ -40,15 +40,6 @@ var internal = require("internal"),
|
||||||
findOrCreateCollectionByName,
|
findOrCreateCollectionByName,
|
||||||
findOrCreateEdgeCollectionByName;
|
findOrCreateEdgeCollectionByName;
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// --SECTION-- private methods
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @addtogroup ArangoGraph
|
|
||||||
/// @{
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief find or create a collection by name
|
/// @brief find or create a collection by name
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1,44 +1,11 @@
|
||||||
/*jslint indent: 2,
|
|
||||||
nomen: true,
|
|
||||||
maxlen: 100,
|
|
||||||
sloppy: true,
|
|
||||||
plusplus: true */
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief Monkeypatches to built-in Classes
|
|
||||||
///
|
|
||||||
/// @file
|
|
||||||
///
|
|
||||||
/// DISCLAIMER
|
|
||||||
///
|
|
||||||
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
|
||||||
///
|
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
/// you may not use this file except in compliance with the License.
|
|
||||||
/// You may obtain a copy of the License at
|
|
||||||
///
|
|
||||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
///
|
|
||||||
/// Unless required by applicable law or agreed to in writing, software
|
|
||||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
/// See the License for the specific language governing permissions and
|
|
||||||
/// limitations under the License.
|
|
||||||
///
|
|
||||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
|
||||||
///
|
|
||||||
/// @author Dr. Frank Celler, Lucas Dohmen
|
|
||||||
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief remove last occurrence of element from an array
|
/// @brief remove last occurrence of element from an array
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Object.defineProperty(Array.prototype, "removeLastOccurrenceOf", {
|
Object.defineProperty(Array.prototype, "removeLastOccurrenceOf", {
|
||||||
value: function (element) {
|
value: function (element) {
|
||||||
return this.splice(this.lastIndexOf(element), 1);
|
var index = this.lastIndexOf(element);
|
||||||
|
return this.splice(index, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -71,10 +38,17 @@ Object.defineProperty(Array.prototype, "intersect", {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Object.defineProperty(Object.prototype, "shallowCopy", {
|
Object.defineProperty(Object.prototype, "shallowCopy", {
|
||||||
get: function () {
|
get: function() {
|
||||||
return this.propertyKeys.reduce(function (previousValue, key) {
|
var shallow = {},
|
||||||
previousValue[key] = this[key]; return previousValue;
|
key;
|
||||||
}, {});
|
|
||||||
|
for (key in this) {
|
||||||
|
if (this.hasOwnProperty(key) && key[0] !== '_' && key[0] !== '$') {
|
||||||
|
shallow[key] = this[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return shallow;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -83,10 +57,17 @@ Object.defineProperty(Object.prototype, "shallowCopy", {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Object.defineProperty(Object.prototype, "propertyKeys", {
|
Object.defineProperty(Object.prototype, "propertyKeys", {
|
||||||
get: function () {
|
get: function() {
|
||||||
return Object.keys(this).filter(function (element) {
|
var keys = [],
|
||||||
return (element[0] !== '_' && element[0] !== '$');
|
key;
|
||||||
});
|
|
||||||
|
for (key in this) {
|
||||||
|
if (this.hasOwnProperty(key) && key[0] !== '_' && key[0] !== '$') {
|
||||||
|
keys.push(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return keys;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,30 @@ static string JS_server_server =
|
||||||
"////////////////////////////////////////////////////////////////////////////////\n"
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||||
"\n"
|
"\n"
|
||||||
"// -----------------------------------------------------------------------------\n"
|
"// -----------------------------------------------------------------------------\n"
|
||||||
|
"// --SECTION-- Module \"monkeypatches\"\n"
|
||||||
|
"// -----------------------------------------------------------------------------\n"
|
||||||
|
"\n"
|
||||||
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||||
|
"/// @addtogroup V8ModuleMonkeypatches\n"
|
||||||
|
"/// @{\n"
|
||||||
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||||
|
"\n"
|
||||||
|
"(function () {\n"
|
||||||
|
" var console = require(\"console\");\n"
|
||||||
|
"\n"
|
||||||
|
" try {\n"
|
||||||
|
" require(\"monkeypatches\");\n"
|
||||||
|
" }\n"
|
||||||
|
" catch (err) {\n"
|
||||||
|
" console.error(\"while loading 'monkeypatches' module: %s\", err);\n"
|
||||||
|
" }\n"
|
||||||
|
"}());\n"
|
||||||
|
"\n"
|
||||||
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||||
|
"/// @}\n"
|
||||||
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
||||||
|
"\n"
|
||||||
|
"// -----------------------------------------------------------------------------\n"
|
||||||
"// --SECTION-- ShapedJson\n"
|
"// --SECTION-- ShapedJson\n"
|
||||||
"// -----------------------------------------------------------------------------\n"
|
"// -----------------------------------------------------------------------------\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
Loading…
Reference in New Issue