Comparing version 9.0.2 to 9.1.0
'use strict'; | ||
const typeTags = { | ||
s: 'string', | ||
f: 'float', | ||
i: 'integer', | ||
b: 'blob' | ||
}; | ||
class Argument { | ||
@@ -24,2 +31,3 @@ constructor(type, value) { | ||
} else if (arg.type) { | ||
if (typeTags[arg.type]) arg.type = typeTags[arg.type]; | ||
this.args.push(arg); | ||
@@ -26,0 +34,0 @@ } else { |
@@ -7,2 +7,6 @@ 'use strict'; | ||
function round(num) { | ||
return Math.round(num * 100) / 100; | ||
} | ||
tap.beforeEach(util.bootstrap); | ||
@@ -84,3 +88,3 @@ | ||
t.equal(msg[0], expected[0], `We reveived the payload: ${msg}`); | ||
t.equal(msg[1][0], expected[1][0], 'pie please'); | ||
t.equal(round(msg[1]), expected[1], 'pie please'); | ||
oscServer.close(); | ||
@@ -95,2 +99,35 @@ t.end(); | ||
tap.test('message: alias messages', (t) => { | ||
const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
const client = new nodeOsc.Client('127.0.0.1', t.context.port); | ||
const m = new nodeOsc.Message('/address'); | ||
m.append({ | ||
type: 'i', | ||
value: 123 | ||
}); | ||
m.append({ | ||
type: 'f', | ||
value: 3.14 | ||
}); | ||
oscServer.on('message', (msg) => { | ||
const expected = [ | ||
'/address', | ||
123, | ||
3.14 | ||
]; | ||
t.equal(msg[0], expected[0], `We reveived the payload: ${msg}`); | ||
t.equal(msg[1], expected[1], 'easy as abc'); | ||
t.ok(Number.isInteger(msg[1]), 'the first value is an int'); | ||
t.equal(round(msg[2]), expected[2], 'pie please'); | ||
t.ok(msg[2] % 1 !== 0, 'the second value is a float'); | ||
oscServer.close(); | ||
t.end(); | ||
}); | ||
client.send(m, () => { | ||
client.close(); | ||
}); | ||
}); | ||
tap.test('message: boolean', (t) => { | ||
@@ -145,3 +182,3 @@ const oscServer = new nodeOsc.Server(t.context.port, '127.0.0.1'); | ||
// const client = new osc.Client('127.0.0.1', 3333); | ||
// const m = new osc.Message('/address');z | ||
// const m = new osc.Message('/address'); | ||
// | ||
@@ -148,0 +185,0 @@ // oscServer.on('message', (msg) => { |
{ | ||
"name": "node-osc", | ||
"description": "pyOSC inspired library for sending and receiving OSC messages", | ||
"version": "9.0.2", | ||
"version": "9.1.0", | ||
"exports": { | ||
@@ -27,5 +27,5 @@ "require": "./dist/lib/index.js", | ||
"prepublishOnly": "npm run build", | ||
"lint": "eslint \"lib/**/*.mjs\" test/* examples/*", | ||
"lint": "eslint \"lib/**/*.mjs\" test/* examples/* rollup.config.mjs", | ||
"test": "npm run lint && npm run build && npm run test:esm && npm run test:cjs", | ||
"test:esm": "tap -j1 test/test-*.mjs", | ||
"test:esm": "tap -j1 test/test-*.mjs", | ||
"test:cjs": "tap -j1 dist/test/test-*.js" | ||
@@ -52,5 +52,5 @@ }, | ||
"get-port": "^6.1.2", | ||
"rollup": "^3.20.1", | ||
"rollup": "^4.9.5", | ||
"tap": "^18.4.2" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
57125
1529
38