loader-utils

utils for webpack loaders

npm install loader-utils
67 downloads in the last day
501 downloads in the last week
2 020 downloads in the last month

loader-utils

Methods

parseQuery

var query = loaderUtils.parseQuery(this.query);
assert(typeof query == "object");
if(query.flag)
    // ...
null                   -> {}
?                      -> {}
?flag                  -> { flag: true }
?+flag                 -> { flag: true }
?-flag                 -> { flag: false }
?xyz=test              -> { xyz: "test" }
?xyz[]=a               -> { xyz: ["a"] }
?flag1&flag2           -> { flag1: true, flag2: true }
?+flag1,-flag2         -> { flag1: true, flag2: false }
?xyz[]=a,xyz[]=b       -> { xyz: ["a", "b"] }
?a%2C%26b=c%2C%26d     -> { "a,&b": "c,&d" }
?{json:5,data:{a:1}}   -> { json: 5, data: { a: 1 } }

License

MIT (http://www.opensource.org/licenses/mit-license.php)

npm loves you