@scandit/web-datacapture-barcode
Version:
Scandit Data Capture SDK for the Web
5 lines (3 loc) • 635 B
JavaScript
function r(t){return (n=>/^[$A-Z_a-z][\w$]*\s*\(.*\)\s*\{/.test(n)&&!n.startsWith("function"))(t)?`function ${t}`:t}var e=["fetch","XMLHttpRequest","eval","Function","self","globalThis","Module","importScripts","this","console","window","document","import","Worker","ServiceWorker"];function s(t){return e.map(n=>new RegExp(`\\b${n}\\b`,"g")).some(n=>n.test(t))}function l(t){if(t==null)return null;let o=r(t);if(s(o))throw new Error("Function should be pure. Shouldn't introduce side effects, or rely on global scope");let n=`'use strict';
return (${o});`;try{return new Function(n)()}catch(i){return null}}
export { l as a };