Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/namusyaka/jsh
Interactive interpreter for JavaScript which is written in Ruby.
https://github.com/namusyaka/jsh
Last synced: about 1 month ago
JSON representation
Interactive interpreter for JavaScript which is written in Ruby.
- Host: GitHub
- URL: https://github.com/namusyaka/jsh
- Owner: namusyaka
- Created: 2013-11-16T16:10:46.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2013-11-17T08:00:22.000Z (almost 11 years ago)
- Last Synced: 2024-10-06T09:21:43.246Z (about 1 month ago)
- Language: Ruby
- Homepage:
- Size: 125 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JSH
[![Build Status](https://travis-ci.org/namusyaka/jsh.png)](https://travis-ci.org/namusyaka/jsh)
This is an interactive interpreter for JavaScript which is written in Ruby.
## Installation
add this line to your Gemfile.
`gem 'jsh'`
or
`$ gem install jsh`
## Usage
### Basic
```shell
$ jsh
[0] jsh) 1 + 1;
2
[1] jsh) "hello world".length;
11
[2] jsh) (function fib(n){ return (n < 2) ? 1 : fib(n - 2) + fib(n - 1); })(10);
89
```### Customize
You can customize in these way.
Then save and execute it.#### `hooks`
```ruby
require 'jsh'JSH::Hooks.register(:before) do
puts "before hook!"
endJSH::Hooks.register(:after) do
puts "after hook!"
endJSH.start
```#### `commands`
Save this file as `foo.rb`.
```ruby
require 'jsh'JSH::Commands.register(:enable_to_say) do |jsh|
jsh.context['say'] = lambda{|this, word, times| word * times }
endJSH.start
```Then execute it.
```shell
$ ruby foo.rb
[0] jsh) enable_to_say
[1] jsh) say('Hello', 3)
HelloHelloHello
```### Options
#### `-r --readline=BOOLEAN`
readline option should be boolean.
default value is `true`.
if set `false` to this option, jsh will not use Readline to input.#### `--noprompt`
if use `--noprompt`, jsh will not print prompt.
## License
The MIT License