value-or-json(input)
is a function that always returns a value based on its input
.
That is, when typeof input !== "object"
, it simply returns its input. However when passed an object, it returns JSON.stringify(input)
.
It also exposes valueOrJson.needsStringify()
in case you just want to test for this condition instead of actually doing the transform.
- NEW Make browser-friendly by converting node-specific
assert()
into JS-genericthrow
. (alex996)
- NEW TypeScript definition. (alex996)
- NEW Initial release.