expand-path
Version:
Super light-weight brace expansion for node
1 lines • 1.1 kB
JavaScript
!function(){var a=function(a){this.str=a};a.prototype._updateString=function(a){this.str=this.str.replace(a,"")},a.prototype.consumeTill=function(a,b){var c=this.str.substring(0,this.str.indexOf(a)+(b?1:0));return this._updateString(c),c},a.prototype.consume=function(a){var b=this.str.match(a);if(b)return this._updateString(a),b[0]},"object"==typeof module&&module.exports&&(module.exports=a),"undefined"!=typeof window&&(window.Consumed=a)}(),function(){var a="undefined"!=typeof module&&this.module!==module,b=a?require("consumed"):window.Consumed,c={"[":"]","{":"}","<":">"},d=function(a,b){for(var c=0;c<b.length;c++)if(a.indexOf(b[c])>-1)return b[c]},e=function(a,b){return b+=a},f=function(a,b,c){return b.concat(a.map(e.bind(null,c)))},g=function(a){var g=new b(a),h=d(a,["{","[","<"]);if(h){for(var i=[""];g.str.indexOf(h)>-1;){var j=g.consumeTill(h);j&&(i=i.map(e.bind(null,j)));var k=g.consumeTill(c[h],!0),l=k.replace(h,"").replace(c[h],"").split(/\s*,\s*/g);i=l.reduce(f.bind(null,i),[])}return g.str&&(i=i.map(e.bind(null,g.str))),i}return[a]};a?module.exports=g:window.expandPath=g}();