0.1.0 • Published 9 years ago

oz-msg v0.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

oz-msg

Build Status

oz's message components

install

browser

$ bower install oz-msg

node.js

$ npm install oz-msg

usage

browser

For bundling systems supporting commonjs, require('oz-msg').

The library is also accessible via one of the build/ files:

  • oz-msg.js: oz-msg without its dependencies
  • oz-msg.all.js: oz-msg with its dependencies bundled
  • oz-msg.min.js: minified build of oz-msg
  • oz-msg.all.js: minified build of oz-msg with its dependencies bundled

If no module system is found, the oz-msg is exposed as the global ozmsg.

nodejs

require('oz-msg')

api

ozmsg.req(type, data)

Creates a request of the given type and data, where type is a string and data is any JSON-serializable object.

The returned request object contains the following properties:

id: the request's uuid type: the given type data: the given data

ozmsg.rep(req, data)

Creates a success reply to the given request req and with the given data, where req is an ozmsg.req object and data is any JSON-serializable object.

The returned reply object contains the following properties:

id: the reply's uuid req: the corresponding request req err: set to null data: the given data

ozmsg.err(req, err)

Creates an error reply to the given request req and with the given error err, where req is ozmsg.req object and err is any JSON-serializable object.

The returned reply object contains the following properties:

id: the reply's uuid req: the corresponding request req data: set to null err: the given error err