GithubHelp home page GithubHelp logo

etherpad-require-kernel's Introduction

require-kernel

This is an implementation of the CommonJS module standard for a browser environment.

Usage

The kernel is a code fragment that evaluates to an unnamed function.

Interface

Modules can be loaded either synchronously and asynchronously:

  • module = require(path)
  • require(path1[, path2[, ...]], function (module1[, module2[, ...]]) {})

The kernel has the following methods:

  • define: A method for defining modules. It may be invoked one of several ways. In either case the path is expected to be fully qualified and the module a function with the signature (require, exports, module).
    • require.define(path, module)
    • require.define({path1: module1[, path2: module2[, ...]]})
  • setGlobalKeyPath: A string (such as "require" and "namespace.req") that evaluates to the kernel in the global scope. Asynchronous retrieval of modules using JSONP will happen if and only if this path is defined. Default is undefined.
  • setRootURI: The URI that non-library paths will be requested relative to. Default is undefined.
  • setLibraryURI: The URI that library paths (i.e. paths that do not match /^\.{0,2}\//) will be requested relative to. Default is undefined.
  • setRequestMaximum: The maximum number of concurrent requests. Default is 2.

Behavior

JSONP

If a global key path was set for the kernel and the request is allowed to be asynchronous, a JSONP will be used to request the module. The callback parameter sent in the request is the define method of require (as specified by the global key path).

Cross Origin Resources

JSONP accomplishes CORS, so if such a request is possible to make, it is made, else, if the user agent is capable of such a request, requests to cross origin resources can be made, if not (IE[6,7]), the kernel will attempt to make a request to a mirrored location on the same origin (http://static.example.com/javascripts/index.js becomes http://www.example.com/javascripts/index.js).

License

Released to the public domain. In any regions where transfer the public domain is not possible the software is granted under the terms of the MIT License.

etherpad-require-kernel's People

Contributors

johnmclear avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.