Console log helpers for your debugging journey
npm install tacker -S
import { printLine, printMirror, printPkgVersion, printPkgProp } from "tacker";
printLine(szColor || oColor)
- Sync
- szColor is a string. Color options can be found on chalk's readme or in source here
- oColor is an object comprised of properties so you can mnaually configure the line
color
: the color of the line; default is bluecharacter
: the character which will make up the line; default is -length
: represents the number of characters to repeat; default is 59quantity
represents the number of lines to print; default is 1
-
printLine("blue")
-
printLine({color:"blue", character:"-","length:59",quantity:1})
printMirror({ mVariable }, szKeyColor, szValueColor)
- Sync
This will print the variable's name and the variable's value (regardless of variable type).
- mVariable is an object or a variable you would like to print. If it's an object or an array, it will pretty-print using JSON.stringify.
- szVariableKeyColor is a string of the variable's key.
- szVariableValueColor is an object or a variable
const mock = {
foo: "bar"
};
printMirror({mock}, "blue", "grey")
printPkgVersion(mPkgSource)
- Async
This will print the version of the specified package.
- mPkgSource allows you to specify which package to read from.
-
undefined
-
string
-
object
-
await printPkgVersion()
await printPkgVersion("/path")
await printPkgVersion("/path/package.json")
await printPkgVersion({ name: "tacker", version: "x.y.z", ...})
printPkgProp(szProperty, mPkgSource)
- Async
This will print any property from the specified package.
- szProperty allows you to specify the package property.
- mPkgSource allows you to specify which package to read from.
-
undefined
-
string
-
object
-
await printPkgProp("version")
await printPkgProp("version", "/path")
await printPkgProp("version", "/path/package.json")
await printPkgProp("version", { name: "tacker", version: "x.y.z", ...})
Name
Portmaneau of "tack" and "logger"In a sailing context, tack means "change course by turning a boat's head into and through the wind"
Why
There's reasons to use more sophisticated tooling (stack traces, Chrome dev tools, etc). However, when you're getting up-and-running with a project, it's extremely helpful to be able to log values. The issue is before long, your terminal is contaminated with a slew of logs. Tacker exists to solve thisHow
- Make logs prettier (current)
- Only log things in certain circumstances (future)