forked from PimpTrizkit/PJs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpOTS.js
More file actions
19 lines (19 loc) · 665 Bytes
/
pOTS.js
File metadata and controls
19 lines (19 loc) · 665 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const pOTS=(o)=> {
if (!o) return null;
let str="",na=0,k,p;
if (typeof(o) == "object") {
if (!pOTS.check) pOTS.check = new Array();
for (k=pOTS.check.length;na<k;na++) if (pOTS.check[na]==o) return '{}';
pOTS.check.push(o);
}
k="",na=typeof(o.length)=="undefined"?1:0;
for(p in o){
if (na) k = "'"+p+"':";
if (typeof o[p] == "string") str += k+"'"+o[p]+"',";
else if (typeof o[p] == "object") str += k+pOTS(o[p])+",";
else str += k+o[p]+",";
}
if (typeof(o) == "object") pOTS.check.pop();
if (na) return "{"+str.slice(0,-1)+"}";
else return "["+str.slice(0,-1)+"]";
}