0.0.3 • Published 4 years ago

man-string v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Convert Every Thing To String!

Looking for a library for debugging? this is what you are looking for

What is This

I guess you have seen this before:

element.innerText = { msg: "Hello" }

// HTML
[object Object]

For solving this problem you should use console but This Library is works like this:

element.innerHTML = { msg: "Hello" }

// HTML
{ msg: "Hello", }

Good huh? you can use this library for debugging or teaching or plobably for blogging

  • It also support arraylikes
Stringer.global();

element.innerHTML = { length: 1, 0: 2 }

// HTML
[ [0]: 2, ]

Getting Started

  • Simple usage:
Stringer(arg: any): string
  • Global Usage:
// config object is optional, used for turning every feature on or off
Stringer.global(config?: { fn: boolean, arr: boolean, obj: boolean }): Stringer

alert(any);

element.innerText = any;

Other Methods

Stringer.setSplitter(splitter: any) // used for splitting object properties or array elements

Stringer.unGlobal(): Stringer // used for reset to normal mode

Stringer.obj(): string // used for convert objects to string

Stringer.arr(): string // used for convert arrays to string

Stringer.fn(): string // used for convert functions to string

Stringer.isArrayLike() // this is what am i using for detect array likes, this returns true if your object has length proprty that has number value (jquery returns true)

Stringer.noConflict(): Stringer // this method removes stringer from anything 😭

// This is the object of original methods value
Stringer.origin = {
    obj: Object.prototype.toString,
    arr: Array.prototype.toString,
    fn: Function.prototype.toString
}

Stringer.binder(parent: any, method: string) // this is just a method to bind functions

Stringer.release: number // version of library

Known Issue

if you directly output null it returns nothing

Import to Node

importing into nodejs looks like this:

const Stringer = require("man-string").Stringer
  • Contact Me

if you found a bug or problem please contact me:

mohammadmahdi1383@outlook.com

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago