Add Robot_JoyIt driver

This commit is contained in:
2026-01-17 16:50:07 +01:00
parent e9e50acf5f
commit 0cfb4d5a95
15848 changed files with 570836 additions and 268976 deletions

28
node_modules/jayson/lib/utils.js generated vendored
View File

@@ -1,6 +1,7 @@
'use strict';
const JSONStream = require('JSONStream');
const StreamValues = require('stream-json/streamers/StreamValues');
const Verifier = require('stream-json/utils/Verifier');
const JSONstringify = require('json-stringify-safe');
const uuid = require('uuid').v4;
@@ -64,19 +65,20 @@ Utils.merge = function(...args) {
};
/**
* Parses an incoming stream for requests using JSONStream
* Parses an incoming stream for requests using stream-json
* @param {Stream} stream
* @param {Object} options
* @param {Function} onRequest Called once for stream errors and an unlimited amount of times for valid requests
*/
Utils.parseStream = function(stream, options, onRequest) {
const onError = Utils.once(onRequest);
const onSuccess = (...args) => onRequest(null, ...args);
const result = JSONStream.parse();
const verifier = new Verifier({jsonStreaming: true});
const parser = StreamValues.withParser();
result.on('data', function(data) {
parser.on('data', function(obj) {
let data = obj.value;
// apply reviver walk function to prevent stringify/parse again
if(typeof options.reviver === 'function') {
@@ -86,11 +88,12 @@ Utils.parseStream = function(stream, options, onRequest) {
onSuccess(data);
});
result.on('error', onError);
parser.on('error', onError);
verifier.on('error', onError);
stream.on('error', onError);
stream.pipe(result);
stream.pipe(verifier);
stream.pipe(parser);
};
/**
@@ -182,7 +185,8 @@ Utils.parseBody = function(stream, options, callback) {
stream.on('end', function() {
utils.JSON.parse(data, options, function(err, request) {
if(err) {
return callback(err);
callback(err);
return;
}
callback(null, request);
});
@@ -322,7 +326,8 @@ Utils.JSON.parse = function(str, options, callback) {
try {
obj = JSON.parse.apply(JSON, [str, reviver].filter(v => v));
} catch(err) {
return callback(err);
callback(err);
return;
}
callback(null, obj);
@@ -346,7 +351,8 @@ Utils.JSON.stringify = function(obj, options, callback) {
try {
str = JSONstringify.apply(JSON, [obj, replacer].filter(v => v));
} catch(err) {
return callback(err);
callback(err);
return;
}
callback(null, str);