Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turbo-stream

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turbo-stream - npm Package Compare versions

Comparing version 2.3.0 to 2.4.0

39

dist/flatten.js

@@ -29,3 +29,3 @@ "use strict";

function stringify(input, index) {
const { deferred, plugins } = this;
const { deferred, plugins, postPlugins } = this;
const str = this.stringified;

@@ -38,2 +38,3 @@ const stack = [[input, index]];

.join(",");
let error = null;
switch (typeof input) {

@@ -50,5 +51,8 @@ case "boolean":

const keyFor = Symbol.keyFor(input);
if (!keyFor)
throw new Error("Cannot encode symbol unless created with Symbol.for()");
str[index] = `["${utils_js_1.TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
if (!keyFor) {
error = new Error("Cannot encode symbol unless created with Symbol.for()");
}
else {
str[index] = `["${utils_js_1.TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
}
break;

@@ -139,3 +143,3 @@ }

else {
throw new Error("Cannot encode object with prototype");
error = new Error("Cannot encode object with prototype");
}

@@ -166,6 +170,29 @@ }

if (!pluginHandled) {
throw new Error("Cannot encode function or unexpected type");
error = new Error("Cannot encode function or unexpected type");
}
}
}
if (error) {
let pluginHandled = false;
if (postPlugins) {
for (const plugin of postPlugins) {
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 error;
}
}
}

@@ -172,0 +199,0 @@ }

@@ -11,3 +11,4 @@ import { type DecodePlugin, type EncodePlugin } from "./utils.js";

plugins?: EncodePlugin[];
postPlugins?: EncodePlugin[];
signal?: AbortSignal;
}): ReadableStream<Uint8Array>;

3

dist/turbo-stream.js

@@ -110,3 +110,3 @@ "use strict";

function encode(input, options) {
const { plugins, signal } = options ?? {};
const { plugins, postPlugins, signal } = options ?? {};
const encoder = {

@@ -118,2 +118,3 @@ deferred: {},

plugins,
postPlugins,
signal,

@@ -120,0 +121,0 @@ };

@@ -35,2 +35,3 @@ export declare const HOLE = -1;

plugins?: EncodePlugin[];
postPlugins?: EncodePlugin[];
signal?: AbortSignal;

@@ -37,0 +38,0 @@ }

{
"name": "turbo-stream",
"version": "2.3.0",
"version": "2.4.0",
"description": "A streaming data transport format that aims to support built-in features such as Promises, Dates, RegExps, Maps, Sets and more.",

@@ -21,3 +21,3 @@ "files": [

"scripts": {
"build": "pnpm build:esm && pnpm build:cjs",
"build": "pnpm build:esm && pnpm build:cjs && cp ./dist/turbo-stream.mjs ./viewer/scripts/turbo-stream.js",
"build:cjs": "tsc --outDir dist --project tsconfig.lib.json",

@@ -24,0 +24,0 @@ "build:esm": "esbuild --bundle --platform=node --target=node16 --format=esm --outfile=dist/turbo-stream.mjs src/turbo-stream.ts",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc