Skip to content

my-trash-bin/250724

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ftson

Fast JSON powered by TypeScript

Usage

1. Configure ftson.config.ts

import { schema } from "ftson";
import { ArbitraryType } from "./src/types/ArbitraryType";

export const stringify = {
  "./src/generated/1.ts": {
    stringify1: schema<ArbitraryType>(/* global config */)({
      // config for the type
      keyOrder: ["b", "a"],
      // config for a nested type
      fields: { b: { fields: { c: { keyOrder: ["d", "e"] } } } },
    }),
  },
};

2. Run ftson

npx ftson

A file like the one below will be generated at ./src/generated/1.ts:

import { ArbitraryType } from "../types/ArbitraryType";

export function stringify1(input: ArbitraryType): string {
  return `{"b":${/* ... fast stringify function */},"a":${input.a}}`;
}

3. Use the generated function

It may require runtime dependencies such as @ftson/escape.

As you may have noticed, the heavy stringify function generator is not needed at runtime!

Status

Work in Progress, incomplete.

About

gunshi test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published