npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lazer-js

v1.4.5

Published

A console printer with a fluent API

Downloads

10

Readme

lazer

Lazer is a utility for printing to the console using a fluent API. Written in TypeScript and compatible with Deno and Node.js runtimes.

Description

Lazer helps you build, format and print complex messages to the console using an expressive fluent API.

Usage

Simple Example

example.ts

import { lazer } from "https://deno.land/x/lazer/mod.ts"

lazer()
    .print("Hello,")
    .print_space()
    .print_green("Green World")
    .print_ln("!")
$ deno run example.ts
Hello, Green World!

Complex Example

example.ts

import { lazer } from "https://deno.land/x/lazer/mod.ts"

const remoteAddr = "127.0.0.1";
const method = "GET";
const path = "/a/really/really/really/long/path/here";
const status = 200;
const time_ms = 20;
const size_bytes_string = "1.10kB";

lazer()
    .print('[').print_utc_time().print(']')
    .print_space().print("-").print_space()
    .print_pad_right(remoteAddr, 15, '_')
    .print_space(2)
    .print_pad_right(method, 4, '_')
    .print_space(2)
    .print_pad_right(path, 20, "_")
    .print_space(2)
    .if(status >= 200 && status < 300)
        .print_green(status)
    .elseif(status >= 300 && status < 400)
        .print_yellow(status)
    .elseif(status >= 400)
        .print_red(status)
    .end()
    .print_space(2)
    .print_pad_right(`${time_ms}ms`, 6, "_")
    .print_space(2)
    .print_ln(size_bytes_string);
$ deno run example.ts
[Fri, 01 Jan 2021 00:00:00 GMT] - 127.0.0.1______  GET_  /a/really/really/+42  200  20ms__  1.10kB 

Buffering Example

example.ts

import { lazer } from "https://deno.land/x/lazer/mod.ts"

const getLinePrefix = () => 
{
    return lazer().buffer()
        .print_yellow('[').print_yellow("Line Prefix").print_yellow(']')
        .print_space().print("-").print_space()
        .print_yellow('[').set_color_yellow().print_utc_time().print_yellow(']')
        .print_space().print("-").print_space()
        .return();
}

lazer()
    .print(getLinePrefix())
    .print_yellow_ln("This is a prefixed line of text output");

lazer()
    .print(getLinePrefix())
    .print_yellow_ln("This is another prefixed line of text output");
$ deno run example.ts
[Line Prefix] - [Mon, 10 May 2021 16:31:29 GMT] - This is a prefixed line of text output
[Line Prefix] - [Mon, 10 May 2021 16:31:29 GMT] - This is another prefixed line of text output

Buffer Aliasing Example

example.ts

import { lazer } from "https://deno.land/x/lazer/mod.ts"

lazer().buffer()
    .set_color_red().print_ln("Some red output to buffer")
    .store('i am an alias');

lazer().buffer()
    .load('i am an alias')
    .print_b();
$ deno run example.ts
Some red output to buffer

Toggling Color Mode Example

example.ts

import { lazer } from "https://deno.land/x/lazer/mod.ts"

lazer()
    .color_off()
    .print_yellow_ln("I am not yellow")
    .color_on()
    .print_yellow_ln("I am yellow");
$ deno run example.ts
I am not yellow
I am yellow

Supported Platforms

Deno

import { lazer } from "https://deno.land/x/lazer/mod.ts"

Node.js

npm i --save lazer-js
const { lazer } = require('lazer-js');