Skip to content

Commit

Permalink
Updated examples and documentation for new coffee-script 1.3 complian…
Browse files Browse the repository at this point in the history
…t API.
  • Loading branch information
russellmcc committed Apr 20, 2012
1 parent b86f5ca commit 65ac6eb
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 104 deletions.
2 changes: 1 addition & 1 deletion examples/osc-float-to-int.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ else
outport = 41235

float_to_int = (message) ->
for arg in message.arguments
for arg in message.args
if arg.type is "float"
arg.type = "integer"
message
Expand Down
10 changes: 5 additions & 5 deletions examples/oscbundle_heartbeat.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ sendHeartbeat = () ->
elements : [
{
address : "/p1"
arguments : new Buffer "beat"
args : new Buffer "beat"
}
{
address : "/p2"
arguments : "string"
args : "string"
}
{
timetag: 34567
elements : [
{
address : "/p3"
arguments : 12
args : 12
}
]
}
]
)

udp.send buf, 0, buf.length, outport, "localhost"

setInterval sendHeartbeat, 2000

console.log "sending heartbeat messages to http://localhost:" + outport
10 changes: 5 additions & 5 deletions examples/oscheartbeat.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This example simply sends a message with several parameter types
# This example simply sends a message with several parameter types
# every two seconds to port 41234

osc = require 'osc-min'
Expand All @@ -13,18 +13,18 @@ else
console.log "sending heartbeat messages to http://localhost:" + outport

#~verbatim:examples[1]~
#### Send a bunch of arguments every two seconds
#### Send a bunch of args every two seconds
sendHeartbeat = () ->
buf = osc.toBuffer(
address : "/heartbeat"
arguments : [
args : [
12
"sttttring"
new Buffer "beat"
{type : "integer", value : 7}
]
)

udp.send buf, 0, buf.length, outport, "localhost"

setInterval sendHeartbeat, 2000
12 changes: 6 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@
// {
// oscType : "message"
// address : "/address/pattern/might/have/wildcards"
// arguments : [arg1,arg2]
// args : [arg1,arg2]
// }
//
// Where arguments is an array of _OSC Arguments_. `oscType` is optional.
// `arguments` can be a single element.
// Where args is an array of _OSC Arguments_. `oscType` is optional.
// `args` can be a single element.
//
// + An _OSC Argument_ is represented as a javascript object with the following layout:
//
Expand Down Expand Up @@ -110,12 +110,12 @@
// a node.js Buffer, or throws if the representation is ill-formed.
//
//----
//### .toBuffer(address, arguments[], [strict])
//### .toBuffer(address, args[], [strict])
// alternative syntax for above. Assumes this is an _OSC Message_ as defined below,
// and `arguments` is an array of _OSC Arguments_ or single _OSC Argument_
// and `args` is an array of _OSC Arguments_ or single _OSC Argument_
exports.toBuffer = function(object, strict, opt) {
if(typeof object === "string")
return utils.toOscPacket({'address' : object, 'arguments' : strict}, opt);
return utils.toOscPacket({'address' : object, 'args' : strict}, opt);
return utils.toOscPacket(object, strict);
};

Expand Down
6 changes: 3 additions & 3 deletions lib/osc-utilities.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ exports.fromOscMessage = (buffer, strict) ->
# implementations that send message without a type string are fixed.
# this will never happen, so we should accept this, even in
# strict mode.
return {address : address, arguments : []} if not buffer.length
return {address : address, args : []} if not buffer.length

# if there's more data but no type string, we can't parse the arguments.
{string : types, rest : buffer} = exports.splitOscString buffer, strict
Expand All @@ -312,7 +312,7 @@ exports.fromOscMessage = (buffer, strict) ->
# parse the arguments.
if types[0] isnt ','
throw StrictError 'Argument lists must begin with ,' if strict
return {address : address, arguments : []}
return {address : address, args : []}

# we don't need the comma anymore
types = types[1..(types.length)]
Expand All @@ -335,7 +335,7 @@ exports.fromOscMessage = (buffer, strict) ->
value : arg?.value
)

{address : address, arguments : args, oscType : "message"}
{address : address, args : args, oscType : "message"}

#
# Try to parse an OSC bundle into a javascript object.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "osc-min",
"version": "0.0.5",
"version": "0.0.6",
"main": "lib/index",
"author": {
"name" : "Russell McClellan",
Expand Down
18 changes: 9 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ sock = udp.createSocket "udp4", (msg, rinfo) ->
sock.bind inport

```
### Send a bunch of arguments every two seconds
### Send a bunch of args every two seconds
```coffee-script
sendHeartbeat = () ->
buf = osc.toBuffer(
address : "/heartbeat"
arguments : [
args : [
12
"sttttring"
new Buffer "beat"
{type : "integer", value : 7}
]
)

udp.send buf, 0, buf.length, outport, "localhost"

setInterval sendHeartbeat, 2000
```
### A simple OSC redirecter
Expand Down Expand Up @@ -101,9 +101,9 @@ takes a _OSC packet_ javascript representation as defined below and returns
a node.js Buffer, or throws if the representation is ill-formed.

----
### .toBuffer(address, arguments[], [strict])
### .toBuffer(address, args[], [strict])
alternative syntax for above. Assumes this is an _OSC Message_ as defined below,
and `arguments` is an array of _OSC Arguments_ or single _OSC Argument_
and `args` is an array of _OSC Arguments_ or single _OSC Argument_

----
### .applyAddressTransform(buffer, transform)
Expand Down Expand Up @@ -148,11 +148,11 @@ See the [spec][spec] for more information on the OSC types.
{
oscType : "message"
address : "/address/pattern/might/have/wildcards"
arguments : [arg1,arg2]
args : [arg1,arg2]
}

Where arguments is an array of _OSC Arguments_. `oscType` is optional.
`arguments` can be a single element.
Where args is an array of _OSC Arguments_. `oscType` is optional.
`args` can be a single element.

+ An _OSC Argument_ is represented as a javascript object with the following layout:

Expand Down
Loading

0 comments on commit 65ac6eb

Please sign in to comment.