qmetrics.net

Serialize JavaScript

JavaScript serialization beyond JSON with safe HTML embedding

An npm package that serializes JavaScript values—including functions, regexps, dates, sets, and maps—to literal JS strings safe for script tags when defaults are used.

Overview

Serialize JavaScript turns in-memory JavaScript data into a string of literal JavaScript, extending what JSON.stringify supports. It handles regular expressions, Date objects, functions, ES6 Sets and Maps, and related types teams often need when sharing state between server and browser.

The output can be saved as a .js file or placed inside an HTML script element. By default, HTML-sensitive characters and JavaScript line terminators are escaped to reduce cross-site scripting risk when embedding serialized data inline.

The serialize function accepts options for indentation spacing, a faster path when content is pure JSON, unsafe straight conversion without escaping, and ignoring functions like JSON.stringify. Deserialization is left to callers, typically by evaluating the parenthesized string in a controlled context.

The package originated from express-state internals and is distributed on npm for Node and bundler workflows. Documentation warns that serialized functions must be self-contained and are not a general way to pass arbitrary code to worker threads.

Key features

  • Serialize functions and regexps
  • Dates, Sets, and Maps support
  • Automatic HTML and line escaping
  • Optional pure-JSON fast path
  • Configurable unsafe and ignoreFunction
  • Literal JS string output
  • npm installable package

Use cases

  • Server-to-client state hydration
  • Embedding routing regexps in HTML
  • Isomorphic app configuration strings
  • Safe inline script data

Tags

Similar software

JS Cookie

Lightweight client-side JavaScript cookie API

A small JavaScript library for reading, writing, and removing browser cookies with broad browser support and no runtime dependencies.

★ 22.6k⟳ 1 month agoMIT
Frameworks & PlatformsDesktop/CLI app

REA

MCP and CLI reverse-engineering toolkit for agents

REA connects coding agents and terminals to local analysis tools for binaries, Electron apps, websites, .NET, and Android targets. Setup registers MCP access and investigation skills via npm.

★ 480.8k⟳ todayMIT

ECC

Open-source agent engineering toolkit for coding harnesses

ECC adds planning, verification, review, memory, skills, and security scanning to coding agents such as Claude Code, Codex, and Cursor. It installs as plugins, packages, and managed adapters across multiple harnesses.

★ 311.7k⟳ 8 days agoMIT
Frameworks & PlatformsDesktop/CLI app

React

JavaScript library for web and native user interfaces

React helps developers build interfaces from reusable components that manage their own state. Views update declaratively when underlying data changes.

★ 253k⟳ 2 days agoMIT
Frameworks & PlatformsDesktop/CLI app

Flutter

Open-source UI framework for multi-platform apps from one codebase

Flutter is an SDK for building user experiences for mobile, web, and desktop from a single codebase. It uses the Dart language and compiles to native machine code or web targets.

★ 181.5k⟳ todayBSD-3-Clause
Open Source Alternative to:Ionic Enterprise

Bootstrap

Responsive HTML, CSS, and JavaScript front-end toolkit

Bootstrap supplies CSS, JavaScript, and Sass-based styles for building responsive, mobile-first sites. It ships prebuilt grid layouts, UI components, and optional JavaScript plugins.

★ 175.1k⟳ 2 days agoMIT