0.0.4 • Published 6 years ago

typevalue v0.0.4

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

typevalue

Convert JavaScript values to their proper type. Handy for converting strings into their properly typed value.

Installation

npm i --save typevalue

Usage

let typeValue = require('typevalue');
let exampleObject = {
    'date': [
        '2018-03-13 04:20:00-700',
        '2018-03-13 04:20:00',
        '2018-03-13'
    ],
    'boolean': [
        true,
        false,
        'true',
        'false',
        'yes',
        'no'
    ],
    'number': [
        0,
        1,
        0.1,
        1.0,
        '0',
        '1',
        '0.1',
        '1.0',
        '1,000',
        '1.5k',
        '$1.25m'
    ]
};
console.log('typeExample', JSON.stringify(typeValue(exampleObject), null, 4));

Output:

typeExample {
    "date": [
        "2018-03-13T11:20:00.000Z",
        "2018-03-13T11:20:00.000Z",
        "2018-03-13T00:00:00.000Z"
    ],
    "boolean": [
        true,
        false,
        true,
        false,
        true,
        false
    ],
    "number": [
        0,
        1,
        0.1,
        1,
        0,
        1,
        0.1,
        1,
        1000,
        1500,
        1250000
    ]
}
0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago