summaryrefslogtreecommitdiff
path: root/assets/viz/2/goog/object/object.js
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2018-11-13 00:24:09 -0500
committerBrian Picciano <mediocregopher@gmail.com>2018-11-13 00:24:09 -0500
commit2b4757367470d8e36bc00901dac567e375796ed4 (patch)
tree72368624006c21d28228a100ee88590c7bf95e58 /assets/viz/2/goog/object/object.js
parent5ed62d23b4bbbf7717de4adfa0eaf2af19365408 (diff)
update viz 2 to use the newest version, which has some performance improvements and is easier to read the code for. also update the description
Diffstat (limited to 'assets/viz/2/goog/object/object.js')
-rw-r--r--assets/viz/2/goog/object/object.js54
1 files changed, 50 insertions, 4 deletions
diff --git a/assets/viz/2/goog/object/object.js b/assets/viz/2/goog/object/object.js
index d15c88c..2f26c2b 100644
--- a/assets/viz/2/goog/object/object.js
+++ b/assets/viz/2/goog/object/object.js
@@ -537,8 +537,9 @@ goog.object.clone = function(obj) {
* <code>goog.object.unsafeClone</code> is unaware of unique identifiers, and
* copies UIDs created by <code>getUid</code> into cloned results.
*
- * @param {*} obj The value to clone.
- * @return {*} A clone of the input value.
+ * @param {T} obj The value to clone.
+ * @return {T} A clone of the input value.
+ * @template T
*/
goog.object.unsafeClone = function(obj) {
var type = goog.typeOf(obj);
@@ -628,7 +629,7 @@ goog.object.extend = function(target, var_args) {
/**
* Creates a new object built from the key-value pairs provided as arguments.
* @param {...*} var_args If only one argument is provided and it is an array
- * then this is used as the arguments, otherwise even arguments are used as
+ * then this is used as the arguments, otherwise even arguments are used as
* the property names and odd arguments are used as the property values.
* @return {!Object} The new object.
* @throws {Error} If there are uneven number of arguments or there is only one
@@ -656,7 +657,7 @@ goog.object.create = function(var_args) {
* Creates a new object where the property names come from the arguments but
* the value is always set to true
* @param {...*} var_args If only one argument is provided and it is an array
- * then this is used as the arguments, otherwise the arguments are used
+ * then this is used as the arguments, otherwise the arguments are used
* as the property names.
* @return {!Object} The new object.
*/
@@ -703,3 +704,48 @@ goog.object.createImmutableView = function(obj) {
goog.object.isImmutableView = function(obj) {
return !!Object.isFrozen && Object.isFrozen(obj);
};
+
+
+/**
+ * Get all properties names on a given Object regardless of enumerability.
+ *
+ * <p> If the browser does not support {@code Object.getOwnPropertyNames} nor
+ * {@code Object.getPrototypeOf} then this is equivalent to using {@code
+ * goog.object.getKeys}
+ *
+ * @param {?Object} obj The object to get the properties of.
+ * @param {boolean=} opt_includeObjectPrototype Whether properties defined on
+ * {@code Object.prototype} should be included in the result.
+ * @param {boolean=} opt_includeFunctionPrototype Whether properties defined on
+ * {@code Function.prototype} should be included in the result.
+ * @return {!Array<string>}
+ * @public
+ */
+goog.object.getAllPropertyNames = function(
+ obj, opt_includeObjectPrototype, opt_includeFunctionPrototype) {
+ if (!obj) {
+ return [];
+ }
+
+ // Naively use a for..in loop to get the property names if the browser doesn't
+ // support any other APIs for getting it.
+ if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
+ return goog.object.getKeys(obj);
+ }
+
+ var visitedSet = {};
+
+ // Traverse the prototype chain and add all properties to the visited set.
+ var proto = obj;
+ while (proto &&
+ (proto !== Object.prototype || !!opt_includeObjectPrototype) &&
+ (proto !== Function.prototype || !!opt_includeFunctionPrototype)) {
+ var names = Object.getOwnPropertyNames(proto);
+ for (var i = 0; i < names.length; i++) {
+ visitedSet[names[i]] = true;
+ }
+ proto = Object.getPrototypeOf(proto);
+ }
+
+ return goog.object.getKeys(visitedSet);
+};