JSFiddle - React, Tailwind, and code Playground

by jakie8

HTML

<script src="https://raw.github.com/jakiestfu/ParseObject.js/master/ParseObject.js"></script>

JavaScript

var tests = {
    hello: {
        world: function(){
          alert('Hello World');
        }
    },
    fruit: {
      apples: {
        red: function(){
          alert('I exist too!');
        },
        green: 123
      }
    }
};


ParseObject({
    path: 'hello/world',
    target: tests,
    delimiter: '/',
    parsed: function(res) {
        // res.exists = true
        // res.type = 'function'
        // res.obj | res.obj houses the function, will allert "Hello World" if called
        console.log(res);
    }
});

ParseObject({
    path: 'fruit-apples-red',
    target: tests,
    delimiter: '-',
    parsed: function(res) {
        // res.exists = true
        // res.type = 'function'
        // res.obj | res.obj houses the function, will allert "I exist too!" if called
        console.log(res);
    }
});

ParseObject({
    path: 'fruit_apples_green',
    target: tests,
    delimiter: '_',
    parsed: function(res) {
        // res.exists = true
        // res.type = 'number'
        // res.obj = 123
        console.log(res);
    }
});

ParseObject({
    path: 'fruit/bananas',
    target: tests,
    delimiter: '/',
    parsed: function(res) {
        // res.exists = false
      console.log(res);
    }
});