Code Monkey home page Code Monkey logo

jsniff's Introduction

jSniff

jSniff is a javascript libary which helps you to sniff functions. When function is sniffed its execution date and parameters are logged by jSniff. In addition, a custom function can be injected to the sniffed function to execute before the original code.
*important: a sniffed function can still be debugged in devTools and its execution will work as if it was not sniffed.

Check jSniff's .NET port to be used with Selenium WebDriver - jSniff.NET

How to use


add script tag to your website:
<script type="text/javascript" src="jSniff.js"></script>

sniff the function using:
jSniff.sniffify

function (obj, funcName, sniffName, customFunc)
  • obj: The object on which the function exists (if it is a function declaration then use window)
  • funcName: The name of the function
  • sniffName: The name for the sniff. It is later used when retrieving the invocations data
  • customFunc: A custom function which will be executed prior to the original function's code

lets assume we have a function declaration as follows:

function multiply(a,b){
    return a*b;
}

so to sniff it we execute:

jSniff.sniffify(window, 'multiply', 'window_multiply', function() { console.log('hello jSniff');} );

retrieve sniffed data using:
jSniff.getInvocations

function getInvocations (sniffName)

This method returns an array of invocations sniffed data. Invocation sniffed data is an object with two properties:

  • executionDate: Javascript Date object with the execution date.
  • params: Array of the execution parameters. Each element in array is an array for itself with two elements. First element is the name of the parameter and the second is its value

jSniff.getLastInvocation

function getLastInvocation (sniffName)

This method returns the last execution sniffed data. the returned object has two properties:

  • executionDate: Javascript Date object with the execution date.
  • params: Array of the execution parameters. Each element in array is an array for itself with two elements. First element is the name of the parameter and the second is its value

jSniff.getInvocations

function getLastInvocationParams (sniffName)

This method returns an array of the last execution parameters. Each element in the array is an array for itself with two elements. First element is the name of the parameter and the second is its value

jsniff's People

Contributors

galziv avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.