From 57beb2352862a8cac4f64908ce2420171b3ee030 Mon Sep 17 00:00:00 2001 From: Scott Bronson Date: Mon, 23 Dec 2013 11:44:55 -0800 Subject: [PATCH 1/2] Add info on calling js functions to README --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f9c7520..a36a233 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,11 @@ evaluate some simple JavaScript cxt = V8::Context.new cxt.eval('7 * 6') #=> 42 +call JavaScript functions + + cxt.eval "function isTruthy(arg) { return !!arg }" + cxt.scope.isTruthy(0) #=> false + embed values into the scope of your context cxt['foo'] = "bar" @@ -173,4 +178,4 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. [1]: https://github.com/cowboyd/libv8 -[2]: http://code.google.com/p/v8/wiki/BuildingWithGYP \ No newline at end of file +[2]: http://code.google.com/p/v8/wiki/BuildingWithGYP From 40b64b8f860e9ae623e8d3690d76e89f9f9fe6e4 Mon Sep 17 00:00:00 2001 From: Scott Bronson Date: Mon, 23 Dec 2013 12:11:05 -0800 Subject: [PATCH 2/2] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a36a233..36cfe04 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,8 @@ evaluate some simple JavaScript call JavaScript functions cxt.eval "function isTruthy(arg) { return !!arg }" - cxt.scope.isTruthy(0) #=> false + cxt[:isTruthy].call(' ') #=> true + cxt.scope.isTruthy(0) #=> false embed values into the scope of your context