Skip to content

Commit

Permalink
[js] Fix README formating
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Oct 5, 2019
1 parent f148d61 commit 6c35cef
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/vm/js/README.md
Expand Up @@ -21,14 +21,18 @@ npm install --save chalk
```

To use node.js modules you need to specify where they should be looked for.
use lib 'nodejs#/your/path/to/node/modules' is a good way to do that

```use lib 'nodejs#/your/path/to/node/modules'``` is a good way to do that.

```
use lib 'nodejs#' ~ $*PROGRAM.parent.add('node_modules').absolute;
use chalk:from<node.js>;
say("Hello {chalk.blue("Blue")} World");
```

Keep in mind that if you load a node.js module during precompilation it gets
*reloaded* at runtime, so it's internal state gets lost.

# Interoperability with JS

Passing :lang<JavaScript> to eval will execute the passed code as JavaScript.
Expand All @@ -54,7 +58,6 @@ Primitive JS data types are converted rather then wrapped
| undefined | Mu |
| BigInt | Int |
| Number | Num |
| -------------|-------|

A Perl 6 Mu when passed to JS land ends up as null

Expand All @@ -71,14 +74,23 @@ In order to enable using wrapped objects in Perl 6 land wrapped objects
offer some methods that Perl 6 expects.

* sink

Does nothing.

* defined

Always returns True

* Bool

Always returns True

* item

Returns the object it is called on

* new

Uses the JavaScript new operator to create an new instance

```perl6
Expand All @@ -91,5 +103,6 @@ offer some methods that Perl 6 expects.
If the wrapped object has method of that same name you can use an :INTERNAL modifier to access it.

```$obj.new(:INTERNAL, 123)```
| -------------|-------|

This will call a js new method rather then doing ``new $obj(123)```

0 comments on commit 6c35cef

Please sign in to comment.