View on GitHub

ts-base

Boring things for projects

Download this project as a .zip file Download this project as a tar.gz file

ts-base

Build PR/Master

Boring project components.

Install

npm install --save @btilford/ts-base-node
npm install --save @btilford/ts-base-browser

Usage

Examples can be found here

Features

Logging

Extra features and configurability for logging. By default uses Console but with node can also use a stream.Writable for stdout and stderr output.

Log Type Browser Node Comment
ConsoleLog yes yes Just a wrapper around console
StdOutLog no yes Uses a Writable defaulting to stdout/stderr
JsonLog no yes TODO

APM

There are some method decorators for instrumenting methods with custom APM. The decorators can accept a Filter that can determine whether to run the decorator or just run the original method. For example only run the decorator N times or at intervals.

Type System Provider
@Timed Browser Console
@Timed Node Console, StatsD, Prometheus
@TimedAsync Browser Console
@TimedAsync Node Console, StatsD, Prometheus
@CountInvocations Browser Console
@CountInvocations Node Console, StatsD, Prometheus
@CountSuccess Browser Console
@CountSuccess Node Console, StatsD, Prometheus
@CountErrors Browser Console
@CountErrors Node Console, StatsD, Prometheus
@GaugeInvocations Node Console, StatsD, Prometheus
@GaugeSuccess Node Console, StatsD, Prometheus
@GaugeErrors Node Console, StatsD, Prometheus

Time

Note most of the things in this package use BigInt which isn’t super well supported yet.

Classes

Utilities

Other Stuff