cycle-shell
[![Build status][travis-image]][travis-url] [![Git tag][git-image]][git-url] [![NPM version][npm-image]][npm-url] [![Code style][standard-image]][standard-url]
Last updated 4 years ago by danleavitt0 .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install cycle-shell 
SYNC missed versions from official npm registry.

cycle shell

Build status Git tag NPM version Code style

A programmable web based shell-like interface

Installation

npm install cycle-shell

Usage

import cycle from 'cycle-shell'

cycle(main, {
  welcome: 'Welcome to my shell.'
})

function main (input) {
  return input
}

API

cycle(update, opts)

Initialize a cycle shell instance. By default, the cycle shell will be placed in the <body> of the document.

Returns Process count listener

var counter = require('cycle-shell')(main)
counter(function (num) {
  console.log(num)
})
update
  • type: function
  • An update function that gets run when the input box is submitted
opts
  • type: object
welcome
  • type: string
  • A message to be displayed when the shell is first run
title
  • type: string
  • The title of the game/application to be displayed next to the input box
view
  • type: function
  • The return value from the main function gets run through the view function to produce a valid output.

The default view function is set up to handle objects, arrays, strings, numbers, and vdux components.

const defaultView = (output) => {
  if (typeof (output) !== 'object' || output.props) {
    return output
  } else if (isArray(output)) {
    output.join('\n')
  } else {
    return reduce((arr, item, key) => {
      arr.push(`${key}: ${item}`)
      return arr
    }, [], output).join('\n')
  }
}
initialState
  • type: object
  • set an initial state for the application
middleware
  • type: function || generator
  • Connect custom middleware to cycle shell

out(msg)

Exposed out action for adding messages to the output log.

msg
  • type: string
  • A message to be placed in the output log.

Current Tags

  • 0.4.22                                ...           latest (4 years ago)

35 Versions

  • 0.4.22                                ...           4 years ago
  • 0.4.21                                ...           4 years ago
  • 0.4.20                                ...           4 years ago
  • 0.4.19                                ...           4 years ago
  • 0.4.18                                ...           4 years ago
  • 0.4.17                                ...           4 years ago
  • 0.4.16                                ...           4 years ago
  • 0.4.15                                ...           4 years ago
  • 0.4.14                                ...           4 years ago
  • 0.4.13                                ...           4 years ago
  • 0.4.12                                ...           4 years ago
  • 0.4.11                                ...           5 years ago
  • 0.4.10                                ...           5 years ago
  • 0.4.9                                ...           5 years ago
  • 0.4.8                                ...           5 years ago
  • 0.4.7                                ...           5 years ago
  • 0.4.6                                ...           5 years ago
  • 0.4.5                                ...           5 years ago
  • 0.4.3                                ...           5 years ago
  • 0.4.2                                ...           5 years ago
  • 0.4.1                                ...           5 years ago
  • 0.4.0                                ...           5 years ago
  • 0.3.9                                ...           5 years ago
  • 0.3.8                                ...           5 years ago
  • 0.3.7                                ...           5 years ago
  • 0.3.5                                ...           5 years ago
  • 0.3.3                                ...           5 years ago
  • 0.3.2                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.1.6                                ...           5 years ago
  • 0.1.5                                ...           5 years ago
  • 0.1.4                                ...           5 years ago
  • 0.1.3                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 1
Dependencies (18)
Dev Dependencies (24)
Dependents (2)

Copyright 2014 - 2017 © taobao.org |