### Question:
ScriptPayloadParserBuilder implements PayloadParserBuilderStrategy { @Override @SneakyThrows public PayloadParser build(ValueObject config) { String script = config.getString("script") .orElseThrow(() -> new IllegalArgumentException("script不能为空")); String lang = config.getString("lang") .orElseThrow(() -> new IllegalArgumentException("lang不能为空")); DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(lang); if (engine == null) { throw new IllegalArgumentException("不支持的脚本:" + lang); } PipePayloadParser parser = new PipePayloadParser(); String id = DigestUtils.md5Hex(script); if (!engine.compiled(id)) { engine.compile(id, script); } Map<String, Object> ctx = new HashMap<>(); ctx.put("parser", parser); engine.execute(id, ctx).getIfSuccess(); return parser; }  @Override PayloadParserType getType(); @Override @SneakyThrows PayloadParser build(ValueObject config);  }### Answer:
@Test void testSplicingUnpack() { ScriptPayloadParserBuilder builder = new ScriptPayloadParserBuilder(); Map<String, Object> config = new HashMap<>(); config.put("script", "\n" + "var BytesUtils = org.jetlinks.community.network.utils.BytesUtils;\n" + "parser.fixed(4)\n" + " .handler(function(buffer){\n" + " var len = BytesUtils.highBytesToInt(buffer.getBytes());\n" + " parser.fixed(len);\n" + " })\n" + " .handler(function(buffer){\n" + " parser.result(buffer.toString(\"UTF-8\"))\n" + " .complete();\n" + " });"); config.put("lang", "javascript"); PayloadParser parser = builder.build(ValueObject.of(config)); parser.handlePayload() .doOnSubscribe(sb -> { Mono.delay(Duration.ofMillis(100)) .subscribe(r -> { Buffer buffer = Buffer.buffer(BytesUtils.toHighBytes(5)); buffer.appendString("1234"); parser.handle(buffer); parser.handle(Buffer.buffer("5")); parser.handle(Buffer.buffer(new byte[]{5, 0})); parser.handle(Buffer.buffer(new byte[]{0, 0}).appendString("12")); parser.handle(Buffer.buffer("345")); }); }) .take(2) .map(bf -> bf.toString(StandardCharsets.UTF_8)) .as(StepVerifier::create) .expectNext("12345", "12345") .verifyComplete(); }