Comparing version 5.0.0-beta.1 to 5.0.0
@@ -266,6 +266,9 @@ 'use strict'; | ||
let message = args[0]; | ||
let callback = () => {}; | ||
let callback; | ||
if (typeof args[args.length - 1] === 'function') { | ||
callback = args.pop(); | ||
} | ||
else { | ||
callback = () => {}; | ||
} | ||
@@ -281,18 +284,26 @@ if (message instanceof Array) { | ||
let buf; | ||
switch (typeof message) { | ||
case 'object': | ||
buf = toBuffer(message); | ||
this._sock.send(buf, 0, buf.length, this.port, this.host, callback); | ||
break; | ||
case 'string': | ||
mes = new Message(args[0]); | ||
for (let i = 1; i < args.length; i++) { | ||
mes.append(args[i]); | ||
} | ||
buf = toBuffer(mes); | ||
this._sock.send(buf, 0, buf.length, this.port, this.host, callback); | ||
break; | ||
default: | ||
throw new Error('That Message Just Doesn\'t Seem Right'); | ||
try { | ||
switch (typeof message) { | ||
case 'object': | ||
buf = toBuffer(message); | ||
this._sock.send(buf, 0, buf.length, this.port, this.host, callback); | ||
break; | ||
case 'string': | ||
mes = new Message(args[0]); | ||
for (let i = 1; i < args.length; i++) { | ||
mes.append(args[i]); | ||
} | ||
buf = toBuffer(mes); | ||
this._sock.send(buf, 0, buf.length, this.port, this.host, callback); | ||
break; | ||
default: | ||
throw new TypeError('That Message Just Doesn\'t Seem Right'); | ||
} | ||
} | ||
catch (e) { | ||
if (e.code !== 'ERR_SOCKET_DGRAM_NOT_RUNNING') throw e; | ||
const error = new ReferenceError('Cannot send message on closed socket.'); | ||
error.code = e.code; | ||
callback(error); | ||
} | ||
} | ||
@@ -299,0 +310,0 @@ } |
{ | ||
"name": "node-osc", | ||
"description": "pyOSC inspired library", | ||
"version": "5.0.0-beta.1", | ||
"version": "5.0.0", | ||
"main": "./dist/bundle.js", | ||
@@ -15,3 +15,3 @@ "exports": { | ||
"engines": { | ||
"node": ">=12" | ||
"node": ">=10" | ||
}, | ||
@@ -22,4 +22,5 @@ "license": "LGPL-2.1", | ||
"prepublishOnly": "npm run build", | ||
"test": "npm run lint && npm run build && npm run tap", | ||
"tap": "c8 tap --no-coverage --no-esm --node-arg=--experimental-modules test/test-*{.js,.mjs}", | ||
"test-legacy": "npm run lint && npm run build && npm run tap -- test/test-*.js", | ||
"test": "npm run lint && npm run build && npm run tap -- test/test-*{.js,.mjs}", | ||
"tap": "c8 tap --no-coverage --no-esm --node-arg=--experimental-modules", | ||
"lint": "eslint lib/* test/* examples/*" | ||
@@ -47,5 +48,6 @@ }, | ||
"eslint": "^6.0.1", | ||
"rollup": "^1.27.9", | ||
"tap": "^14.6.1" | ||
"get-port": "^5.1.1", | ||
"tap": "^14.10.7", | ||
"rollup": "^1.27.9" | ||
} | ||
} |
# node-osc | ||
A very basic OSC client (so far) implementation based heavily on [pyOSC](https://trac.v2.nl/wiki/pyOSC). | ||
A very basic [Open Sound Control](http://opensoundcontrol.org/introduction-osc) client. Heavily inspired by [pyOSC](https://trac.v2.nl/wiki/pyOSC). | ||
@@ -5,0 +5,0 @@ Install using npm |
'use strict'; | ||
const test = require('tap').test; | ||
const t = require('tap'); | ||
const test = t.test; | ||
const generatePort = require('./generate-port'); | ||
const getPort = require('get-port'); | ||
const osc = require('node-osc'); | ||
const osc = require('../'); | ||
t.beforeEach(async (done, t) => { | ||
t.context.port = await getPort({ | ||
port: getPort.makeRange(3000, 3100) | ||
}); | ||
}); | ||
test('osc: argument message no callback', (t) => { | ||
const port = generatePort(); | ||
const oscServer = new osc.Server(port, '0.0.0.0'); | ||
const client = new osc.Client('0.0.0.0', port); | ||
const oscServer = new osc.Server(t.context.port, '127.0.0.1'); | ||
const client = new osc.Client('127.0.0.1', t.context.port); | ||
@@ -26,5 +32,4 @@ t.plan(1); | ||
test('osc: client with callback and message as arguments', (t) => { | ||
const port = generatePort(); | ||
const oscServer = new osc.Server(port, '0.0.0.0'); | ||
const client = new osc.Client('0.0.0.0', port); | ||
const oscServer = new osc.Server(t.context.port, '127.0.0.1'); | ||
const client = new osc.Client('127.0.0.1', t.context.port); | ||
@@ -31,0 +36,0 @@ t.plan(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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
59758
1113
1
5