@jecloud/utils
Version:
JECloud 工具库
1 lines • 678 B
JavaScript
import{isEmpty as r,isFunction as e}from"../lodash";import n from"./bind_function";export function execScript(t,o){if(r(t))return t;var c=t;try{var u=window;return t="with (sandbox) { \n "+t+"\n }",new Function("sandbox",t)(new Proxy(null!=o?o:u,{has:function(r,e){return!0},get:function(r,t){if(t!==Symbol.unscopables){if(Reflect.has(r,t))return Reflect.get(r,t);var o=Reflect.get(u,t);return e(o)?n(u,o):o}}}))}catch(r){console.trace("execScript error!",c),console.error(r)}return null}export function execScript4Return(r){var e;try{r="return ( \n "+r+" \n )",e=new Function(r)()}catch(e){console.trace("execScript4Return error!",r),console.error(e)}return e}