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

@bowdens/react-terminal

v2.0.1

Published

A novelty terminal emulator for react

Downloads

3

Readme

react-terminal

A novelty terminal emulator for react. You probably shouldn't use this for anything serious. Pass in programs as callback functions that are called with the arguments the user specifies. The input line supports (some of) the bash shortcuts like control-L to clear the screen, as well as the arrow keys up and down to navigate command history.

NPM JavaScript Style Guide

Install

npm install --save @bowdens/react-terminal

Usage

import React from 'react'

import Console from '@bowdens/react-terminal'
import '@bowdens/react-terminal/dist/index.css'

const Example = () => {
  const programs = {
    echo: ({argv: [_, ...args]}) => {
      return args.join(" ")
    },
  }
  return (
    <Console programs={programs}/>
  )
}

Props

Prop | Description | Example -----|------|----- programs | An object with all of the programs. It should be in the form programName: function. The callback function is passed an object with a single element 'argv' which is an array of the arguments that were specified when the program was invoked. It expects a single string as output to return to stdout. There is no stderr functionality. | {echo: ({argv: [prog, ...args]}) => "example stdout"} prompt | The prompt to show before the user's text. Its best to use the \u00a0 at the end of the prompt so the rendered HTML won't compress the whitespace. Default is "$\u00a0" | ">\u00a0" style | Any styling for the component. Colours will be passed down to the input elements | { color: "limegreen", backgroundColor: "black" } motd | A string that will be displayed when the component is first rendered. | "Welcome to the terminal!" tabComplete | A callback that is fired whenever the tab key is pressed while the console is focussed. It is passed the current value and the number of tab keys pressed in a row without the value changing. It expects a value to be returned, either the existing value if no change is to be made, or a new value which will update the current value in the console input. If it is not provided the default is used, which attempts to match the input value with the programs by prefix. | (value, ntabs)=>{...} ref | A ref that provides the following properties: pushCommand which accepts a single argument (a command) that executes that command, and appendToStdout which accepts a single argument, either a string or an array of strings, which are appended to stdout. This allows the console to be used programatically without direct user input.

Check out example/src/App.js for a more complete example with a working echo program.

License

MIT © bowdens