https://github.com/mvertes/co-shell
yield and promise enabled node REPL extension
https://github.com/mvertes/co-shell
Last synced: about 1 year ago
JSON representation
yield and promise enabled node REPL extension
- Host: GitHub
- URL: https://github.com/mvertes/co-shell
- Owner: mvertes
- License: mit
- Created: 2015-04-04T13:08:40.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-06-23T07:47:25.000Z (almost 10 years ago)
- Last Synced: 2025-04-08T18:57:24.333Z (about 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# co-shell
[](https://travis-ci.org/mvertes/co-shell)
Extend node.js core [REPL](https://nodejs.org/api/repl.html) module
to support promises, [co](https://github.com/tj/co) and `yield` statements.
Both executable and module for use in programs are provided.
## Install
```
$ npm install [-g] co-shell
```
## Usage
Install some promized stuff, for example [mz](https://github.com/normalize/mz):
```
$ npm install mz
```
Then run the provided `bin/co-shell` executable.
Adjust first line `#!/usr/local/bin/node --harmony` if necessary.
```js
$ co-shell
co-shell> fs = require('mz/fs')
co-shell> a = yield fs.readFile('/etc/hosts', 'utf-8')
co-shell> console.log(a)
```
## API
Using `co-shell` in a program is quite simple. Lets build a shell
as above, enabling access to `mz/fs`:
```js
var coshell = require('co-shell');
var context = coshell({prompt: 'co-shell> '}).context;
context.fs = require('mz/fs');
```
`coshell(options)` has exactly the same syntax as `repl.start(options)`
in core [REPL](https://nodejs.org/api/repl.html). Please refer
to the original documentation for further details.
## License
[MIT license](./LICENSE).