Autocast - Node Module
Posted by Dave Eddy on Jul 17 2012 - tags: techEasily and automatically cast common datatypes in JavaScript
I was working on parsing output from the command line while creating the Node SMF module. This required me to inspect the elements individually and write case statements to expect certain data types be returned.
What I mean by this is…
When you parse the command line, everything gets returned as a string.
So, you must do some post-processing to cast items that look like numbers
to numbers, strings that look like keywords to keywords, ie 'false'
to false
, etc.
So, autocast was born. This module will do all of that inspection for you and return what it thinks the object should be.
Check out the project page here https://github.com/bahamas10/node-autocast
Example
Install
Install locally to use as a module
npm install autocast
License
MIT Licensed