mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2026-01-03 03:27:21 +01:00
Updated to v1.9.9
This commit is contained in:
93
conf/site/node_modules/node-forge/lib/util.js
generated
vendored
93
conf/site/node_modules/node-forge/lib/util.js
generated
vendored
@@ -2513,99 +2513,6 @@ util.makeLink = function(path, query, fragment) {
|
||||
((fragment.length > 0) ? ('#' + fragment) : '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Follows a path of keys deep into an object hierarchy and set a value.
|
||||
* If a key does not exist or it's value is not an object, create an
|
||||
* object in it's place. This can be destructive to a object tree if
|
||||
* leaf nodes are given as non-final path keys.
|
||||
* Used to avoid exceptions from missing parts of the path.
|
||||
*
|
||||
* @param object the starting object.
|
||||
* @param keys an array of string keys.
|
||||
* @param value the value to set.
|
||||
*/
|
||||
util.setPath = function(object, keys, value) {
|
||||
// need to start at an object
|
||||
if(typeof(object) === 'object' && object !== null) {
|
||||
var i = 0;
|
||||
var len = keys.length;
|
||||
while(i < len) {
|
||||
var next = keys[i++];
|
||||
if(i == len) {
|
||||
// last
|
||||
object[next] = value;
|
||||
} else {
|
||||
// more
|
||||
var hasNext = (next in object);
|
||||
if(!hasNext ||
|
||||
(hasNext && typeof(object[next]) !== 'object') ||
|
||||
(hasNext && object[next] === null)) {
|
||||
object[next] = {};
|
||||
}
|
||||
object = object[next];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Follows a path of keys deep into an object hierarchy and return a value.
|
||||
* If a key does not exist, create an object in it's place.
|
||||
* Used to avoid exceptions from missing parts of the path.
|
||||
*
|
||||
* @param object the starting object.
|
||||
* @param keys an array of string keys.
|
||||
* @param _default value to return if path not found.
|
||||
*
|
||||
* @return the value at the path if found, else default if given, else
|
||||
* undefined.
|
||||
*/
|
||||
util.getPath = function(object, keys, _default) {
|
||||
var i = 0;
|
||||
var len = keys.length;
|
||||
var hasNext = true;
|
||||
while(hasNext && i < len &&
|
||||
typeof(object) === 'object' && object !== null) {
|
||||
var next = keys[i++];
|
||||
hasNext = next in object;
|
||||
if(hasNext) {
|
||||
object = object[next];
|
||||
}
|
||||
}
|
||||
return (hasNext ? object : _default);
|
||||
};
|
||||
|
||||
/**
|
||||
* Follow a path of keys deep into an object hierarchy and delete the
|
||||
* last one. If a key does not exist, do nothing.
|
||||
* Used to avoid exceptions from missing parts of the path.
|
||||
*
|
||||
* @param object the starting object.
|
||||
* @param keys an array of string keys.
|
||||
*/
|
||||
util.deletePath = function(object, keys) {
|
||||
// need to start at an object
|
||||
if(typeof(object) === 'object' && object !== null) {
|
||||
var i = 0;
|
||||
var len = keys.length;
|
||||
while(i < len) {
|
||||
var next = keys[i++];
|
||||
if(i == len) {
|
||||
// last
|
||||
delete object[next];
|
||||
} else {
|
||||
// more
|
||||
if(!(next in object) ||
|
||||
(typeof(object[next]) !== 'object') ||
|
||||
(object[next] === null)) {
|
||||
break;
|
||||
}
|
||||
object = object[next];
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if an object is empty.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user