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

tinyspy

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tinyspy - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

2

dist/index.js

@@ -1,1 +0,1 @@

var A=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var O=(t,e)=>{var s={};for(var r in t)w.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(t!=null&&A)for(var r of A(t))e.indexOf(r)<0&&K.call(t,r)&&(s[r]=t[r]);return s};function y(t,e){if(!t)throw new Error(e)}function a(t,e){return typeof e===t}var c=new Set;function h(t){y(a("function",t)||a("undefined",t),"cannot spy on a non-function value");let e=function(...r){if(e.called=!0,e.callCount++,e.calls.push(r),e.next){let[l,d]=e.next;if(e.results.push(e.next),e.next=null,l==="ok")return d;throw d}let n,o="ok";if(e.impl)try{n=e.impl.apply(this,r),o="ok"}catch(l){n=l,o="error"}let f=[o,n];return n&&a("object",n)&&a("function",n.then)&&n.then(l=>f[1]=l),e.results.push(f),n};Object.defineProperty(e,"length",{value:t?t.length:0}),Object.defineProperty(e,"__isSpy",{value:!0}),Object.defineProperty(e,"returns",{get(){return this.results.map(([,r])=>r)}}),Object.defineProperty(e,"name",{value:t&&t.name||"spy"});let s=()=>{e.called=!1,e.callCount=0,e.results=[],e.calls=[]};return s(),e.impl=t,e.reset=s,e.nextError=r=>(e.next=["error",r],e),e.nextResult=r=>(e.next=["ok",r],e),e}var k=(t,e)=>Object.getOwnPropertyDescriptor(t,e);function E(t,e,s){y(!a("undefined",t),"spyOn could not find an object to spy upon"),y(a("object",t)||a("function",t),"cannot spyOn on a primitive value");let r=()=>typeof e=="string"?[e,"value"]:"getter"in e?[e.getter,"get"]:[e.setter,"set"],[n,o]=r(),f=k(t,n),l=Object.getPrototypeOf(t),d=l&&k(l,n),p=f||d;y(p||n in t,`${n} does not exist`);let R=!1;o==="value"&&p&&!p.value&&p.get&&(o="get",R=!0,s=p.get());let u;p?u=p[o]:o!=="value"?u=()=>t[n]:u=t[n],s||(s=u);let i=h(s),S=T=>{let v=p||{configurable:!0,writable:!0},{value:F}=v,m=O(v,["value"]);o!=="value"&&delete m.writable,m[o]=T,Object.defineProperty(f||!p?t:l,n,m)},P=()=>S(u);return i.restore=P,i.getOriginal=()=>R?u():u,i.willCall=T=>(i.impl=T,i),S(R?()=>i:i),c.add(i),i}function q(){for(let t of c)t.restore();c.clear()}export{q as restoreAll,c as spies,h as spy,E as spyOn};
var v=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var A=(t,e)=>{var o={};for(var r in t)w.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(t!=null&&v)for(var r of v(t))e.indexOf(r)<0&&K.call(t,r)&&(o[r]=t[r]);return o};function f(t,e){if(!t)throw new Error(e)}function a(t,e){return typeof e===t}var c=new Set;function O(t){f(a("function",t)||a("undefined",t),"cannot spy on a non-function value");let e=function(...r){if(e.called=!0,e.callCount++,e.calls.push(r),e.next){let[s,d]=e.next;if(e.results.push(e.next),e.next=null,s==="ok")return d;throw d}let n,l="ok";if(e.impl)try{n=e.impl.apply(this,r),l="ok"}catch(s){n=s,l="error"}let u=[l,n];return n&&a("object",n)&&a("function",n.then)&&(n=n.then(s=>u[1]=s).catch(s=>{throw u[0]="error",u[1]=s,s})),e.results.push(u),n};Object.defineProperty(e,"length",{value:t?t.length:0}),Object.defineProperty(e,"__isSpy",{value:!0}),Object.defineProperty(e,"returns",{get(){return this.results.map(([,r])=>r)}}),Object.defineProperty(e,"name",{value:t&&t.name||"spy"});let o=()=>{e.called=!1,e.callCount=0,e.results=[],e.calls=[]};return o(),e.impl=t,e.reset=o,e.nextError=r=>(e.next=["error",r],e),e.nextResult=r=>(e.next=["ok",r],e),e}var k=(t,e)=>Object.getOwnPropertyDescriptor(t,e);function E(t,e,o){f(!a("undefined",t),"spyOn could not find an object to spy upon"),f(a("object",t)||a("function",t),"cannot spyOn on a primitive value");let r=()=>typeof e=="string"?[e,"value"]:"getter"in e?[e.getter,"get"]:[e.setter,"set"],[n,l]=r(),u=k(t,n),s=Object.getPrototypeOf(t),d=s&&k(s,n),p=u||d;f(p||n in t,`${n} does not exist`);let R=!1;l==="value"&&p&&!p.value&&p.get&&(l="get",R=!0,o=p.get());let y;p?y=p[l]:l!=="value"?y=()=>t[n]:y=t[n],o||(o=y);let i=O(o),h=T=>{let S=p||{configurable:!0,writable:!0},{value:F}=S,m=A(S,["value"]);l!=="value"&&delete m.writable,m[l]=T,Object.defineProperty(u||!p?t:s,n,m)},P=()=>h(y);return i.restore=P,i.getOriginal=()=>R?y():y,i.willCall=T=>(i.impl=T,i),h(R?()=>i:i),c.add(i),i}function q(){for(let t of c)t.restore();c.clear()}export{q as restoreAll,c as spies,O as spy,E as spyOn};
{
"name": "tinyspy",
"version": "0.2.4",
"version": "0.2.5",
"type": "module",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

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