quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

generate_dict.js (1020B)


      1 // Function to recursively iterate through built-in names.
      2 function collectBuiltinNames(obj, visited = new Set(), result = new Set()) {
      3   // Check if the object has already been visited to avoid infinite recursion.
      4   if (visited.has(obj))
      5     return;
      6 
      7   // Add the current object to the set of visited objects
      8   visited.add(obj);
      9   // Get the property names of the current object
     10   const properties = Object.getOwnPropertyNames(obj);
     11   // Iterate through each property
     12   for (var i=0; i < properties.length; i++) {
     13     var property = properties[i];
     14     if (property != "collectBuiltinNames" && typeof property != "number")
     15       result.add(property);
     16     // Check if the property is an object and if so, recursively iterate through its properties.
     17     if (typeof obj[property] === 'object' && obj[property] !== null)
     18       collectBuiltinNames(obj[property], visited, result);
     19   }
     20   return result;
     21 }
     22 
     23 // Start the recursive iteration with the global object.
     24 console.log(Array.from(collectBuiltinNames(this)).join('\n'));