Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More β†’
Socket
Sign inDemoInstall
Socket

esmock

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esmock - npm Package Compare versions

Comparing version 2.3.1 to 2.3.2

2

package.json
{
"name": "esmock",
"type": "module",
"version": "2.3.1",
"version": "2.3.2",
"license": "ISC",

@@ -6,0 +6,0 @@ "readmeFilename": "README.md",

@@ -30,6 +30,2 @@ ```diff

},
"ava": [
"ava is incompatible w/ --loader and node v20 or greater",
"https://github.com/avajs/ava/issues/3195"
],
"jest": {

@@ -65,3 +61,3 @@ "runner": "jest-light-runner"

assert.strictEqual(cookup('breakfast'), 'β˜•πŸ₯“πŸ§‚')
assert.equal(cookup('breakfast'), 'β˜•πŸ₯“πŸ§‚')
})

@@ -75,3 +71,3 @@

assert.strictEqual(getFile(), 'returned to 🌲 every caller in the tree')
assert.equal(getFile(), 'returned to 🌲 every caller in the tree')
})

@@ -81,10 +77,8 @@

// https://github.com/iambumblehead/esmock/wiki#call-esmock-globals
const Users = await esmock('../Users.js', {
// nested esmock defines 'fetch' at req.js' import tree *only*
const { userCount } = await esmock('../Users.js', {
'../req.js': await esmock('../req.js', {
import: {
// define globals, such as 'fetch', using the import namespace
import: { // define globals like 'fetch' on the import namespace
fetch: async () => ({
status: 200,
json: async () => [["jim","πŸ˜„"],["jen","😊"]]
json: async () => [['jim','πŸ˜„'],['jen','😊']]
})

@@ -95,3 +89,3 @@ }

assert.deepEqual(await Users.count(), 2)
assert.deepEqual(await userCount(), 2)
})

@@ -106,3 +100,3 @@

// mock definition is returned from cache, when import is called
assert.strictEqual(await doAwaitImport('cfgπŸ› οΈ'), 'cfgπŸ› οΈ')
assert.equal(await doAwaitImport('cfgπŸ› οΈ'), 'cfgπŸ› οΈ')
// a bit more info are found in the wiki guide

@@ -109,0 +103,0 @@ })

import Se from"process";var d=import.meta.url;var $e=(e,t)=>new Error(`invalid moduleId: "${e}" (used by ${t})`),Ee=(e,t)=>new Error(`un-mocked moduleId: "${e}" (used by ${t})`),xe=()=>new Error("the loader chain process must include esmock. start the process using --loader=esmock."),Oe=(e,t)=>new Error(`no mocks provided for module: "${e}" (used by ${t}`),p={errModuleIdNotFound:$e,errModuleIdNotMocked:Ee,errMissingLoader:xe,errModuleIdNoDefs:Oe};var[V,Ce]=Se.versions.node.split(".").map(e=>+e),q=V<16||V===16&&Ce<12,ve=/\?esmkgdefs=.*/,H=/.*\?esmkgdefs=/,E=/#-#esmkdefs/,W=/^file:\/\/\/import\?/,Fe=/file:\/\/\/import\?([^#]*)/,Te=/\bimport,|,import\b|\bimport\b/g,$=/esmkTreeId=\d*/,Pe=/esmkModuleId=([^&]*)/,_=/\?esmk=\d*/,M=/.*exportNames=(.*)/,Ae=/.*#-#/,Ne=/isesm=true/,De=/isfound=false/,Ft=({port:e})=>(e.addEventListener("message",t=>global.mockKeys[t.data.key]=t.data.keylong),e.unref(),"global.postMessageEsmk = d => port.postMessage(d)"),B=e=>{let[t,s]=e.match(Fe)||[];return[t,M.test(s)&&s.replace(M,"$1").split(",")]},Ge=e=>{let t=e.split(E)[1]||"",s=B(t),o=e.replace(H,""),r=B(o);return[s[0]||r[0],[...new Set([s[1]||[],r[1]||[]].flat())]]},Q=e=>_.test(e)&&global.esmockTreeIdGet(e.match(_)[0].split("=")[1]),Z=async(e,t,s)=>s.parentURL&&(s.conditions.slice(-1)[0]==="node-addons"||s.importAssertions||q)?e(t,s):e(t),Tt=async(e,t,s)=>{let{parentURL:o}=t,r=Q(o)||o;if(!$.test(r))return Z(s,e,t);let[c]=String(r).match($),[n,a]=r.split(E),l=n&&n.replace(H,"");if(r.includes(`esmkModuleId=${e}&isfound=false`)){let U=new RegExp(".*file:///"+e+"(\\?"+c+"(?:(?!#-#).)*).*"),z=(l.match(U)||a.match(U)||[])[1];if(z)return{shortCircuit:!0,url:d+z}}if(W.test(e))return{shortCircuit:!0,url:e.replace(W,d+"?")};let m=await Z(s,e,t),I=new RegExp(".*("+m.url+"\\?"+c+"(?:(?!#-#).)*).*"),y=I.test(a)&&a.replace(I,"$1")||I.test(l)&&l.replace(I,"$1");if(y?m.url=Ne.test(y)?y:d+"#-#"+y:l&&l!=="0"&&(m.url.startsWith("node:")||(m.url+="?esmkgdefs="+l)),/strict=3/.test(r)&&!y)throw p.errModuleIdNotMocked(m.url,r.split("?")[0]);return m},J="esmock-loader=true",Ke=e=>`${e}?${J}`,X=async e=>(await import(Ke(e))).default===!0,Ue=async(e,t,s)=>{if(e.endsWith(J))return{format:"module",shortCircuit:!0,responseURL:e,source:"export default true"};let o=Q(e)||e;if(o&&(o.match($)||[])[0]){let[n,a]=Ge(o);if(a&&a.length)return{format:"module",shortCircuit:!0,responseURL:encodeURI(e),source:`import {${a}} from '${n}';`+(await s(e,t)).source}}if(E.test(e))return s(e,t);e=e.replace(ve,""),e.startsWith(d)&&(e=e.replace(Ae,""),De.test(e)&&(e=e.replace(d,`file:///${e.match(Pe)[1]}`)));let c=M.test(e)&&e.replace(M,"$1").replace(Te,"").split(",");return c&&c[0]?{format:"module",shortCircuit:!0,responseURL:encodeURI(e),source:c.map(n=>n==="default"?`export default global.esmockCacheGet("${e}").default`:`export const ${n} = global.esmockCacheGet("${e}").${n}`).join(`
`)}:s(e,t)},Pt=q&&Ue;var Y=(e=>async()=>e=e||X(import.meta.url))();import at from"fs";import lt from"node:url";import ne from"fs";import ce from"url";import i from"path";import ie from"module";var C=ie.createRequire(import.meta.url),L=ne.realpathSync.native,ae=new RegExp("^(?:node:)?("+ie.builtinModules.join("|").replace("/","/")+")$"),ze=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,v=/^.\.?(?=\/|\\)/,ee=/\\/g,Ve=/index.[tj]sx?$/,We=/[\\/]resolvewithplus[\\/]/,_e=/(^@[^/]*\/[^/]*|^[^/]*)\/?(.*)$/,x=/^#/,le=/(\*)/g,me=/([./])/g,Be=/^node:/,Ze=/^file:/,ue=[".js",".mjs",".ts",".tsx",".json",".node"],te="node_modules",R="package.json",se="node",oe="default",F="import",w=".",pe=e=>e&&typeof e=="object",O={},qe=e=>Be.test(e)?e:`node:${e}`,He=e=>e&&ce.pathToFileURL(e).href,Qe=e=>ae.test(e),Je=e=>Ze.test(e)?ce.fileURLToPath(e):e,Xe=e=>i.resolve(i.extname(e)?i.dirname(e):e)+i.sep,S=e=>ee.test(e)?e.replace(ee,i.posix.sep):e,f=(e,t)=>{try{t=ne.statSync(e)}catch{t=!1}return t&&(t.isFile()||t.isFIFO())},de=e=>e.split(i.sep).reduce((t,s,o)=>(s===te&&!We.test(e)||(s=o?i.join(t[0][o-1],s):s||i.sep,t[0].push(s),t[1].push(i.resolve(i.join(s,te)))),t),[[],[]])[1].reverse(),Ye=e=>{let t=e.split(i.sep).slice(1).reduce((s,o,r)=>(s.push(i.resolve(i.join(r?s[r-1]:i.sep,o))),s),[]).reverse().find(s=>f(i.join(s,R)));return t&&i.join(t,R)},Le=e=>(String(e).match(_e)||[]).slice(1),re=(e,t)=>new RegExp(e.replace(me,"\\$1").replace(le,".*")).test(t),et=(e,t,s)=>{let o=new RegExp(e.replace(me,"\\$1").replace(le,"(.*)")),r=(s.match(o)||[])[1];return r&&t.replace("*",r)},fe=(e,t,s,o=!1)=>(re(e,s)&&(t.includes("*")?re(t,s)?o=s:e.includes("*")&&e!==t&&(o=et(e,t,s)):o=t),o),ge=(e,t,s,o=e[0])=>e.length?(x.test(s)?x.test(o):v.test(o))&&typeof t[o]=="string"&&fe(o,t[o],s)||ge(e.slice(1),t,s):null,u=(e,t)=>{let s=!1;return typeof e=="string"?e:(!s&&Array.isArray(e)&&(s=e.reduce((o,r)=>o||u(r,t),null)),!s&&pe(e)&&(typeof e[t]=="string"&&(s=e[t]),!s&&e[se]&&(s=u(e[se],t)),!s&&e[oe]&&(s=u(e[oe],t)),!s&&e[t]&&(s=u(e[t],t)),!s&&e[w]&&(s=typeof e[w]=="string"?t===F&&u(e[w],t):u(e[w],t)),s||(s=ge(Object.keys(e),e,t))),s)},ke=(e,t)=>{let s=t&&t.ismodule&&e.module,o=s||t&&t.browser&&e.browser,r=e.exports,c,n;return o&&(typeof o=="string"?n=o:pe(o)&&([c]=Object.keys(o).filter(a=>Ve.test(a)),n=c in o&&o[c])),r&&(n=u(r,F)),n},b=e=>{var t=null;return f(e)?t=e:ue.some(s=>f(e+s)&&(t=e+s)),t},he=(e,t)=>{let s=null,o,r=i.join(e,R),c=f(r)&&C(r);return(o=ke(c,t))?s=b(i.join(e,o)):(o=c.main)?s=b(i.join(e,o))||b(i.join(e,i.join(o,"index"))):ue.some(n=>(n=i.join(e,`index${n}`))&&f(n)&&(s=n)),s},ye=(e,t,s)=>{let o=v.test(e)?i.join(t,e):e;return b(o,s)||he(o,s)},tt=(e,t,s)=>{let o=s&&s.imports,r=u(o,t);return r&&(v.test(r)?i.join(e,r):be(r,e,{isposixpath:!0}))},st=(e,t,s,o)=>{let r=u(o&&o.exports,s?"./"+s:F);return r&&i.join(e,t,r)},ot=(e,t,s,o)=>{let r=i.join(e,t,R),c=f(r),n=c&&C(r);return c&&st(e,t,s,n,o)},rt=(e,t,s)=>{let o=Ye(t),r=i.dirname(o);return o&&tt(r,e,C(o),s)},nt=(e,t,s)=>{let[o,r]=Le(e);if(x.test(o))return rt(e,t,s);let c=de(t).sort((n,a)=>n.length>a.length);return function n(a,l,m=l-1){return l--?ot(i.join(a[m-l]),o,r,s)||ye(i.join(a[m-l],e),null,s)||n(c,l,m):null}(c,c.length)},ct=(e,t,s)=>{var o=null;return t=typeof t=="string"?Xe(Je(decodeURI(t))):process.cwd(),ae.test(e)?o=qe(e):(o=ze.test(e)?ye(S(e),t,s):nt(e,t),o=o&&(s.isposixpath?L(o):He(S(L(o))))),o},be=(e,t,s)=>{let o=O[e+t];return o||(o=ct(e,t,s||{}),O[e+t]=o)},g=Object.assign(be,{pathToPosix:S,getasnode_module_paths:de,getesmkeyvalmatch:fe,getasfilesync:b,getasdirsync:he,gettargetindex:ke,iscoremodule:Qe,esmparse:u,cache:O});var T={isESM:{},mockDefs:{}},je=(e,t)=>(typeof global.postMessageEsmk=="function"&&global.postMessageEsmk({key:e,keylong:t}),global.mockKeys[String(e)]=t),P=e=>global.mockKeys[String(e)],A=(e,t)=>global.esmockCache.mockDefs[e]=t,it=e=>global.esmockCache.mockDefs[e],Ie=e=>T.isESM[e],Me=(e,t)=>T.isESM[e]=t;Object.assign(global,{esmockCache:T,esmockCacheGet:it,esmockTreeIdGet:P,mockKeys:{}});var N=e=>typeof e=="object"&&e,D=e=>N(e)&&"default"in e,mt=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,ut=typeof import.meta.resolve=="function",pt=((e=0)=>()=>++e)(),we=e=>e.startsWith("file://")?e:lt.pathToFileURL(e),dt=Object.getPrototypeOf({}),ft=e=>Object.getPrototypeOf(e)===dt,k=ut?import.meta.resolve.constructor.name==="AsyncFunction"?async(e,t)=>import.meta.resolve(e,we(t)).catch(()=>g(e,t)):(e,t)=>{try{return import.meta.resolve(e,we(t))}catch{return g(e,t)}}:g,gt=(e,t)=>ft(e)?Object.assign({},e,t):Object.assign(Object.keys(e).reduce((s,o)=>(Object.defineProperty(s,o,{value:e[o],writable:!0}),s),Object.create(e)),t),kt=(e,t)=>N(e)&&N(t)?gt(e,t):t,ht=(e,t,s)=>s===null?Object.assign({},e||{},t):(t=Object.assign({},e||{},{default:kt(D(e)&&e.default,D(t)?t.default:t)},t),!g.iscoremodule(s)&&Object.isExtensible(t.default)&&(t.default.default=t.default),t),yt=/(^\s*|[});\n]\s*)(import\s+(['"]|(\*\s+as\s+)?[^"'()\n;]+\s+from\s+['"]|\{)|export\s+\*\s+from\s+["']|export\s+(\{|default|function|class|var|const|let|async\s+function))/,bt=(e,t)=>(t=Ie(e),typeof t=="boolean"||(t=!g.iscoremodule(e)&&mt.test(e)&&yt.test(at.readFileSync(e,"utf-8")),Me(e,t)),t),jt=(e,t)=>{let s=D(e)&&e.default;return/boolean|string|number/.test(typeof s)?e:Object.isExtensible(s)?Object.assign(s,e,{esmkTreeId:t}):Object.assign({},s,e,{esmkTreeId:t})},It=e=>{let t=c=>c==="null"||A(c,null),s=P(e.split("esmk=")[1]),[o,r]=s.split("#-#esmkdefs=");String(r).split("#-#").forEach(t),String(o.split("esmkgdefs=")[1]).split("#-#").forEach(t)},Mt=async(e,t,s,o,r)=>{t=ht(r.strict||!o||await import(o),t,o);let c=(o||"file:///"+s)+"?"+["esmkTreeId="+e,"esmkModuleId="+s,"isfound="+Boolean(o),"isesm="+bt(o),"exportNames="+Object.keys(t).sort().join()].join("&");return A(c,t),c},G=async(e,t,s,o,r,c,n)=>{if(o=o||Object.keys(s),n=o[0],c=c||[],!n)return c;let a=k.constructor.name==="AsyncFunction"?await k(n,e):k(n,e);if(!a&&r.isModuleNotFoundError!==!1&&n!=="import")throw p.errModuleIdNotFound(n,e);return c.push(await Mt(t,s[n],n,a,r)),G(e,t,s,o.slice(1),r,c)},wt=async(e,t,s,o,r)=>{let c=k.constructor.name==="AsyncFunction"?await k(e,t):k(e,t);if(!c)throw p.errModuleIdNotFound(e,t);let n=o?Object.keys(o):[],a=s?Object.keys(s):[];if(r.strict===3&&!n.length&&!a.length)throw p.errModuleIdNoDefs(e,t);let l=typeof r.id=="number"?r.id:pt(),m=`${c}?key=${l}&strict=${r.strict}?`+["esmkgdefs="+(n.length&&(await G(t,l,o,n,r)).join("#-#")||0),"esmkdefs=",a.length&&(await G(t,l,s,a,r)).join("#-#")||0].join("#-#");return je(String(l),m),c+`?esmk=${l}`},j=Object.assign(wt,{purge:It,sanitize:jt});var Rt=/^.*(\(|at )(.*):[\d]*:[\d]*.*$/,Re=(e,t)=>(e=typeof e[1]=="string"?e:[e[0],new Error().stack.split(`
`)}:s(e,t)},Pt=q&&Ue;var Y=(e=>async()=>e=e||X(import.meta.url))();import at from"fs";import lt from"node:url";import ne from"fs";import ce from"url";import i from"path";import ie from"module";var C=ie.createRequire(import.meta.url),L=ne.realpathSync.native,ae=new RegExp("^(?:node:)?("+ie.builtinModules.join("|").replace("/","/")+")$"),ze=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,v=/^.\.?(?=\/|\\)/,ee=/\\/g,Ve=/index.[tj]sx?$/,We=/[\\/]resolvewithplus[\\/]/,_e=/(^@[^/]*\/[^/]*|^[^/]*)\/?(.*)$/,x=/^#/,le=/(\*)/g,me=/([./])/g,Be=/^node:/,Ze=/^file:/,ue=[".js",".mjs",".ts",".tsx",".json",".node"],te="node_modules",R="package.json",se="node",oe="default",F="import",w=".",pe=e=>e&&typeof e=="object",O={},qe=e=>Be.test(e)?e:`node:${e}`,He=e=>e&&ce.pathToFileURL(e).href,Qe=e=>ae.test(e),Je=e=>Ze.test(e)?ce.fileURLToPath(e):e,Xe=e=>i.resolve(i.extname(e)?i.dirname(e):e)+i.sep,S=e=>ee.test(e)?e.replace(ee,i.posix.sep):e,f=(e,t)=>{try{t=ne.statSync(e)}catch{t=!1}return t&&(t.isFile()||t.isFIFO())},de=e=>e.split(i.sep).reduce((t,s,o)=>(s===te&&!We.test(e)||(s=o?i.join(t[0][o-1],s):s||i.sep,t[0].push(s),t[1].push(i.resolve(i.join(s,te)))),t),[[],[]])[1].reverse(),Ye=e=>{let t=e.split(i.sep).slice(1).reduce((s,o,r)=>(s.push(i.resolve(i.join(r?s[r-1]:i.sep,o))),s),[]).reverse().find(s=>f(i.join(s,R)));return t&&i.join(t,R)},Le=e=>(String(e).match(_e)||[]).slice(1),re=(e,t)=>new RegExp(e.replace(me,"\\$1").replace(le,".*")).test(t),et=(e,t,s)=>{let o=new RegExp(e.replace(me,"\\$1").replace(le,"(.*)")),r=(s.match(o)||[])[1];return r&&t.replace("*",r)},fe=(e,t,s,o=!1)=>(re(e,s)&&(t.includes("*")?re(t,s)?o=s:e.includes("*")&&e!==t&&(o=et(e,t,s)):o=t),o),ge=(e,t,s,o=e[0])=>e.length?(x.test(s)?x.test(o):v.test(o))&&typeof t[o]=="string"&&fe(o,t[o],s)||ge(e.slice(1),t,s):null,u=(e,t)=>{let s=!1;return typeof e=="string"?e:(!s&&Array.isArray(e)&&(s=e.reduce((o,r)=>o||u(r,t),null)),!s&&pe(e)&&(typeof e[t]=="string"&&(s=e[t]),!s&&e[se]&&(s=u(e[se],t)),!s&&e[oe]&&(s=u(e[oe],t)),!s&&e[t]&&(s=u(e[t],t)),!s&&e[w]&&(s=typeof e[w]=="string"?t===F&&u(e[w],t):u(e[w],t)),s||(s=ge(Object.keys(e),e,t))),s)},ke=(e,t)=>{let s=t&&t.ismodule&&e.module,o=s||t&&t.browser&&e.browser,r=e.exports,c,n;return o&&(typeof o=="string"?n=o:pe(o)&&([c]=Object.keys(o).filter(a=>Ve.test(a)),n=c in o&&o[c])),r&&(n=u(r,F)),n},b=e=>{var t=null;return f(e)?t=e:ue.some(s=>f(e+s)&&(t=e+s)),t},he=(e,t)=>{let s=null,o,r=i.join(e,R),c=f(r)&&C(r);return(o=ke(c,t))?s=b(i.join(e,o)):(o=c.main)?s=b(i.join(e,o))||b(i.join(e,i.join(o,"index"))):ue.some(n=>(n=i.join(e,`index${n}`))&&f(n)&&(s=n)),s},ye=(e,t,s)=>{let o=v.test(e)?i.join(t,e):e;return b(o,s)||he(o,s)},tt=(e,t,s)=>{let o=s&&s.imports,r=u(o,t);return r&&(v.test(r)?i.join(e,r):be(r,e,{isposixpath:!0}))},st=(e,t,s,o)=>{let r=u(o&&o.exports,s?"./"+s:F);return r&&i.join(e,t,r)},ot=(e,t,s,o)=>{let r=i.join(e,t,R),c=f(r),n=c&&C(r);return c&&st(e,t,s,n,o)},rt=(e,t,s)=>{let o=Ye(t),r=i.dirname(o);return o&&tt(r,e,C(o),s)},nt=(e,t,s)=>{let[o,r]=Le(e);if(x.test(o))return rt(e,t,s);let c=de(t).sort((n,a)=>n.length>a.length);return function n(a,l,m=l-1){return l--?ot(i.join(a[m-l]),o,r,s)||ye(i.join(a[m-l],e),null,s)||n(c,l,m):null}(c,c.length)},ct=(e,t,s)=>{var o=null;return t=typeof t=="string"?Xe(Je(decodeURI(t))):process.cwd(),ae.test(e)?o=qe(e):(o=ze.test(e)?ye(S(e),t,s):nt(e,t),o=o&&(s.isposixpath?L(o):He(S(L(o))))),o},be=(e,t,s)=>{let o=O[e+t];return o||(o=ct(e,t,s||{}),O[e+t]=o)},g=Object.assign(be,{pathToPosix:S,getasnode_module_paths:de,getesmkeyvalmatch:fe,getasfilesync:b,getasdirsync:he,gettargetindex:ke,iscoremodule:Qe,esmparse:u,cache:O});var T={isESM:{},mockDefs:{}},je=(e,t)=>(typeof global.postMessageEsmk=="function"&&global.postMessageEsmk({key:e,keylong:t}),global.mockKeys[String(e)]=t),P=e=>global.mockKeys[String(e)],A=(e,t)=>global.esmockCache.mockDefs[e]=t,it=e=>global.esmockCache.mockDefs[e],Ie=e=>T.isESM[e],Me=(e,t)=>T.isESM[e]=t;Object.assign(global,{esmockCache:T,esmockCacheGet:it,esmockTreeIdGet:P,mockKeys:{}});var N=e=>typeof e=="object"&&e,D=e=>N(e)&&"default"in e,mt=/^\.?\.?([a-zA-Z]:)?(\/|\\)/,ut=typeof import.meta.resolve=="function",pt=((e=0)=>()=>++e)(),we=e=>e.startsWith("file://")?e:lt.pathToFileURL(e),dt=Object.getPrototypeOf({}),ft=e=>Object.getPrototypeOf(e)===dt,k=ut?import.meta.resolve.constructor.name==="AsyncFunction"?async(e,t)=>import.meta.resolve(e,we(t)).catch(()=>g(e,t)):(e,t)=>{try{return import.meta.resolve(e,we(t))}catch{return g(e,t)}}:g,gt=(e,t)=>ft(e)?Object.assign({},e,t):Object.assign(Object.keys(e).reduce((s,o)=>(Object.defineProperty(s,o,{value:e[o],writable:!0}),s),Object.create(e)),t),kt=(e,t)=>N(e)&&N(t)?gt(e,t):t,ht=(e,t,s)=>s===null?Object.assign({},e||{},t):(t=Object.assign({},e||{},{default:kt(D(e)&&e.default,D(t)?t.default:t)},t),!g.iscoremodule(s)&&Object.isExtensible(t.default)&&(t.default.default=t.default),t),yt=/(^\s*|[});\n]\s*)(import\s+(['"]|(\*\s+as\s+)?[^"'()\n;]+\s+from\s+['"]|\{)|export\s+\*\s+from\s+["']|export\s+(\{|default|function|class|var|const|let|async\s+function))/,bt=(e,t)=>(t=Ie(e),typeof t=="boolean"||(t=!g.iscoremodule(e)&&mt.test(e)&&yt.test(at.readFileSync(e,"utf-8")),Me(e,t)),t),jt=(e,t)=>{let s=D(e)&&e.default;return/boolean|string|number/.test(typeof s)?e:Object.isExtensible(s)?Object.assign(s,e,{esmkTreeId:t}):Object.assign({},s,e,{esmkTreeId:t})},It=e=>{let t=c=>c==="null"||A(c,null),s=P(e.split("esmk=")[1]),[o,r]=s.split("#-#esmkdefs=");String(r).split("#-#").forEach(t),String(o.split("esmkgdefs=")[1]).split("#-#").forEach(t)},Mt=async(e,t,s,o,r)=>{t=ht(r.strict||!o||await import(o),t,o);let c=(o||"file:///"+s)+"?"+["esmkTreeId="+e,"esmkModuleId="+s,"isfound="+!!o,"isesm="+bt(o),"exportNames="+Object.keys(t).sort().join()].join("&");return A(c,t),c},G=async(e,t,s,o,r,c,n)=>{if(o=o||Object.keys(s),n=o[0],c=c||[],!n)return c;let a=k.constructor.name==="AsyncFunction"?await k(n,e):k(n,e);if(!a&&r.isModuleNotFoundError!==!1&&n!=="import")throw p.errModuleIdNotFound(n,e);return c.push(await Mt(t,s[n],n,a,r)),G(e,t,s,o.slice(1),r,c)},wt=async(e,t,s,o,r)=>{let c=k.constructor.name==="AsyncFunction"?await k(e,t):k(e,t);if(!c)throw p.errModuleIdNotFound(e,t);let n=o?Object.keys(o):[],a=s?Object.keys(s):[];if(r.strict===3&&!n.length&&!a.length)throw p.errModuleIdNoDefs(e,t);let l=typeof r.id=="number"?r.id:pt(),m=`${c}?key=${l}&strict=${r.strict}?`+["esmkgdefs="+(n.length&&(await G(t,l,o,n,r)).join("#-#")||0),"esmkdefs=",a.length&&(await G(t,l,s,a,r)).join("#-#")||0].join("#-#");return je(String(l),m),c+`?esmk=${l}`},j=Object.assign(wt,{purge:It,sanitize:jt});var Rt=/^.*(\(|at )(.*):[\d]*:[\d]*.*$/,Re=(e,t)=>(e=typeof e[1]=="string"?e:[e[0],new Error().stack.split(`
`)[3].replace(Rt,"$2"),...e.slice(1)],e[4]={...e[4],...t},e);var h=e=>async(...t)=>{let[s,o,r,c,n]=Re(t,e);if(!await Y())throw p.errMissingLoader();let a=await j(s,o,r,c,n),l=await import(a);return n.purge!==!1&&j.purge(a),j.sanitize(l,a)},K=e=>e&&/object|function/.test(typeof e)&&"esmkTreeId"in e&&j.purge(e.esmkTreeId),$t=Object.assign(h({strict:1}),{purge:K,p:h({strict:1,purge:!1})}),Et=Object.assign(h({strict:3}),{purge:K,p:h({strict:3,purge:!1})}),ts=Object.assign(h(),{purge:K,p:h({purge:!1}),strict:$t,strictest:Et});export{ts as default,Pt as getSource,Ft as globalPreload,Ue as load,X as loaderIsVerified,Tt as resolve,$t as strict,Et as strictest};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc