MCPcopy Create free account
hub / github.com/Moli-X/Resources / processValue

Function processValue

Script/Parser.js:3269–3375  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

3267 }
3268
3269 function processValue(val) {
3270 val = val.replace(regex["trim"], "");
3271 var m = null;
3272
3273 if(val == 'true') {
3274 return true;
3275 } else if(val == 'false') {
3276 return false;
3277 } else if(val == '.NaN') {
3278 return Number.NaN;
3279 } else if(val == 'null') {
3280 return null;
3281 } else if(val == '.inf') {
3282 return Number.POSITIVE_INFINITY;
3283 } else if(val == '-.inf') {
3284 return Number.NEGATIVE_INFINITY;
3285 } else if(m = val.match(regex["dashesString"])) {
3286 return m[1];
3287 } else if(m = val.match(regex["quotesString"])) {
3288 return m[1];
3289 } else if(m = val.match(regex["float"])) {
3290 return parseFloat(m[0]);
3291 } else if(m = val.match(regex["integer"])) {
3292 return parseInt(m[0]);
3293 } else if( !isNaN(m = Date.parse(val))) {
3294 return new Date(m);
3295 } else if(m = val.match(regex["single_key_value"])) {
3296 var res = {};
3297 res[m[1]] = processValue(m[2]);
3298 return res;
3299 } else if(m = val.match(regex["array"])){
3300 var count = 0, c = ' ';
3301 var res = [];
3302 var content = "";
3303 var str = false;
3304 for(var j = 0, lenJ = m[1].length; j < lenJ; ++j) {
3305 c = m[1][j];
3306 if(c == '\'' || c == '"') {
3307 if(str === false) {
3308 str = c;
3309 content += c;
3310 continue;
3311 } else if((c == '\'' && str == '\'') || (c == '"' && str == '"')) {
3312 str = false;
3313 content += c;
3314 continue;
3315 }
3316 } else if(str === false && (c == '[' || c == '{')) {
3317 ++count;
3318 } else if(str === false && (c == ']' || c == '}')) {
3319 --count;
3320 } else if(str === false && count == 0 && c == ',') {
3321 res.push(processValue(content));
3322 content = "";
3323 continue;
3324 }
3325
3326 content += c;

Callers 1

processBlockFunction · 0.85

Calls 2

parseMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected