value-or-json
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

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.

Version History

v1.1.0 2020-09-02

  • NEW Make browser-friendly by converting node-specific assert() into JS-generic throw. (alex996)

v1.0.0 2020-08-28

  • NEW TypeScript definition. (alex996)

v0.1.0 2019-02-23

  • NEW Initial release.

Readme

Keywords

none

Package Sidebar

Install

npm i value-or-json

Weekly Downloads

4

Version

1.1.0

License

MIT

Unpacked Size

3.07 kB

Total Files

5

Last publish

Collaborators

  • rentzsch