Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apochromat

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apochromat

Dynamic text rendering for interactive command line apps.

  • 0.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

apochromat

Dynamic text rendering for interactive command line apps.

  • @apochromat/print: Dynamic text output for interactive command line apps.
  • @apochromat/animation: Dynamic text animations for interactive command line apps.

Installation

npm install apochromat --save

Usage

Hello World

import {Lens} from 'apochromat';

const greeting = new Lens();
const salutation = new Lens();
const subject = new Lens();

greeting.subscribe((event) => {
  if (event === 'render') {
    console.log(greeting.frame);
  }
});

salutation.render`Hi`;
subject.render`everyone`;
greeting.render`${salutation}, ${subject}!`;
subject.render`world`;
salutation.render`Hello`;
Hi, everyone!
Hi, world!
Hello, world!

Rendering of dynamic lists

import {Lens, list} from 'apochromat';

const foobarbaz = new Lens();
const foo = new Lens();
const bar = new Lens();
const baz = new Lens();

foo.render`foo`;
bar.render`bar`;
baz.render`baz`;
foobarbaz.render(...list(',', foo, bar, baz));
console.log(foobarbaz.frame);
foo,bar,baz

Types

type LensListener = (event: LensEvent) => void;
type LensEvent = 'attach' | 'detach' | 'render';

class Lens {
  get frame(): string;
  render(segments: readonly string[], ...children: readonly unknown[]): boolean;
  subscribe(listener: LensListener): () => void;
}
function list(
  delimiter: string,
  ...elements: readonly unknown[]
): [readonly string[], ...(readonly unknown[])];

Copyright 2021 Clemens Akens. All rights reserved. MIT license.

FAQs

Package last updated on 22 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc