All notable changes to this project will be documented in this file. See standard-version for commit guidelines.
4.0.2 (2024-09-18)
- use
Number.parseFloat
,Number.parseInt
, etc and use string templates consistently (af946b1)
4.0.1 (2023-12-14)
- allow replacer and reviver to be
null
(b280774)
4.0.0 (2023-12-13)
- The usages of types
JSONValue
,JSONObject
,JSONArray
, andJSONPrimitive
must be replaced withunknown
. Only relevant when using areplacer
.
- replace
JSONValue
withunknown
(7f4d81b)
3.0.2 (2023-11-13)
- crash when input ends with a truncated unicode character (fe6a1e3)
3.0.1 (2023-11-06)
3.0.0 (2023-11-01)
- The usages of types
JavaScriptValue
,JavaScriptObject
,JavaScriptArray
andJavaScriptPrimitive
must be replaced withunknown
.
- #250 replace the
JavaScriptValue
type definition withunknown
, which is more accurate (6033fec) - drop official support for node.js 16 (ee88c4a)
- for backward compatibility, keep the JavaScriptValue types there and mark them deprecated (bb92e3f)
- replace
JavaScriptValue
withunknown
, which is more accurate (see #250) (94d2503)
2.0.11 (2023-07-12)
- adjust published module types (311995d)
2.0.10 (2023-07-07)
- let the
main
field inpackage.json
point to the CommonJS output instead of ESM (0d6c48f)
2.0.9 (2023-05-05)
2.0.8 (2023-03-06)
2.0.7 (2023-03-06)
- do to throw a duplicate key error when the values are equal (452f385)
- Fix: empty objects and arrays being formatted with indentation inside.
- Fix: error handling unicode characters containing a
9
.
- Improved performance.
- Fix:
parse
not throwing an exception on illegal characters inside a string, like an unescaped new line.
- Fix:
parse
throwing a duplicate key error when using built-in property name liketoString
as key.
- Fix: configure
exports
inpackage.json
to fix problems with Jest (#243). Thanks @akphi.
IMPORTANT: BREAKING CHANGES
Breaking changes:
- Function
parse
now throws an error when a duplicate key is encountered. - Dropped support for circular references. If you encounter circular references in your data structures, please rethink your datastructures: better prevent circular references in the first place.
- The constructor of the
LosslessNumber
class now only supports a string as argument. UsetoLosslessNumber
to convert a number into a LosslessNumber in a safe way. - Dropped the undocumented property
.type
onLosslessNumber
instances. Please use.isLosslessNumber
instead. - Dropped official support for Node.js 12.
Non-breaking changes:
- Serialization of numeric values is now fully customizable via new options
parseNumber
andnumberStringifiers
, making it easier to integrate with a BigNumber library, or to write your own logic to turn numeric values intobigint
when needed. - Built in support for
bigint
. - Built-in support for
Date
(turned off by default), seereviveDate
. - Export a set of utility functions:
isInteger
,isNumber
,isSafeNumber
,toSafeNumberOrThrow
,getUnsafeNumberReason
,parseLosslessNumber
,parseNumberAndBigInt
,reviveDate
,isLosslessNumber
,toLosslessNumber
. - THe library is modular now: it exports ES modules and an UMD bundle. The ES modules allow to import only the functions that you need, instead of pulling in the full bundle.
- The library now comes with TypeScript definitions, and the code has been rewritten in TypeScript,
- Performance of both
parse
andstringify
has been improved a lot.
- Fixed stringifing of object keys containing special characters like backslash, see #239. Thanks @mengfanliao.
- Fix #117: remove unnecessary configuration files from npm package.
- Improved performance of
stringify
by usingJSON.stringify
where possible. Thanks @SergeyFromHell for the suggestion (see #5).
- Fixed #4: parser not handling strings equaling a JSON delimiter
like
"["
correctly.
- Upgraded all dev dependencies, fixes broken build script. See #2.
- Implemented support for circular references (configurable).
- Implemented support for reviver, replacer, and indentation (space).
- Throw error in case of underflow.
- Performance improvements.
- The
LosslessNumber
class now throws errors when you would lose information when converting from and to aLosslessNumber
. - Handle escape characters when stringifying a string.
- Exposed
LosslessNumber
in public API.
- First functional version which can parse and stringify.