Skip to content

itwillwork/function-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

function-logger

Awesome tool for FP JS. Logging of the input and output arguments of the function on each call.

JSBin demo

Motivation

for example, debugging sort products code:

const byPrice = order => (a, b) => order(a.price, b.price);

const asc = (a, b) => a - b;
const desc = (a, b) => b - a;

const products = [{price: 100}, {price: 50}, {price: 300}];

// products.sort(byPrice(desc));

// use functionLogger for fast logging
products.sort(functionLogger(byPrice(desc)));

browser console output

output

Installation

npm install function-logger --save-dev

You can set globally, to be used in all their projects without having to install each.

Usage

Wrap the function for which you want to watch. And yet! 🏁

import functionLogger from 'function-logger';

// foo('bar')
functionLogger(foo)('bar')

Usage for CodePen and JSBin as UMD module

in html area

<script src="https://unpkg.com/function-logger@latest/build/umd/index.js"></script>

in js area use functionLogger from global scope

JSBin demo

Contributing

Got ideas on how to make this better? Open an issue!

License

MIT

About

Awesome tool for FP JS. Logging of the input and output arguments of the function on each call.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published