daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Jun 24th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getCircularKeys(obj,opt={left:100}){
  2.   if(!obj||typeof obj!=='object'){
  3.     return ;
  4.   }
  5.   let keys=Object.keys(obj);
  6.   function appendKeys(keys){
  7.     opt.left-=keys.length;
  8.     if(opt.left<=0){
  9.        return true;
  10.     }
  11.   }
  12.   if(appendKeys(keys)){
  13.     return keys;
  14.   }  
  15.   for(const key in obj){
  16.     const propertiesKeys=getCircularKeys(obj[key],opt);
  17.     keys=[...keys,...propertiesKeys]
  18.     if(appendKeys(propertiesKeys,opt)){
  19.       return keys;
  20.     }
  21.   }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top