From 2b4757367470d8e36bc00901dac567e375796ed4 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Tue, 13 Nov 2018 00:24:09 -0500 Subject: 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 --- assets/viz/2/goog/object/object.js | 54 +++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 4 deletions(-) (limited to 'assets/viz/2/goog/object') 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) { * goog.object.unsafeClone is unaware of unique identifiers, and * copies UIDs created by getUid 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. + * + *

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} + * @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); +}; -- cgit v1.2.3