Created
August 29, 2018 16:01
Revisions
-
samdenty created this gist
Aug 29, 2018 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ (function getCompletions(type) { let object; if (type === "string") object = new String(""); else if (type === "number") object = new Number(0); else if (type === "bigint") object = Object(BigInt(0)); else if (type === "boolean") object = new Boolean(false); else object = this; const result = []; try { for (let o = object; o; o = Object.getPrototypeOf(o)) { if ( (type === "array" || type === "typedarray") && o === object && o.length > 9999 ) continue; const group = { items: [], __proto__: null }; try { if (typeof o === "object" && o.constructor && o.constructor.name) group.title = o.constructor.name; } catch (ee) { } result[result.length] = group; const names = Object.getOwnPropertyNames(o); const isArray = Array.isArray(o); for (let i = 0; i < names.length && group.items.length < 10000; ++i) { if (isArray && /^[0-9]/.test(names[i])) continue; group.items[group.items.length] = names[i]; } } } catch (e) { } return result; });