unknown2string
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

mapUnknownToString

CI/CD version downloads

  • Takes any value
  • Returns a string

It'll take a boolean, a number, null, undefined, an Array, an Error, an object, even another string!

Examples

const unknowns = [
  true,
  false,
  123,
  null,
  undefined,
  ['Hello', 'world'],
  new Error('test error message'),
  { Hello: 'world' },
  'string',
];

const strings = unknowns.map(mapUnknownToString);
console.log(strings);

/*
[
  'true',
  'false',
  '123',
  'null',
  'undefined',
  '["Hello", "world"]',
  'test error message',
  '{"Hello": "world"}',
  'string',
]
*/

Readme

Keywords

none

Package Sidebar

Install

npm i unknown2string

Weekly Downloads

388

Version

1.0.1

License

MIT

Unpacked Size

6.78 kB

Total Files

11

Last publish

Collaborators

  • charlesstover