1.0.3 • Published 6 years ago

sniffpro v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

sniffpro

sniffpro


license

A simple function for debugging stuff like promise chains, streams and other pipeline-like thingees

Usage

const sniff = require('sniffpro')

fetch('https://api.com/users'))
	.then(response => response.json())
	.then(sniff) // Will console.log out the parsed json, and return the value, effectively passing it on to the next .then
	.then(user => Promise.all(user.friends.map(friend => getFriend(friendId))))
	.then(friends => /* do even more stuff here */)

Overriding prefix

sniffpro will log to console with a sniff prefix but if you want to override it like this

const sniff = require('sniffpro')

fetch('https://api.com/users')
	.then(response => response.json())
	.then(sniff.tag('mytag'))

Sniffing to file

const sniff = require('sniffpro')

fetch('https://api.com/users')
	.then(response => response.json())
	.then(sniff.save('api.json'))

Loading file

const sniff = require('sniffpro')

sniff.load('api.json')
	.then(data => data.name)
	.then(sniff)

Memoizing expensive calls to file

const sniff = require('sniffpro')

sniff.memo('api.json', () => fetch('https://api.com/users').then(response => response.json()))
	.then(data => data.name)
	.then(sniff)
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago