from-string

1.1.7 • Public • Published

from-string

Converting string data into its corresponding javascript types

Table of contents

General info

from-string allows to change string representations of arrays, numbers, booleans into its corresponding values. I.e. having "2" it will result with 2 returned.

function: parse(stringValue)

var number2  = theModule.parse("2");
var number222  = theModule.parse("2.22");
Kind Parameter Type Description
Argument stringValue string Required. String data that will be converted to corresponding data type value
Returns `object array

Mappings

Sample Input Result Type Result
"2" number 2
"2.3" number 2.3
".2" number 0.2
"testing one two three" string "testing one two three"
undefined undefined undefined
null undefined undefined
"[1,2,3]" array<number> [1,2,3]
"["a","b","c"]" array<string> ["a","b","c"]
"false" boolean false
"true" boolean true

Package Sidebar

Install

npm i from-string

Weekly Downloads

0

Version

1.1.7

License

MIT

Unpacked Size

16 kB

Total Files

7

Last publish

Collaborators

  • grulka