123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- import { makePredicate } from "../utils/index.js";
- function make_nested_lookup(obj) {
- const out = new Map();
- for (var key of Object.keys(obj)) {
- out.set(key, makePredicate(obj[key]));
- }
- const does_have = (global_name, fname) => {
- const inner_map = out.get(global_name);
- return inner_map != null && inner_map.has(fname);
- };
- return does_have;
- }
- export const pure_prop_access_globals = new Set([
- "Number",
- "String",
- "Array",
- "Object",
- "Function",
- "Promise",
- ]);
- const object_methods = [
- "constructor",
- "toString",
- "valueOf",
- ];
- export const is_pure_native_method = make_nested_lookup({
- Array: [
- "indexOf",
- "join",
- "lastIndexOf",
- "slice",
- ...object_methods,
- ],
- Boolean: object_methods,
- Function: object_methods,
- Number: [
- "toExponential",
- "toFixed",
- "toPrecision",
- ...object_methods,
- ],
- Object: object_methods,
- RegExp: [
- "test",
- ...object_methods,
- ],
- String: [
- "charAt",
- "charCodeAt",
- "concat",
- "indexOf",
- "italics",
- "lastIndexOf",
- "match",
- "replace",
- "search",
- "slice",
- "split",
- "substr",
- "substring",
- "toLowerCase",
- "toUpperCase",
- "trim",
- ...object_methods,
- ],
- });
- export const is_pure_native_fn = make_nested_lookup({
- Array: [
- "isArray",
- ],
- Math: [
- "abs",
- "acos",
- "asin",
- "atan",
- "ceil",
- "cos",
- "exp",
- "floor",
- "log",
- "round",
- "sin",
- "sqrt",
- "tan",
- "atan2",
- "pow",
- "max",
- "min",
- ],
- Number: [
- "isFinite",
- "isNaN",
- ],
- Object: [
- "create",
- "getOwnPropertyDescriptor",
- "getOwnPropertyNames",
- "getPrototypeOf",
- "isExtensible",
- "isFrozen",
- "isSealed",
- "hasOwn",
- "keys",
- ],
- String: [
- "fromCharCode",
- ],
- });
- export const is_pure_native_value = make_nested_lookup({
- Math: [
- "E",
- "LN10",
- "LN2",
- "LOG2E",
- "LOG10E",
- "PI",
- "SQRT1_2",
- "SQRT2",
- ],
- Number: [
- "MAX_VALUE",
- "MIN_VALUE",
- "NaN",
- "NEGATIVE_INFINITY",
- "POSITIVE_INFINITY",
- ],
- });
|