npm.io
0.2.1 • Published 1 year ago

brave-json

Licence
MIT
Version
0.2.1
Deps
1
Size
9 kB
Vulns
0
Weekly
0

brave-json

Install

npm install --save brave-json
# or
yarn add brave-json

API

BraveJSON
interface IConverter<Raw, JSON extends JSONValue = JSONValue> {
  toJSON(value: Raw): JSON
  fromJSON(value: JSON): Raw
}

class BraveJSON {
  static readonly DEFAULT_SYMBOL = '$brave-json'

  constructor(
    converter: IConverter<unknown, JSONValue>
  , options?: { symbol?: string = BraveJSON.DEFAULT_SYMBOL }
  )

  stringify(value: unknown, space?: string | number): string
  parse<T>(text: string): T
}