turbo-stream
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -138,4 +138,26 @@ "use strict"; | ||
} | ||
default: | ||
throw new Error("Cannot encode function or unexpected type"); | ||
default: { | ||
const isArray = Array.isArray(input); | ||
let pluginHandled = false; | ||
if (!isArray && plugins) { | ||
for (const plugin of plugins) { | ||
const pluginResult = plugin(input); | ||
if (Array.isArray(pluginResult)) { | ||
pluginHandled = true; | ||
const [pluginIdentifier, ...rest] = pluginResult; | ||
str[index] = `[${JSON.stringify(pluginIdentifier)}`; | ||
if (rest.length > 0) { | ||
str[index] += `,${rest | ||
.map((v) => flatten.call(this, v)) | ||
.join(",")}`; | ||
} | ||
str[index] += "]"; | ||
break; | ||
} | ||
} | ||
} | ||
if (!pluginHandled) { | ||
throw new Error("Cannot encode function or unexpected type"); | ||
} | ||
} | ||
} | ||
@@ -142,0 +164,0 @@ } |
{ | ||
"name": "turbo-stream", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "A streaming data transport format that aims to support built-in features such as Promises, Dates, RegExps, Maps, Sets and more.", | ||
@@ -5,0 +5,0 @@ "files": [ |
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
44724
1143