1.1.7 • Published 4 years ago

from-string v1.1.7

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

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");
KindParameterTypeDescription
ArgumentstringValuestringRequired. String data that will be converted to corresponding data type value
Returnsobject|array|string|number|booleanObject or type representing given string value

Mappings

Sample InputResult TypeResult
"2"number2
"2.3"number2.3
".2"number0.2
"testing one two three"string"testing one two three"
undefinedundefinedundefined
nullundefinedundefined
"1,2,3"array<number>1,2,3
""a","b","c""array<string>"a","b","c"
"false"booleanfalse
"true"booleantrue
1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago