0.0.3 • Published 5 years ago

@monabbous/object-digger v0.0.3

Weekly downloads
-
License
-
Repository
github
Last release
5 years ago

Object Digger

This library is used to parse an accessor string with a given context object.

for example:

const context = {
    "name" : {
        "value": "Ali Baba",
        "operator": "LIKE"
    },
    "phone": "000221133456"
};

console.log(digger("name.value", context));

output:

["Ali Baba"] 

String Parser

The string parser can be used just like handlebar mustache syntax with a given context object, which would return a string with the accessors being resolved and parsed.

console.log(diggerStringParser("Hi, my name is [[name.value]] and my phone number is [[phone]]", context));
console.log(diggerStringParser("Hi, my name is {{name.value}} and my phone number is {{phone}}", context, 'curly-brackets'));
console.log(diggerStringParser("Hi, my name is ``name.value`` and my phone number is ``phone``", context, 'backticks'));

output:

"Hi, my name is Ali Baba and my phone number is 000221133456" 

that's it just install with npm i @monabbous/object-digger and start digging :D