Comparing version 1.8.9 to 1.9.0
{ | ||
"name": "esmock", | ||
"version": "1.8.9", | ||
"version": "1.9.0", | ||
"license": "ISC", | ||
@@ -55,4 +55,4 @@ "readmeFilename": "README.md", | ||
"dependencies": { | ||
"resolvewithplus": "^0.8.4" | ||
"resolvewithplus": "^0.8.5" | ||
} | ||
} |
@@ -10,3 +10,3 @@ ```diff | ||
``` | ||
[![npm version](https://badge.fury.io/js/esmock.svg)](https://badge.fury.io/js/esmock) [![Build Status](https://github.com/iambumblehead/esmock/workflows/nodejs-ci/badge.svg)][2] [![install size](https://packagephobia.now.sh/badge?p=esmock)](https://packagephobia.now.sh/result?p=esmock) [![downloads](https://badgen.now.sh/npm/dm/esmock)](https://npmjs.org/package/esmock) | ||
[![npm version](https://badge.fury.io/js/esmock.svg)](https://badge.fury.io/js/esmock) [![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/iambumblehead/166d927bd0089d7bfdee4e98a537712c/raw/esmock__heads_master.json)][2] [![install size](https://packagephobia.now.sh/badge?p=esmock)](https://packagephobia.now.sh/result?p=esmock) [![downloads](https://badgen.now.sh/npm/dm/esmock)](https://npmjs.org/package/esmock) | ||
@@ -13,0 +13,0 @@ **esmock provides native ESM import mocking for unit tests.** Use examples below as a quick-start guide, see the [descriptive and friendly esmock guide here,][10] or browse [esmock's test runner examples.][3] |
@@ -1,2 +0,2 @@ | ||
import g from"process";import p from"path";import U from"url";import L from"./esmock.js";import $ from"./esmockIsLoader.js";global.esmockloader=$;export default L;const k="file:///"+p.join(p.dirname(U.fileURLToPath(import.meta.url)),"esmock.js").replace(/^\//,""),u=" 16. 12">g.versions.node.split(".").slice(0,2).map(e=>e.padStart(3)).join("."),w=/\?esmockGlobals=.*/,j=/.*\?esmockGlobals=/,f=/#esmockModuleKeys/,y=/.*exportNames=(.*)/,A=/esmockKey=\d*/,C=/[^#]*#/,I=/isesm=true/,N=async(e,o,s)=>{const{parentURL:t}=o,[a]=t&&t.match(/\?esmk=\d*/)||[],n=a?global.esmockKeyGet(a.split("=")[1]):t,[i]=n&&n.match(A)||[],c=o.conditions.slice(-1)[0]==="node-addons"?o.importAssertions&&o.parentURL||u?await s(e,o):await s(e):o.parentURL?await s(e,o):await s(e);if(!i)return c;const R=decodeURI(c.url),l=new RegExp(".*("+R+"\\?"+i+"[^#]*).*"),[K,d]=n.split(f),r=K.replace(j,""),b=l.test(d)&&d.replace(l,"$1"),G=l.test(r)&&r.replace(l,"$1"),m=b||G;return m?c.url=I.test(m)?m:k+"#"+m:r&&r!=="null"&&(c.url.startsWith("node:")||(c.url+="?esmockGlobals="+r)),c},h=async(e,o,s)=>{if(f.test(e))return s(e,o);e=e.replace(w,""),e.startsWith(k)&&(e=e.replace(C,""));const t=y.test(e)&&e.replace(y,"$1").split(",");return t.length?{format:"module",shortCircuit:!0,responseURL:encodeURI(e),source:t.map(a=>a==="default"?`export default global.esmockCacheGet("${e}").default`:`export const ${a} = global.esmockCacheGet("${e}").${a}`).join(` | ||
`)}:s(e,o)},P=u&&h;export{h as load,N as resolve,P as getSource}; | ||
import U from"process";import p from"path";import $ from"url";import L from"./esmock.js";import j from"./esmockIsLoader.js";global.esmockloader=j;export default L;const k="file:///"+p.join(p.dirname($.fileURLToPath(import.meta.url)),"esmock.js").replace(/^\//,""),[f,w]=U.versions.node.split(".").map(e=>+e),u=f<16||f===16&&w<12,A=/\?esmockGlobals=.*/,C=/.*\?esmockGlobals=/,y=/#esmockModuleKeys/,R=/.*exportNames=(.*)/,v=/esmockKey=\d*/,I=/[^#]*#/,N=/isesm=true/,P=async(e,o,r)=>{const{parentURL:s}=o,[t]=s&&s.match(/\?esmk=\d*/)||[],n=t?global.esmockKeyGet(t.split("=")[1]):s,[i]=n&&n.match(v)||[],c=o.parentURL&&(o.conditions.slice(-1)[0]==="node-addons"||o.importAssertions||u)?await r(e,o):await r(e);if(!i)return c;const K=decodeURI(c.url),m=new RegExp(".*("+K+"\\?"+i+"[^#]*).*"),[b,d]=n.split(y),l=b.replace(C,""),G=m.test(d)&&d.replace(m,"$1"),g=m.test(l)&&l.replace(m,"$1"),a=G||g;return a?c.url=N.test(a)?a:k+"#"+a:l&&l!=="null"&&(c.url.startsWith("node:")||(c.url+="?esmockGlobals="+l)),c},h=async(e,o,r)=>{if(y.test(e))return r(e,o);e=e.replace(A,""),e.startsWith(k)&&(e=e.replace(I,""));const s=R.test(e)&&e.replace(R,"$1").split(",");return s.length?{format:"module",shortCircuit:!0,responseURL:encodeURI(e),source:s.map(t=>t==="default"?`export default global.esmockCacheGet("${e}").default`:`export const ${t} = global.esmockCacheGet("${e}").${t}`).join(` | ||
`)}:r(e,o)},M=u&&h;export{h as load,P as resolve,M as getSource}; |
@@ -1,1 +0,1 @@ | ||
import d from"fs";import f from"path";import l from"resolvewithplus";import{esmockKeySet as O,esmockKeyGet as K,esmockCacheSet as j,esmockCacheResolvedPathIsESMGet as M,esmockCacheResolvedPathIsESMSet as S}from"./esmockCache.js";const y=e=>typeof e=="object"&&e,k=e=>y(e)&&"default"in e,m="file:///",p=(e,s)=>(s||(s=l.iscoremodule(e)?"node:":m),s.includes(m)&&(e=d.realpathSync.native(e)),process.platform==="win32"&&(e=e.split(f.sep).join(f.posix.sep)),`${s}${e.replace(/^\//,"")}`),g=(e,s,o)=>{const c=y(e),t=y(s);return c&&t?o=Object.assign({},e,s):s?o=s:c?o=Object.assign({},e):e&&(o=e),o},w=(e,s,o)=>{const c=l.iscoremodule(o),t=g(k(e)&&e.default,k(s)?s.default:s),n=Object.assign({},e||{},{default:t},s);return!c&&Object.isExtensible(n.default)&&(n.default.default=n.default),n},E=/(^\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))/,x=(e,s)=>(s=M(e),typeof s=="boolean"||(s=!l.iscoremodule(e)&&E.test(d.readFileSync(e,"utf-8")),S(e,s)),s),I=(e,s)=>{const o="default"in e&&e.default;return/boolean|string|number/.test(typeof o)?e:Object.prototype.toString.call(o)==="[object Module]"?Object.assign({},o,e,{esmockKey:s}):Object.assign(o,e,{esmockKey:s})},D=e=>{const s=n=>n==="null"||j(n,null),o=K(e.split("esmk=")[1]),[c,t]=o.split("#esmockModuleKeys=");String(t).split("#").forEach(s),String(c.split("esmockGlobals=")[1]).split("#").forEach(s)},G=((e=0)=>()=>++e)(),$=async(e,s,o,c,t)=>{const n=x(o),r=t.partial?await import(p(o)):null,i=w(r,c,o),a=Object.keys(i).sort().join(),u=`${p(o)}?`+["esmockKey="+e,"esmockModuleKey="+s,"isesm="+n,a?"exportNames="+a:"exportNone"].join("&");return j(u,i),u},b=async(e,s,o,c,t,n,r)=>{if(t=t||Object.keys(c),n=n||[],!t.length)return n;let i=l(t[0],e);if(!i)throw e=e.replace(/^\/\//,"").replace(process.cwd(),".").replace(process.env.HOME,"~"),new Error(`not a valid path: "${t[0]}" (used by ${e})`);return process.platform==="win32"&&(i=i.split(f.sep).join(f.posix.sep)),n.push(await $(o,t[0],i,c[t[0]],r)),b(e,s,o,c,t.slice(1),n,r)},N=async(e,s,o,c,t)=>{const n=l(s,e),r=typeof t.key=="number"?t.key:G(),i=await b(e,n,r,o,Object.keys(o),0,t),a=await b(e,n,r,c,Object.keys(c),0,t);if(n===null)throw new Error(`modulePath not found: "${s}"`);const u=p(n,m)+"?"+"key=:esmockKey?esmockGlobals=:esmockGlobals#esmockModuleKeys=:moduleKeys".replace(/:esmockKey/,r).replace(/:esmockGlobals/,a.join("#")||"null").replace(/:moduleKeys/,i.join("#"));return O(String(r),u),p(n,m)+`?esmk=${r}`};export{N as esmockModuleMock,D as esmockModuleImportedPurge,I as esmockModuleImportedSanitize}; | ||
import d from"fs";import f from"path";import l from"resolvewithplus";import{esmockKeySet as O,esmockKeyGet as K,esmockCacheSet as j,esmockCacheResolvedPathIsESMGet as M,esmockCacheResolvedPathIsESMSet as S}from"./esmockCache.js";const y=e=>typeof e=="object"&&e,k=e=>y(e)&&"default"in e,m="file:///",p=(e,s)=>(s||(s=l.iscoremodule(e)?"node:":m),s.includes(m)&&(e=d.realpathSync.native(e)),process.platform==="win32"&&(e=e.split(f.sep).join(f.posix.sep)),`${s}${e.replace(/^\//,"")}`),g=(e,s,o)=>{const c=y(e),t=y(s);return c&&t?o=Object.assign({},e,s):s?o=s:c?o=Object.assign({},e):e&&(o=e),o},w=(e,s,o)=>{const c=l.iscoremodule(o),t=g(k(e)&&e.default,k(s)?s.default:s),n=Object.assign({},e||{},{default:t},s);return!c&&Object.isExtensible(n.default)&&(n.default.default=n.default),n},E=/(^\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))/,x=(e,s)=>(s=M(e),typeof s=="boolean"||(s=!l.iscoremodule(e)&&E.test(d.readFileSync(e,"utf-8")),S(e,s)),s),I=(e,s)=>{const o="default"in e&&e.default;return/boolean|string|number/.test(typeof o)?e:Object.prototype.toString.call(o)==="[object Module]"?Object.assign({},o,e,{esmockKey:s}):Object.assign(o,e,{esmockKey:s})},D=e=>{const s=n=>n==="null"||j(n,null),o=K(e.split("esmk=")[1]),[c,t]=o.split("#esmockModuleKeys=");String(t).split("#").forEach(s),String(c.split("esmockGlobals=")[1]).split("#").forEach(s)},G=((e=0)=>()=>++e)(),$=async(e,s,o,c,t)=>{const n=x(o),r=t.partial?await import(p(o)):null,i=w(r,c,o),a=Object.keys(i).sort().join(),u=`${p(o)}?`+["esmockKey="+e,"esmockModuleKey="+s,"isesm="+n,a?"exportNames="+a:"exportNone"].join("&");return j(u,i),u},b=async(e,s,o,c,t,n,r)=>{if(t=t||Object.keys(c),n=n||[],!t.length)return n;let i=l(t[0],e);if(!i)throw e=e.replace(/^\/\//,"").replace(process.cwd(),".").replace(process.env.HOME,"~"),new Error(`not a valid path: "${t[0]}" (used by ${e})`);return process.platform==="win32"&&(i=i.split(f.sep).join(f.posix.sep)),n.push(await $(o,t[0],i,c[t[0]],r)),b(e,s,o,c,t.slice(1),n,r)},N=async(e,s,o,c,t)=>{const n=l(s,e),r=typeof t.key=="number"?t.key:G(),i=await b(e,n,r,o,Object.keys(o),0,t),a=await b(e,n,r,c,Object.keys(c),0,t);if(n===null)throw new Error(`modulePath not found: "${s}"`);const u=p(n,m)+"?"+"key=:esmockKey?esmockGlobals=:esmockGlobals#esmockModuleKeys=:moduleKeys".replace(/:esmockKey/,r).replace(/:esmockGlobals/,a.join("#")||"null").replace(/:moduleKeys/,i.join("#"));return O(String(r),u),p(n,m)+`?esmk=${r}`};export{N as esmockModuleMock,D as esmockModuleImportedPurge,I as esmockModuleImportedSanitize}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12052
Updatedresolvewithplus@^0.8.5