0.2.0 • Published 8 years ago

tap-debug v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

tap-debug Build Status npm version

:beer: Debug on tap.

Why?

Helps afford the creation of data-driven, narrative user journeys, aka. log level 'human'.

  • Plays nicely with the then() and tap() methods of your promises as well as functional pipelines.
  • ES6-style variable interpolation built in.
  • Colored output makes it easy to spot variables and their values.
  • :v::ok_hand::heart_eyes: Emojis :raised_hands::fire::star2:

Example

Example

'use strict';

var debug = require('debug')('icebox:checker');
var see = require('tap-debug')(debug);

var checkIcebox = require('./icebox').get;

function checkIceboxForPlums() {
  var hasPlums = function(icebox) {
    return icebox.plum > 0;
  };

  return checkIcebox('plum').
         tap(see(':speak_no_evil: There are ${plum} plums in the icebox.')).
         then(hasPlums);
}

See these examples for further usage instructions.

API

require('tap-debug')(debugFn, options)

Takes a debugFn such as visionmedia/debug and a configuration options object.

{
  stringifyValue: false,
  stringifyValueSeparator: ': ',
  stringifyValueFormatter: 'inspect',
  emojify: true,
  colorify: true
}

tapDebug(message[, options])(object)

A curried tap()able version of the debugger.

See above for a working example.

.debug(message[, object, options])

A ternary version of the curried tap()able version of the debugger.

var see = require('tap-debug')();
see.debug('hello there');
.ifElse(predicate, ifMessage, elseMessage[, options])(object)

A curried tap()able version of the debugger, which will switch its message depending on whether the predicate function supplied returns true or false on being called with the object.

var see = require('tap-debug')();
// ...
promise.tap(see.ifElse(isNull, 'This promise was null', 'This promise was not null.'));
.switchCase(getCase, caseMessages[, options])(object)

A curried tap()able version of the debugger, which can switch its message depending on whether the getCase function supplied returns a key which matches a message in caseMessages on being called with the object.

var see = require('tap-debug')();
// ...
promise.tap(see.switchCase(getCase, {
  'case-one': 'This is the first message.',
  'case-two': 'This is the second message.',
  'default': 'This is the default message.'
}));
0.2.0

8 years ago

0.1.8

8 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago