A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/cowboyd/commonjs.rb below:

cowboyd/commonjs.rb: Common JS for Ruby

CommonJS

Host CommonJS JavaScript environments in Ruby

The internet is now awash with non-browser JavaScript code. Much of this code conforms to some simple conventions that let you use it anywhere you have a JavaScript interpreter available. These conventions are collectively called "commonjs"

We have several JavaScript interpreters available to us from Ruby. Therefore, why shouldn't we be able to use commonjs applications and libraries?

Using common JS from Ruby.

CommonJS now passes all of the Modules 1.0 unit tests.

env = CommonJS::Environment.new(:path => '/path/to/lib/dir')
env.require('foo.js')

By default, all you get with a bare commonjs environment is the Modules API

The plan however, is to allow you to extend your commonjs environment to have whatever native interfaces you want in it. So for example, if you want to allow filesystem access, as well as access to the process information, you would say:

env.modules :filesystem, :process

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4