/string-any

Primary LanguageJavaScriptMIT LicenseMIT

string-any

Codacy Badge npm GitHub npm bundle size

string-any is a package to convert any object to a string and not [object Object]

Usage

const { toStr } = require('string-any');

// objects
toStr(
  {
    name: "name",
    id: 32918,
    randomThing: {
      dwq: "hello"
    },
    func: () => "hello"
  }
);
// => "{
// =>   name: "name",
// =>   id: 32918,
// =>   randomThing: {
// =>      dwq: "hello"
// =>   },
// =>   func: () => "hello"
// => }"

// functions
toStr(() => {}) // => "() => {}"

// numbers
toStr(10) // => "10"

// Strings
toStr("hello") // => '"hello"'

// String Objects
toStr(new String("hello")) // => "hello"

// Arrays
toStr([1,2,3]) // => "[1, 2, 3]"

LICENSE

MIT License

Copyright (c) 2019 AliBasicCoder