time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

_safeGet.js (456B)


      1 /**
      2  * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
      3  *
      4  * @private
      5  * @param {Object} object The object to query.
      6  * @param {string} key The key of the property to get.
      7  * @returns {*} Returns the property value.
      8  */
      9 function safeGet(object, key) {
     10   if (key === 'constructor' && typeof object[key] === 'function') {
     11     return;
     12   }
     13 
     14   if (key == '__proto__') {
     15     return;
     16   }
     17 
     18   return object[key];
     19 }
     20 
     21 module.exports = safeGet;