GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fory/javascript at main · apache/fory

Expand file tree

/

javascript

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
/

javascript

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
benchmark
benchmark
 
 
packages
packages
 
 
test
test
 
 
.eslintrc.cjs
.eslintrc.cjs
 
 
.gitignore
.gitignore
 
 
.npmrc
.npmrc
 
 
.prettierignore
.prettierignore
 
 
.prettierrc
.prettierrc
 
 
README.md
README.md
 
 
jest.config.js
jest.config.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

README.md

Outline

Apache Fory™ JavaScript

npm License

JavaScript / TypeScript implementation of the Apache Fory™ cross-language serialization protocol. Serialize JavaScript objects to bytes and deserialize them back — including across services written in Java, Python, Go, Rust, C++, and other Fory-supported languages.

Key Features

  • Cross-language — serialize in JavaScript, deserialize in Java, Python, Go, Rust, C++, and more without writing glue code
  • Fast — serializer code is generated and cached at registration time; optimized for V8 JIT
  • Reference-aware — shared references and circular object graphs are supported
  • Schema-driven — field types, nullability, and polymorphism are declared once with Type.* builders
  • Schema evolution — optional forward/backward compatibility for independent service deployments
  • Modern types — bigint, typed arrays, Map, Set, Date, float16, bfloat16 supported

Packages

Package Description
@apache-fory/core Main Fory runtime for JavaScript/TypeScript
@apache-fory/hps Optional Node.js high-performance suite (Node.js 20+)

Installation

npm install @apache-fory/core

For optional Node.js string-detection acceleration:

npm install @apache-fory/hps

@apache-fory/hps uses V8's fast-call API to detect string encoding efficiently. It requires Node.js 20+ and is completely optional — if installation fails or your environment does not support it, @apache-fory/core works perfectly on its own.

Quick Start

import Fory, { Type } from "@apache-fory/core";

// Optional: import hps for Node.js string performance boost
// import hps from "@apache-fory/hps";

const userType = Type.struct(
  { typeName: "example.user" },
  {
    id: Type.int64(),
    name: Type.string(),
    age: Type.int32(),
  },
);

const fory = new Fory();
// With hps: const fory = new Fory({ hps });
const { serialize, deserialize } = fory.register(userType);

const bytes = serialize({ id: 1n, name: "Alice", age: 30 });
const user = deserialize(bytes);
console.log(user);
// { id: 1n, name: 'Alice', age: 30 }

Supported Types

JavaScript Value Fory Schema Notes
boolean Type.bool()
number Type.int8() / int16() / int32() / float32() / float64() Pick the width matching the peer language
bigint Type.int64() / uint64() Use for 64-bit integers
string Type.string()
Uint8Array Type.binary() Binary blob
Date Type.timestamp() / Type.date()
Array Type.list(Type.T()) Ordered collection
Map Type.map(Type.K(), Type.V())
Set Type.set(Type.T())
Typed arrays Type.int32Array() / Type.float64Array() / ... Dense numeric or bool arrays

Cross-Language Serialization

Fory JavaScript serializes to the same binary format as the Java, Python, Go, Rust, C++, and Swift runtimes. A message written in JavaScript can be read in any other supported language without any conversion layer.

// JavaScript side
const messageType = Type.struct(
  { typeName: "example.message" },
  {
    id: Type.int64(),
    content: Type.string(),
  },
);

const fory = new Fory();
const { serialize } = fory.register(messageType);
const bytes = serialize({ id: 1n, content: "hello from JavaScript" });
// Send bytes to a Java/Python/Go/Rust service

Register the same example.message type on the other side using the peer runtime's API.

Schema Evolution

Compatible mode is enabled by default for independent service deployments:

const fory = new Fory();

Readers can skip unknown fields and tolerate missing ones, supporting rolling upgrades and schema changes across services.

Documentation

Full documentation is available at fory.apache.org:

  • JavaScript Serialization Guide
  • Basic Serialization
  • Supported Types
  • Schema Evolution
  • Xlang Serialization Spec

License

Apache License 2.0 — see LICENSE for details.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.