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 🙏

© 2025 – Pkg Stats / Ryan Hefner

web-termjs

v1.1.2

Published

Terminal emulator for browsers

Readme

web-termjs

Terminal emulator for browsers

This repository got inspired by SDA/terminal

Live Demo

Quickstart

Browser

Download or clone this repository or the dist folder and add it to your project.

Add following to the head in your HTML file:

<link href="/path/to/web-termjs/dist/terminal.min.css">
<script src="/path/to/web-termjs/dist/terminal.min.js"></script>

Add a container which will hold the terminal like this:

<body>
    <div id="terminal"></div>
</body>

Add another script after the terminal.min.js (in <script> tags or in a extra file) and add following example:

var container = document.getElementById('terminal');
var term = new terminal.Terminal({
        welcome: 'Hi! :D',
        prompt: '',
        separator: '$',
        theme: 'dark'
    })
    .openIn(container)
    .onCommand(commands);

function commands(cmd, args, stream) {
    if (cmd === 'test') {
        stream.write('succeed');
    }
    stream.close();
}

Or just run the index.html in example folder.

NodeJS

Download the package from NPM.

npm install --save web-termjs

Then import it and create the terminal.

JavaScript

const Terminal = require('web-termjs').Terminal;

const term = new Terminal()
    .openIn(...)
    .onCommand(...);

TypeScript

import { Terminal } from 'web-termjs';

const term: Terminal = new Terminal()
    .openIn(...)
    .onCommand(...);

Angular 5 Example

app.component.html
<div #terminal></div>
app.component.ts
import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
import { Terminal, Stream } from 'web-termjs';
import { Options } from 'web-termjs/lib/options';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterViewInit {
  @ViewChild('terminal') terminal: ElementRef;
  term: Terminal;

  ngAfterViewInit() {
    const options: Options = {
      welcome: 'Hello!',
      prompt: '',
      separator: '>',
      theme: 'light'
    };
    this.term = new Terminal(this.terminal.nativeElement, this.onCommand, options);
  }

  onCommand(cmd: string, args: string[], stream: Stream) {
    stream.write('Ok!');
    stream.close();
  }
}

Custom Themes

Create a CSS file with following content which you can specify (with examples):

# Font
.terminal-custom-name {
	color: black;
	font-family: monospace;
}

# Links
.terminal-custom-name a {
	color: #000;
}

# Background
.terminal-custom-name .background {
	background: #fff;
}

# Styles for the whole container
.terminal-custom-name .background .term-container {
    text-shadow: none;
    padding: 4px;
}

# Prompt
.terminal-custom-name .prompt {
	color: #02f;
}

Add this CSS file after terminal.css to your project. Then you can define your theme in the options parameter

theme: 'custom-name'

or set it with

term.setTheme('custom-name');

API

class Terminal

constructor

constructor(options: Options)

options has a default value:

{
    welcome: '',
    prompt: '',
    separator: '$',
    theme: 'dark'
}

theme

theme: string

Getter and setter of the theme

prompt

prompt: string

Getter and setter of the prompt

container

container: HTMLElement

Getter of the container

clear

clear(): void

Clears the screen.

close

close(): void

Removes the terminal from the website.

openIn

openIn(container: HTMLElement): Terminal

Sets the container by the given parameter and starts it.

onCommand

onCommand(exec: (cmd: string, args: string[], stream: Stream) => any): Terminal

Sets the function which will be called when a command has entered.

class Stream

write

write(html: string): void

Prints the given text (can be html style) into the terminal. If you closed the stream you can't write into the terminal anymore.

close

close(): void

Closes the stream. After this a new prompt appears.

interface Options

welcome: string

Will be shown on initialize terminal.

prompt: string

Will be shown on every input at the beginning.

separator: string

Separator between prompt and input.

theme: string

Name of theme.

License

Copyright 2017 Daniel Däschle

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.