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 — GitHub - samthor/tiny-stable-stringify: Sorted version of JSON.stringify

BranchesTags
Open more actions menu

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
.vscode
.vscode
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
.prettierrc.json
.prettierrc.json
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 
pnpm-lock.yaml
pnpm-lock.yaml
 
 
tsconfig.json
tsconfig.json
 
 
types.d.ts
types.d.ts
 
 

Repository files navigation

Sorted version of JSON.stringify() so you can get a consistent hash from stringified data. Zero dependencies, ~450 bytes uncompressed.

Versus the leading brand:

💨 30% faster

🗜️ 98% smaller (20.2kb with deps vs 0.45k and no deps)

Usage

Install with your favorite package manager. The API is the same as JSON.stringify, and the library mostly wraps that.

import { stringify } from 'tiny-stable-stringify';

const obj = { z: 1, a: 2 };

console.info(stringify(obj));

// output is: {"a":2,"z":1}

Supports nested objects, sorting all keys consistently.

Handles the upcoming raw JSON feature, but just returns these unchanged with no sorting applied.

Notes

This package doesn't support custom sorting because we (ab)use JS' record type which puts integers first. But you don't care, you just want the keys to be sorted.

Requirements

I'm sure this is very upsetting, but this library requires a JS engine that supports WeakMap, Object.keys, Array.isArray, and JSON.stringify.

About

Sorted version of JSON.stringify

www.npmjs.com/package/tiny-stable-stringify

Topics

determenistichashjsonsortstablestringify

Resources

Readme
Apache-2.0 license
Activity

Stars

10 stars

Watchers

1 watching

Forks

0 forks
Report repository

Used by

Contributors

Languages

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.