mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-14 23:24:52 +09:00
Fix misc problems detected by ESLint
Reformat and clean up issues detected by ESLint.
This commit is contained in:
1 parent
8cb21c5fa8
commit
e9f5cae4f0
34 files changed
+132
-189
No files matched your search
+25
-24
@@ -1,35 +1,36 @@
|
||||
/**
|
||||
Helper functions related to objects
|
||||
@module
|
||||
*/
|
||||
* Helper functions related to objects
|
||||
* @module
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
Deep clones an object, is actually just JSON.parse(JSON.stringify()) but looks cleaner.
|
||||
@param {object} obj to clone
|
||||
@returns {object} The cloned object.
|
||||
|
||||
@example
|
||||
a = {"thingy":"with a value"};
|
||||
b = a;
|
||||
a == b; // true
|
||||
c = objectOps.deepclone(a);
|
||||
a == c; // false
|
||||
*/
|
||||
* Deep clones an object, is actually just JSON.parse(JSON.stringify()) but looks cleaner.
|
||||
* @param {object} obj to clone
|
||||
* @returns {object} The cloned object.
|
||||
*
|
||||
* @example
|
||||
* a = {"thingy":"with a value"};
|
||||
* b = a;
|
||||
* a == b; // true
|
||||
* c = objectOps.deepclone(a);
|
||||
* a == c; // false
|
||||
*/
|
||||
module.exports.deepclone = function(obj){
|
||||
return JSON.parse(JSON.stringify(obj));
|
||||
};
|
||||
/**
|
||||
Checks if a string is valid JSON using try/catch. If passed an object it will always return true.
|
||||
@param {string} string to verify
|
||||
@returns {boolean} true if valid JSON.
|
||||
|
||||
@example
|
||||
objectOps.isJSON("99 bottles of beer"); // false
|
||||
objectOps.isJSON("99"); // true
|
||||
objectOps.isJSON({"thingy":"that is an object"}); // true
|
||||
objectOps.isJSON(JSON.stringify({"thingy":"that is an object"})); // true
|
||||
*/
|
||||
/**
|
||||
* Checks if a string is valid JSON using try/catch. If passed an object it will always return true.
|
||||
* @param {string} string to verify
|
||||
* @returns {boolean} true if valid JSON.
|
||||
*
|
||||
* @example
|
||||
* objectOps.isJSON("99 bottles of beer"); // false
|
||||
* objectOps.isJSON("99"); // true
|
||||
* objectOps.isJSON({"thingy":"that is an object"}); // true
|
||||
* objectOps.isJSON(JSON.stringify({"thingy":"that is an object"})); // true
|
||||
*/
|
||||
module.exports.isJSON = function(string){
|
||||
let stringIsJson = false;
|
||||
let x;
|
||||
|
||||
Reference in new issue
Block a user