Skip to content

Commit

Permalink
JS: Make npm module importable. Update instructions.
Browse files Browse the repository at this point in the history
  • Loading branch information
kanaka committed Feb 8, 2017
1 parent c1955a8 commit f4400dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -8,4 +8,5 @@ RegPack/node_modules
old
notes
*.pyc
*.pyz
*-minipy.py
17 changes: 12 additions & 5 deletions README.md
Expand Up @@ -18,7 +18,7 @@ fairly different from mal so it is a standalone project.

You can try out miniMAL with the [online REPL](http://kanaka.github.io/miniMAL/).

The easiest way to install miniMAL is via npm:
Install the miniMAL binary using npm:

```bash
sudo npm install -g minimal-lisp
Expand All @@ -29,13 +29,13 @@ There are several different ways to use and/or integrate miniMAL:
* **Start a REPL**: run the miniMAL REPL (read-eval-print-loop). Requires
Node.js.
```bash
./miniMAL
miniMAL
```

* **Run a miniMAL program**: run a miniMAL program and then exit.
Requires Node.js.
```bash
./miniMAL hello.json
miniMAL hello.json
```

* **As a shebang script**: add a shebang line to the top of your
Expand All @@ -48,18 +48,25 @@ chmod +x hello2.json
./hello2.json
```

To use miniMAL as a library in another project, first install the
module locally using npm:

```bash
sudo npm install minimal-lisp
```

* **Node.js library**: you can use the miniMAL Node.js library to
evaluate miniMAL source code in a regular Node.js program.
```javascript
var miniMAL = require('./miniMAL-node.js'),
var miniMAL = require('minimal-lisp'),
m = miniMAL();
m.eval(["+", 2, 3]);
```

* **Web library**: you can use the miniMAL web library to evaluate
miniMAL code in your web application.
```html
<script src="miniMAL-min.js"></script>
<script src="node_modules/minimal-lisp/js/web/miniMAL-min.js"></script>
<script>
var m = miniMAL();
m.eval(["+", 2, 3]);
Expand Down
1 change: 1 addition & 0 deletions js/index.js
@@ -0,0 +1 @@
module.exports = require('./miniMAL-node.js');
1 change: 1 addition & 0 deletions js/package.json
Expand Up @@ -14,6 +14,7 @@
"files": [
"miniMAL",
"miniMAL-node.js",
"index.js",
"miniMAL-min.js",
"miniMAL-js1k.js",
"step*.js",
Expand Down

0 comments on commit f4400dc

Please sign in to comment.