1.1.3 • Published 9 years ago

text-parser v1.1.3

Weekly downloads
1
License
WTFPL
Repository
-
Last release
9 years ago

#HOW TO USE: Firstly init it like that:

var parser=new (require("text-parser"))({
    folder:__dirname+"/lang/parser", //Folder with avail. languages
    langs:["en"]                     //avail. language list
});

Nextly create file with your language (folder/language.json) and fill thim like that:

{
    "stringname": [
        "variant1 {{num:id}}, {{str:string}},{{type:any_or_not}}:{{t:string}}",
        "variant2 {{num:id}}:{{str:string}}:{{t:string}}",
    ]
}

And use it like this:

var stringToParse="variant1 3, test,:test2"
parser.parse("stringname",stringToParse,(out)=>{
    console.log(out);
    //Will write: 
    // {num:3, str:test, type:"", t:test2}
})
stringToParse="variant1 3, test,test3:test2"
parser.parse("stringname",stringToParse,(out)=>{
    console.log(out);
    //Will write: 
    // {num:3, str:test, type:"test3", t:test2}
})

If input string does not matched requested, callback will be not executed.

1.1.3

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago