New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

spyjunk

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spyjunk

Simple utility to spy on objects and functions. To improve the desperate experience of `console.log` debugging.

  • 0.0.2
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

spyjunk

Simple utility to spy on objects and functions. To improve the desperate experience of console.log debugging.

Install

npm install spyjunk

Usage

Object Spy

import { makeObjectSpy } from "spyjunk";

const someFunc = (x, y) => x + y;

const target = {
  n: 123,
  s: "someString"
};

const spy = makeObjectSpy(target, "someSpy");

spy.z = 666;

someFunc(spy.n, spy.z);

This will produce the following output:

Creating object spy "someSpy" for object: {"n":123,"s":"someString"}
Writing value 666 to property "z" on spy "someSpy" in {"n":123,"s":"someString"}.
Reading property "n" on spy "someSpy" in {"n":123,"s":"someString","z":666}.
Reading property "z" on spy "someSpy" in {"n":123,"s":"someString","z":666}.

If no target object is specified, a new empty one will be used. If no name is provided, the default name will be used.

Function Spy

import { makeFunctionSpy } from "spyjunk";

const target = (x, y) => x + y;

const spy = makeFunctionSpy(target, "someSpy");

spy(123, "someString");

This will produce the following output:

Creating function spy someSpy for function: (x, y) => x + y
Called function spy "someSpy" with arguments [123,someString] and context: undefined.

If no target object is specified, a new empty function will be used. If no name is provided, the default name will be used.

Keywords

FAQs

Package last updated on 23 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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