1.0.0 • Published 2 years ago

@inlang/detect-json-formatting v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 years ago

@inlang/detect-json-formatting

Detects the formatting of a JSON file and returns a function to serialize the JSON file in the same format.

  • useful to minimize git diffs and merge conflicts

Usage

import { detectJsonFormatting } from '@inlang/detect-json-formatting'

const file = fs.readFileSync('./messages.json', 'utf-8')
const json = JSON.parse(file)
const stringify = detectJsonFormatting(file)
const serialized = stringify(json)

// serialized === file (same formatting)