Skip to content
timcameronryan edited this page Jul 20, 2012 · 10 revisions

js.io, a module system for the client and browser

js.io is a package management and module system for JavaScript. js.io modules can be evaluated in a JavaScript runtime (e.g. node.js) or precompiled into a single package for use on the client side.

js.io provides the following:

  • A module system.
  • Dependency graph that works in the client and the browser.
  • Support and networking libraries that can be used on either platform.

Usage

js.io can be invoked as a compiler or a runtime.

To compile a js.io module, invoke from the command line:

jsio_compile module.path

Module system

import statements

Imports are preprocessed when the script is first compiled. Imports are located at the top of your scripts.

import path.module
import .relative.module

__imports__.js

Gets evaluated at compilation time to determine what classes to include.

exports.classes = { ... };

exports.resolve = function () { ... };

Packages

(top-level)

base

index

jsio

logging

net

lib

Callback

Enum

Hash

Iterator

LogClass

PubSub

Sortable

sort

net

buffer

env

errors

interfaces

later

net.protocols

buffered

Cuppa

delimited

echo

mspp

rtjp

stomp

net.scp

client

transports

std

JSON

XML

js

base64

uri

utf8

uuid

string

pad

timeAgo

util

Animation

ajax

browser

util.browser.$

  • $(string selector[, window]) — Selects an array of objects that match the given selector.

  • $(HTMLElement element) — Alias for $.remove(element).

  • $(object spec) — Alias for $.create(spec).

  • $(window window) — Alias for $.size(window).

  • $.id(string id[, window]) — Returns an element matching the given id.

  • $.id(HTMLElement element) — Identity function. Useful for accepting an id or element as an argument.

  • $.apply(HTMLElement element, object spec) — From the spec object, the following options can be applied:

    • id
    • style
    • src
    • class/className
    • parent/parentNode, and optionally first, before, after for its position
    • html
    • text
    • children
    • first
  • $.isElement(object element) — Returns true if the given object is an element.

  • $.insertBefore(HTMLElement parentNode, HTMLElement element[, HTMLElement nextSibling]) — Inserts an element, before an optional element.

  • $.insertAfter(HTMLElement parentNode, HTMLElement element[, HTMLElement previousSibling]) — Inserts an element, after an optional element.

  • $.create(object spec) — Creates an element of the tag name tag, then calls $.apply() on the element with the given spec.

  • $.show(HTMLElement element[, string display = "block"]) — Unhides an element, setting its display style to the optional display property.

  • $.hide(HTMLElement element) — Hides an element by setting its display property to none.

  • $.addClass(HTMLElement, (array classNames|string classNames)) — Sets a class or classes on an element.

  • $.getTag(HTMLElement ancestor, string tagName) — Gets all elements with the given tagName which descend from the ancestor.

  • $.removeClass(HTMLElement element, (array classNames|string classNames)) — Removes the classNames from the element.

  • $.style(HTMLElement element, object css) — Sets the style of the element according to the given css object.

  • $.onEvent(HTMLElement element, string name, function callback) — Attaches an event listener to the element for the given event. The this property of the callback will be assigned to the global context.

  • $.removeEvent(HTMLElement element, string name, function callback) — Removes an event listener from an element.

  • $.stopEvent(Event event) — Stops an event object from propagating or performing the default action in the document.

  • $.setText(HTMLElement element, string text) — Sets the text of the given element.

  • $.setValue(HTMLElement element, string value) — Sets the value of the given element or the first child of the element.

  • $.remove(HTMLElement element) — Removes the element from its parent node.

  • $.cursorPos(ClickEvent event, HTMLElement element) — Returns the cursor position relative to the origin coordinate of the page for the given click event.

  • $.pos(HTMLElement element) — Returns the offset of the element from the origin coordinate of the page.

  • $.size(HTMLElement element) — Returns an object with the dimensions of the element.

  • $.size(Window window) — Returns an object with the dimensions and position of the window relative to the document origin.

  • $.insertCSSFile(string url) — Inserts a new stylesheet to the page with the given URL.

browserdetect

formatNumber

jslint

jsonSchema

optparse

path

setProperty

sizzle

sprintf

syntax

underscore

wordWrap

License

MIT licensed.

Clone this wiki locally