Sha256: 4ea5351cea859b242b69b16b6f1d5c32a483cb9efee25f231eee53a2936649a8
Contents?: true
Size: 687 Bytes
Versions: 69
Compression:
Stored size: 687 Bytes
Contents
var UNDEF; /** * Parses string and convert it into a native value. */ function typecast(val) { var r; if ( val === null || val === 'null' ) { r = null; } else if ( val === 'true' ) { r = true; } else if ( val === 'false' ) { r = false; } else if ( val === UNDEF || val === 'undefined' ) { r = UNDEF; } else if ( val === '' || isNaN(val) ) { //isNaN('') returns false r = val; } else { //parseFloat(null || '') returns NaN r = parseFloat(val); } return r; } module.exports = typecast;
Version data entries
69 entries across 69 versions & 2 rubygems