Comparing version 0.0.13 to 0.0.14
@@ -1,1 +0,1 @@ | ||
var S=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var O=(t,r)=>{var e={};for(var s in t)F.call(t,s)&&r.indexOf(s)<0&&(e[s]=t[s]);if(t!=null&&S)for(var s of S(t))r.indexOf(s)<0&&K.call(t,s)&&(e[s]=t[s]);return e};function i(t,r){if(!t)throw new Error(r)}function l(t,r){return typeof r===t}var u=new Set;function v(t){i(l("function",t)||l("undefined",t),"cannot spy on a non-function value");let r=t,e=(...n)=>{if(e.called=!0,e.callCount+=1,e.calls.push(n),e.next){let[p,a]=e.next;if(e.results.push(e.next),e.next=null,p==="ok")return a;throw a}let o,y="ok";if(t)try{o=t(...n),y="ok"}catch(p){o=p,y="error"}return e.results.push([y,o]),o};Object.defineProperty(e,"length",{value:t?t.length:0}),Object.defineProperty(e,"__isSpy",{value:!0}),Object.defineProperty(e,"returns",{get(){return this.results.map(([,n])=>n)}});let s=()=>{e.called=!1,e.callCount=0,e.results=[],e.calls=[]};return s(),e.reset=s,e.nextError=n=>(e.next=["error",n],e),e.nextResult=n=>(e.next=["ok",n],e),e.willCall=n=>(t=n,e),e.restore=()=>t=r,e}var h=(t,r)=>Object.getOwnPropertyDescriptor(t,r);function E(t,r,e){i(!l("undefined",t),"spyOn could not find an object to spy upon"),i(l("object",t)||l("function",t),"cannot spyOn on a primitive value");let s=()=>typeof r=="string"?[r,"value"]:"getter"in r?[r.getter,"get"]:[r.setter,"set"],[n,o]=s(),y=h(t,n),p=Object.getPrototypeOf(t),a=h(p,n),f=y||a;i(f,`${n} does not exist`),i(f.configurable,`${n} is not declared configurable`);let g=f[o];e||(e=g);let c=v(e.bind(t)),T=k=>{let A=f,{value:w}=A,R=O(A,["value"]);o!=="value"&&delete R.writable,R[o]=k,Object.defineProperty(y?t:p,n,R)},m=()=>T(g);return c.restore=m,T(c),u.add(c),c}function q(){for(let t of u)t.restore();u.clear()}export{q as restoreAll,u as spies,v as spy,E as spyOn}; | ||
var S=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var O=(t,r)=>{var e={};for(var s in t)K.call(t,s)&&r.indexOf(s)<0&&(e[s]=t[s]);if(t!=null&&S)for(var s of S(t))r.indexOf(s)<0&&w.call(t,s)&&(e[s]=t[s]);return e};function i(t,r){if(!t)throw new Error(r)}function y(t,r){return typeof r===t}var f=new Set;function h(t){i(y("function",t)||y("undefined",t),"cannot spy on a non-function value");let r=t,e=(...n)=>{if(e.called=!0,e.callCount+=1,e.calls.push(n),e.next){let[u,c]=e.next;if(e.results.push(e.next),e.next=null,u==="ok")return c;throw c}let o,p="ok";if(t)try{o=t(...n),p="ok"}catch(u){o=u,p="error"}return e.results.push([p,o]),o};Object.defineProperty(e,"length",{value:t?t.length:0}),Object.defineProperty(e,"__isSpy",{value:!0}),Object.defineProperty(e,"returns",{get(){return this.results.map(([,n])=>n)}});let s=()=>{e.called=!1,e.callCount=0,e.results=[],e.calls=[]};return s(),e.reset=s,e.nextError=n=>(e.next=["error",n],e),e.nextResult=n=>(e.next=["ok",n],e),e.willCall=n=>(t=n,e),e.restore=()=>t=r,e}var m=(t,r)=>Object.getOwnPropertyDescriptor(t,r);function _(t,r,e){i(!y("undefined",t),"spyOn could not find an object to spy upon"),i(y("object",t)||y("function",t),"cannot spyOn on a primitive value");let s=()=>typeof r=="string"?[r,"value"]:"getter"in r?[r.getter,"get"]:[r.setter,"set"],[n,o]=s(),p=m(t,n),u=Object.getPrototypeOf(t),c=m(u,n),l=p||c;i(l,`${n} does not exist`),i(l.configurable,`${n} is not declared configurable`);let R=!1;o==="value"&&!l.value&&l.get&&(o="get",R=!0,e=l.get());let T=l[o];e||(e=T);let a=h(e.bind(t)),A=F=>{let v=l,{value:G}=v,g=O(v,["value"]);o!=="value"&&delete g.writable,g[o]=F,Object.defineProperty(p?t:u,n,g)},k=()=>A(T);return a.restore=k,A(R?()=>a:a),f.add(a),a}function z(){for(let t of f)t.restore();f.clear()}export{z as restoreAll,f as spies,h as spy,_ as spyOn}; |
{ | ||
"name": "tinyspy", | ||
"version": "0.0.13", | ||
"version": "0.0.14", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
4306
46
1