RingoJS

Module Index

  • assert

    Assertion library for unit testing. It implements the CommonJS Unit Testing specification and adds some additional convenience methods. All methods allow an additional argument: comment. This comment will be appended to the error message if an assertion fails.

  • binary

    When dealing with network sockets or binary files, it’s necessary to read and write into byte streams. JavaScript itself does not provide a native representation of binary data, so this module provides two classes addressing this shortcoming. The implementation follows the CommonJS Binary/B proposal.

    ByteArray implements a modifiable and resizable byte buffer.

    ByteString implements an immutable byte sequence.

    Both classes share a common base class Binary. The base class can't be instantiated. It exists only to affirm that ByteString and ByteArray instances of Binary.

    When passed to a Java method that expects a byte[], instances of these classes are automatically unwrapped.

  • console

    This module provides functions to write on the standard output stream stdout and error stream stderr for error logging and quick debugging. It’s similar to the console object implemented in most web browsers.

  • fs

    This module provides a file system API for the manipulation of paths, directories, files, links, and the construction of input and output streams. It follows the CommonJS Filesystem/A proposal.

  • globals

    RingoJS adopts some of the global properties from the Rhino shell and adds a few of its own.

    Note that this module must and can not be imported like an ordinary module. It is evaluated only once upon RingoJS startup.

  • io

    This module provides functions for reading and writing streams of raw bytes. It implements the Stream and TextStream classes as per the CommonJS IO/A proposal.

    Streams are closely related with two other modules. Low-level byte manipulation is provided by the binary module and uses the ByteArray or ByteString class. The fs module returns io streams for reading and writing files.

  • net

    This module provides support for networking using TCP and UDP sockets. A socket represents a connection between a client and a server program over a network. The underlying native binding is provided by the java.net package.

  • system

    This module provides an implementation of the system module compliant to the CommonJS System/1.0 specification. Beyond the standard a print() function is provided.

  • test

    A test runner compliant to the CommonJS Unit Testing specification. It manages the execution of unit tests and processes test results. The runner reports the total number of failures as exit status code.

    The runner treats a module like a test case. A test case defines the fixture to run multiple tests. Test cases can provide optional setUp() and tearDown() functions to initialize and destroy the fixture. The test runner will run these methods prior to / after each test. Test functions must start with a test prefix in their name, otherwise they are skipped by the runner.

    The following example test case testDatabase.js starts a new test runner if executed with ringo testDatabase.js

  • ringo/args

    A parser for command line options. This parser supports various option formats:

    • -a -b -c (multiple short options)
    • -abc (multiple short options combined into one)
    • -a value (short option with value)
    • -avalue (alternative short option with value)
    • --option value (long option with value)
    • --option=value (alternative long option with value)
  • ringo/base64

    Base64 encoding and decoding for binary data and strings.

  • ringo/buffer

    A simple text Buffer class for composing strings.

  • ringo/concurrent

    Utilities for working with multiple concurrently running threads.

  • ringo/daemon

    The daemon control script invoked by the init script.

    This module interprets the first command line argument as module ID, load the module and try to invoke the life cycle functions on it.

    For HTTP servers it is generally more convenient to directly use ringo/httpserver which will create a new server instance and pass it to as argument to the application life cycle functions.

  • ringo/encoding

    Low-level support for character encoding and decoding. It uses the packages java.nio and java.nio.charset for the underlying operations.

  • ringo/engine

    Provides access to the Rhino JavaScript engine.

  • ringo/events

    Exports an EventEmitter classes that provide methods to emit events and register event listener functions.

  • ringo/httpclient

    A module for sending HTTP requests and receiving HTTP responses.

  • ringo/logging

    This module provides generic logging support for Ringo applications. It uses SLF4J or Apache log4j if either is detected in the classpath, and will fall back to java.util.logging otherwise.

    If the first argument passed to any of the logging methods is a string containing any number of curly bracket pairs ({}), the logger will interpret it as format string and use any following arguments to replace the curly bracket pairs. If an argument is an Error or Java Exception object, the logger will render a stack trace for it and append it to the log message.

    This module's exports object implements the EventEmitter interface and emits logged messages using the log level name as event type.

  • ringo/mime

    This module provides functionality for determining the MIME type for a given file extension.

  • ringo/profiler

    A profiler for measuring execution time of JavaScript functions. Note that you need to run with optimization level -1 for profiling to work. Running the profiler on optimized code will produce no data.

  • ringo/promise

    Allows to work with deferred values that will be resolved in the future.

  • ringo/shell

    Provides functions to deal with the Ringo shell / REPL. It allows to start a new Ringo shell programmatically. This module is internally used by every Ringo REPL to interact with the user. The example shows a simple Ringo shell script which prepares an object and opens a shell for live interaction.

  • ringo/subprocess

    A module for spawning processes, connecting to their input/output/errput and returning their response codes. It uses the current JVM's runtime provided by java.lang.Runtime.getRuntime(). The exact behavior of this module is highly system-dependent.

  • ringo/term

    A module for printing ANSI terminal escape sequences. This module provides a number of useful color and style constants, and a replacement for the print function optimized for styled output.

  • ringo/worker

    A Worker API based on the W3C Web Workers. Ringo offers "shared-nothing" workers for parallel execution and abstract JVM threads. A worker has its own private set of modules and an isolated scope, tied together in a single JVM thread. Each worker gets its own single-threaded event loop that behaves just like the event loop in a browser or in Node. Communication between workers uses the postMessage() method and the onmessage event handler. To improve performance Ringo keeps free workers in a queue and only allocates a new one if all existing workers are busy. Workers help to keep multi-threaded JavaScript free from any common threading pitfalls, like synchronization or locking.

  • ringo/zip

    This module provides classes to uncompress zip files and streams.

  • ringo/httpserver/builder

    A module for configuring an http(s) server

  • ringo/httpserver/eventsource

  • ringo/httpserver/httpserver

    A module containing the HttpServer constructor and its more lowlevel methods

  • ringo/httpserver/index

    A module containing build and daemon lifecycle methods for http server

  • ringo/httpserver/utils

  • ringo/httpserver/websocket

  • ringo/jsgi/connector

    Low-level JSGI adapter implementation.

  • ringo/jsgi/eventsource

    This module provides the constructor for EventSource response objects, which allow pushing messages to connected clients.

  • ringo/jsgi/response

    This module provides response helper functions for composing JSGI response objects. For more flexibility the JsgiResponse is chainable.

  • ringo/utils/arrays

    Provides utility functions for working with JavaScript Arrays.

  • ringo/utils/dates

    Adds useful functions for working with JavaScript Date objects.

  • ringo/utils/files

    A collection of file related utilities not covered by the CommonJS standard fs module.

  • ringo/utils/http

    Provides utility functions to work with HTTP requests and responses. Most methods are useful for low-level operations only. To develop a full-featured web application it’s recommended to use a dedicated web framework like stick.

  • ringo/utils/numbers

    Provides utility functions for working with JavaScript numbers.

  • ringo/utils/objects

    Adds utility functions for working with JavaScript Objects

  • ringo/utils/strings

    Adds useful methods to the JavaScript String type.

  • ringo/utils/test

  • ringo/httpserver/context/application

  • ringo/httpserver/context/context

  • ringo/httpserver/context/static