From c26852da77631509abdee83bd90a92ad00dd3760 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 13 Jun 2017 21:01:04 +0100 Subject: [PATCH] Add buffer support to split node --- nodes/core/locales/en-US/messages.json | 36 ++++ nodes/core/logic/17-split.html | 143 ++++++++++----- nodes/core/logic/17-split.js | 242 ++++++++++++++++++++----- 3 files changed, 332 insertions(+), 89 deletions(-) diff --git a/nodes/core/locales/en-US/messages.json b/nodes/core/locales/en-US/messages.json index c44cd287b..83509a020 100644 --- a/nodes/core/locales/en-US/messages.json +++ b/nodes/core/locales/en-US/messages.json @@ -785,5 +785,41 @@ "createfail": "failed to create file: __error__" }, "tip": "Tip: The filename should be an absolute path, otherwise it will be relative to the working directory of the Node-RED process." + }, + "split": { + "intro":"Split msg.payload based on type:", + "object":"Object", + "objectSend":"Send a message for each key/value pair", + "strBuff":"String / Buffer", + "array":"Array", + "splitUsing": "Split using", + "splitLength": "Fixed length of", + "stream":"Handle as a stream of messages" + }, + "join":{ + "mode":{ + "mode":"Mode", + "auto":"automatic", + "custom":"manual" + }, + "combine":"Combine each", + "create":"to create", + "type":{ + "string":"a String", + "array":"an Array", + "object":"a key/value Object", + "merged":"a merged Object" + }, + "using":"using", + "key":"as the key", + "joinedUsing":"joined using", + "send":"Send the message:", + "afterCount":"After a number of message parts", + "count":"count", + "subsequent":"and every subsequent message.", + "afterTimeout":"After a timeout following the first message", + "seconds":"seconds", + "complete":"After a message with the msg.complete property set", + "tip":"This mode assumes this node is either paired with a split node or the received messages will have a properly configured msg.parts property." } } diff --git a/nodes/core/logic/17-split.html b/nodes/core/logic/17-split.html index c6ef1561d..bb03b4439 100644 --- a/nodes/core/logic/17-split.html +++ b/nodes/core/logic/17-split.html @@ -15,13 +15,31 @@ --> @@ -53,7 +71,11 @@ color:"#E2D96E", defaults: { name: {value:""}, - splt: {value:"\\n"} + splt: {value:"\\n"}, + spltType: {value:"str"}, + arraySplt: {value:1}, + arraySpltType: {value:"len"}, + stream: {value: false} }, inputs:1, outputs:1, @@ -63,98 +85,127 @@ }, labelStyle: function() { return this.name?"node_label_italic":""; + }, + oneditprepare: function() { + $("#node-input-splt").typedInput({ + default: 'str', + typeField: $("#node-input-spltType"), + types:[ + 'str', + 'bin', + {value:"len", label:RED._("node-red:split.splitLength"),validate:/^\d+$/} + ] + }); + if (this.arraySplt === undefined) { + $("#node-input-arraySplt").val(1); + } + $("#node-input-arraySplt").typedInput({ + default: 'len', + typeField: $("#node-input-arraySpltType"), + types:[ + {value:"len", label:RED._("node-red:split.splitLength"),validate:/^\d+$/} + ] + }); } });