|
|
|
|
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Mock=e():t.Mock=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var a=n[r]={exports:{},id:r,loaded:!1};return t[r].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){var r,a=n(1),o=n(3),u=n(5),i=n(20),l=n(23),s=n(25);"undefined"!=typeof window&&(r=n(27));/*!
|
|
|
|
|
Mock - 模拟请求 & 模拟数据
|
|
|
|
|
https://github.com/nuysoft/Mock
|
|
|
|
|
墨智 mozhi.gyy@taobao.com nuysoft@gmail.com
|
|
|
|
|
*/
|
|
|
|
|
var c={Handler:a,Random:u,Util:o,XHR:r,RE:i,toJSONSchema:l,valid:s,heredoc:o.heredoc,setup:function(t){return r.setup(t)},_mocked:{}};c.version="1.0.1-beta3",r&&(r.Mock=c),c.mock=function(t,e,n){return 1===arguments.length?a.gen(t):(2===arguments.length&&(n=e,e=void 0),r&&(window.XMLHttpRequest=r),c._mocked[t+(e||"")]={rurl:t,rtype:e,template:n},c)},t.exports=c},function(module,exports,__webpack_require__){var Constant=__webpack_require__(2),Util=__webpack_require__(3),Parser=__webpack_require__(4),Random=__webpack_require__(5),RE=__webpack_require__(20),Handler={extend:Util.extend};Handler.gen=function(t,e,n){e=void 0==e?"":e+"",n=n||{},n={path:n.path||[Constant.GUID],templatePath:n.templatePath||[Constant.GUID++],currentContext:n.currentContext,templateCurrentContext:n.templateCurrentContext||t,root:n.root||n.currentContext,templateRoot:n.templateRoot||n.templateCurrentContext||t};var r,a=Parser.parse(e),o=Util.type(t);return Handler[o]?(r=Handler[o]({type:o,template:t,name:e,parsedName:e?e.replace(Constant.RE_KEY,"$1"):e,rule:a,context:n}),n.root||(n.root=r),r):t},Handler.extend({array:function(t){var e,n,r=[];if(0===t.template.length)return r;if(t.rule.parameters)if(1===t.rule.min&&void 0===t.rule.max)t.context.path.push(t.name),t.context.templatePath.push(t.name),r=Random.pick(Handler.gen(t.template,void 0,{path:t.context.path,templatePath:t.context.templatePath,currentContext:r,templateCurrentContext:t.template,root:t.context.root||r,templateRoot:t.context.templateRoot||t.template})),t.context.path.pop(),t.context.templatePath.pop();else if(t.rule.parameters[2])t.template.__order_index=t.template.__order_index||0,t.context.path.push(t.name),t.context.templatePath.push(t.name),r=Handler.gen(t.template,void 0,{path:t.context.path,templatePath:t.context.templatePath,currentContext:r,templateCurrentContext:t.template,root:t.context.root||r,templateRoot:t.context.templateRoot||t.template})[t.template.__order_index%t.template.length],t.template.__order_index+=+t.rule.parameters[2],t.context.path.pop(),t.context.templatePath.pop();else for(e=0;e<t.rule.count;e++)for(n=0;n<t.template.length;n++)t.context.path.push(r.length),t.context.templatePath.push(n),r.push(Handler.gen(t.template[n],r.length,{path:t.context.path,templatePath:t.context.templatePath,currentContext:r,templateCurrentContext:t.template,root:t.context.root||r,templateRoot:t.context.templateRoot||t.template})),t.context.path.pop(),t.context.templatePath.pop();else for(e=0;e<t.template.length;e++)t.context.path.push(e),t.context.templatePath.push(e),r.push(Handler.gen(t.template[e],e,{path:t.context.path,templatePath:t.context.templatePath,currentContext:r,templateCurrentContext:t.template,root:t.context.root||r,templateRoot:t.context.templateRoot||t.template})),t.context.path.pop(),t.context.templatePath.pop();return r},object:function(t){var e,n,r,a,o,u,i={};if(void 0!=t.rule.min)for(e=Util.keys(t.template),e=Random.shuffle(e),e=e.slice(0,t.rule.count),u=0;u<e.length;u++)r=e[u],a=r.replace(Constant.RE_KEY,"$1"),t.context.path.push(a),t.context.templatePath.push(r),i[a]=Handler.gen(t.template[r],r,{path:t.context.path,templatePath:t.context.templatePath,currentContext:i,templateCurrentContext:t.template,root:t.context.root||i,templateRoot:t.context.templateRoot||t.template}),t.context.path.pop(),t.context.templatePath.pop();else{e=[],n=[];for(r in t.template)("function"==typeof t.template[r]?n:e).push(r);for(e=e.concat(n),u=0;u<e.length;u++)r=e[u],a=r.replace(Constant.RE_KEY,"$1"),t.context.path.push(a),t.context.templatePath.push(r),i[a]=Handler.gen(t.template[r],r,{path:t.context.path,templatePath:t.context.templatePath,currentContext:i,templateCurrentContext:t.template,root:t.context.root||i,templateRoot:t.context.templateRoot||t.template}),t.context.path.pop(),t.context.templatePath.pop(),o=r.match(Constant.RE_KEY),o&&o[2]&&"number"===Util.type(t.template[r])&&(t.template[r]+=parseInt(o[2],10))}return i},number:function(t){var e,n;if(t.rule.decimal){for(t.template+="",n=t.template.split("."),n[0]=t.rule.range?t.rule.count:n[0],n[1]=(n[1]||"").slice(0,t.r
|
|
|
|
|
150121:"土默特左旗",150122:"托克托县",150123:"和林格尔县",150124:"清水河县",150125:"武川县",150126:"其它区",150200:"包头市",150202:"东河区",150203:"昆都仑区",150204:"青山区",150205:"石拐区",150206:"白云鄂博矿区",150207:"九原区",150221:"土默特右旗",150222:"固阳县",150223:"达尔罕茂明安联合旗",150224:"其它区",150300:"乌海市",150302:"海勃湾区",150303:"海南区",150304:"乌达区",150305:"其它区",150400:"赤峰市",150402:"红山区",150403:"元宝山区",150404:"松山区",150421:"阿鲁科尔沁旗",150422:"巴林左旗",150423:"巴林右旗",150424:"林西县",150425:"克什克腾旗",150426:"翁牛特旗",150428:"喀喇沁旗",150429:"宁城县",150430:"敖汉旗",150431:"其它区",150500:"通辽市",150502:"科尔沁区",150521:"科尔沁左翼中旗",150522:"科尔沁左翼后旗",150523:"开鲁县",150524:"库伦旗",150525:"奈曼旗",150526:"扎鲁特旗",150581:"霍林郭勒市",150582:"其它区",150600:"鄂尔多斯市",150602:"东胜区",150621:"达拉特旗",150622:"准格尔旗",150623:"鄂托克前旗",150624:"鄂托克旗",150625:"杭锦旗",150626:"乌审旗",150627:"伊金霍洛旗",150628:"其它区",150700:"呼伦贝尔市",150702:"海拉尔区",150703:"扎赉诺尔区",150721:"阿荣旗",150722:"莫力达瓦达斡尔族自治旗",150723:"鄂伦春自治旗",150724:"鄂温克族自治旗",150725:"陈巴尔虎旗",150726:"新巴尔虎左旗",150727:"新巴尔虎右旗",150781:"满洲里市",150782:"牙克石市",150783:"扎兰屯市",150784:"额尔古纳市",150785:"根河市",150786:"其它区",150800:"巴彦淖尔市",150802:"临河区",150821:"五原县",150822:"磴口县",150823:"乌拉特前旗",150824:"乌拉特中旗",150825:"乌拉特后旗",150826:"杭锦后旗",150827:"其它区",150900:"乌兰察布市",150902:"集宁区",150921:"卓资县",150922:"化德县",150923:"商都县",150924:"兴和县",150925:"凉城县",150926:"察哈尔右翼前旗",150927:"察哈尔右翼中旗",150928:"察哈尔右翼后旗",150929:"四子王旗",150981:"丰镇市",150982:"其它区",152200:"兴安盟",152201:"乌兰浩特市",152202:"阿尔山市",152221:"科尔沁右翼前旗",152222:"科尔沁右翼中旗",152223:"扎赉特旗",152224:"突泉县",152225:"其它区",152500:"锡林郭勒盟",152501:"二连浩特市",152502:"锡林浩特市",152522:"阿巴嘎旗",152523:"苏尼特左旗",152524:"苏尼特右旗",152525:"东乌珠穆沁旗",152526:"西乌珠穆沁旗",152527:"太仆寺旗",152528:"镶黄旗",152529:"正镶白旗",152530:"正蓝旗",152531:"多伦县",152532:"其它区",152900:"阿拉善盟",152921:"阿拉善左旗",152922:"阿拉善右旗",152923:"额济纳旗",152924:"其它区",210000:"辽宁省",210100:"沈阳市",210102:"和平区",210103:"沈河区",210104:"大东区",210105:"皇姑区",210106:"铁西区",210111:"苏家屯区",210112:"东陵区",210113:"新城子区",210114:"于洪区",210122:"辽中县",210123:"康平县",210124:"法库县",210181:"新民市",210184:"沈北新区",210185:"其它区",210200:"大连市",210202:"中山区",210203:"西岗区",210204:"沙河口区",210211:"甘井子区",210212:"旅顺口区",210213:"金州区",210224:"长海县",210281:"瓦房店市",210282:"普兰店市",210283:"庄河市",210298:"其它区",210300:"鞍山市",210302:"铁东区",210303:"铁西区",210304:"立山区",210311:"千山区",210321:"台安县",210323:"岫岩满族自治县",210381:"海城市",210382:"其它区",210400:"抚顺市",210402:"新抚区",210403:"东洲区",210404:"望花区",210411:"顺城区",210421:"抚顺县",210422:"新宾满族自治县",210423:"清原满族自治县",210424:"其它区",210500:"本溪市",210502:"平山区",210503:"溪湖区",210504:"明山区",210505:"南芬区",210521:"本溪满族自治县",210522:"桓仁满族自治县",210523:"其它区",210600:"丹东市",210602:"元宝区",210603:"振兴区",210604:"振安区",210624:"宽甸满族自治县",210681:"东港市",210682:"凤城市",210683:"其它区",210700:"锦州市",210702:"古塔区",210703:"凌河区",210711:"太和
|
|
|
|
|
522231:"其它区",522300:"黔西南布依族苗族自治州",522301:"兴义市",522322:"兴仁县",522323:"普安县",522324:"晴隆县",522325:"贞丰县",522326:"望谟县",522327:"册亨县",522328:"安龙县",522329:"其它区",522400:"毕节市",522401:"七星关区",522422:"大方县",522423:"黔西县",522424:"金沙县",522425:"织金县",522426:"纳雍县",522427:"威宁彝族回族苗族自治县",522428:"赫章县",522429:"其它区",522600:"黔东南苗族侗族自治州",522601:"凯里市",522622:"黄平县",522623:"施秉县",522624:"三穗县",522625:"镇远县",522626:"岑巩县",522627:"天柱县",522628:"锦屏县",522629:"剑河县",522630:"台江县",522631:"黎平县",522632:"榕江县",522633:"从江县",522634:"雷山县",522635:"麻江县",522636:"丹寨县",522637:"其它区",522700:"黔南布依族苗族自治州",522701:"都匀市",522702:"福泉市",522722:"荔波县",522723:"贵定县",522725:"瓮安县",522726:"独山县",522727:"平塘县",522728:"罗甸县",522729:"长顺县",522730:"龙里县",522731:"惠水县",522732:"三都水族自治县",522733:"其它区",530000:"云南省",530100:"昆明市",530102:"五华区",530103:"盘龙区",530111:"官渡区",530112:"西山区",530113:"东川区",530121:"呈贡区",530122:"晋宁县",530124:"富民县",530125:"宜良县",530126:"石林彝族自治县",530127:"嵩明县",530128:"禄劝彝族苗族自治县",530129:"寻甸回族彝族自治县",530181:"安宁市",530182:"其它区",530300:"曲靖市",530302:"麒麟区",530321:"马龙县",530322:"陆良县",530323:"师宗县",530324:"罗平县",530325:"富源县",530326:"会泽县",530328:"沾益县",530381:"宣威市",530382:"其它区",530400:"玉溪市",530402:"红塔区",530421:"江川县",530422:"澄江县",530423:"通海县",530424:"华宁县",530425:"易门县",530426:"峨山彝族自治县",530427:"新平彝族傣族自治县",530428:"元江哈尼族彝族傣族自治县",530429:"其它区",530500:"保山市",530502:"隆阳区",530521:"施甸县",530522:"腾冲县",530523:"龙陵县",530524:"昌宁县",530525:"其它区",530600:"昭通市",530602:"昭阳区",530621:"鲁甸县",530622:"巧家县",530623:"盐津县",530624:"大关县",530625:"永善县",530626:"绥江县",530627:"镇雄县",530628:"彝良县",530629:"威信县",530630:"水富县",530631:"其它区",530700:"丽江市",530702:"古城区",530721:"玉龙纳西族自治县",530722:"永胜县",530723:"华坪县",530724:"宁蒗彝族自治县",530725:"其它区",530800:"普洱市",530802:"思茅区",530821:"宁洱哈尼族彝族自治县",530822:"墨江哈尼族自治县",530823:"景东彝族自治县",530824:"景谷傣族彝族自治县",530825:"镇沅彝族哈尼族拉祜族自治县",530826:"江城哈尼族彝族自治县",530827:"孟连傣族拉祜族佤族自治县",530828:"澜沧拉祜族自治县",530829:"西盟佤族自治县",530830:"其它区",530900:"临沧市",530902:"临翔区",530921:"凤庆县",530922:"云县",530923:"永德县",530924:"镇康县",530925:"双江拉祜族佤族布朗族傣族自治县",530926:"耿马傣族佤族自治县",530927:"沧源佤族自治县",530928:"其它区",532300:"楚雄彝族自治州",532301:"楚雄市",532322:"双柏县",532323:"牟定县",532324:"南华县",532325:"姚安县",532326:"大姚县",532327:"永仁县",532328:"元谋县",532329:"武定县",532331:"禄丰县",532332:"其它区",532500:"红河哈尼族彝族自治州",532501:"个旧市",532502:"开远市",532522:"蒙自市",532523:"屏边苗族自治县",532524:"建水县",532525:"石屏县",532526:"弥勒市",532527:"泸西县",532528:"元阳县",532529:"红河县",532530:"金平苗族瑶族傣族自治县",532531:"绿春县",532532:"河口瑶族自治县",532533:"其它区",532600:"文山壮族苗族自治州",532621:"文山市",532622:"砚山县",532623:"西畴县",532624:"麻栗坡县",532625:"马关县",532626:"丘北县",532627:"广南县",532628:"富宁县",532629:"其它区",532800:"西双版纳傣族自治州",532801:"景洪市",532822:"勐海县",532823:"勐腊县",532824:"其它区",532900:"大理白族自治<EFBFBD>
|
|
|
|
|
return new n("word")},An="\\W",_n='"\\\\W"',Mn=function(){return new n("non-word")},Pn="\\c",Tn='"\\\\c"',Hn="any character",Sn=function(t){return new g(t)},Dn="\\",qn='"\\\\"',Fn=/^[1-9]/,Ln="[1-9]",On=function(t){return new m(t)},In="\\0",jn='"\\\\0"',Nn=/^[0-7]/,zn="[0-7]",Un=function(t){return new d(t.join(""))},Bn="\\x",Gn='"\\\\x"',Xn=/^[0-9a-fA-F]/,Kn="[0-9a-fA-F]",Wn=function(t){return new f(t.join(""))},Yn="\\u",$n='"\\\\u"',Jn=function(t){return new p(t.join(""))},Vn=function(){return new n("null-character")},Zn=0,Qn=0,tr=0,er={line:1,column:1,seenCR:!1},nr=0,rr=[],ar=0;if("startRule"in bt){if(!(bt.startRule in wt))throw new Error("Can't start parsing from rule \""+bt.startRule+'".');Ct=wt[bt.startRule]}if(n.offset=x,n.text=v,yt=Ct(),null!==yt&&Zn===t.length)return yt;throw w(rr),Qn=Math.max(Zn,nr),new e(rr,Qn<t.length?t.charAt(Qn):null,Qn,y(Qn).line,y(Qn).column)}return t(e,Error),{SyntaxError:e,parse:v}}(),x=1,y={};t.exports=v},function(t,e,n){function r(t,e){for(var n="",r=t;e>=r;r++)n+=String.fromCharCode(r);return n}var a=n(3),o=n(5),u={extend:a.extend},i=r(97,122),l=r(65,90),s=r(48,57),c=r(32,47)+r(58,64)+r(91,96)+r(123,126),h=r(32,126),p=" \f\n\r \x0B \u2028\u2029",f={"\\w":i+l+s+"_","\\W":c.replace("_",""),"\\s":p,"\\S":function(){for(var t=h,e=0;e<p.length;e++)t=t.replace(p[e],"");return t}(),"\\d":s,"\\D":i+l+c};u.gen=function(t,e,n){return n=n||{guid:1},u[t.type]?u[t.type](t,e,n):u.token(t,e,n)},u.extend({token:function(t,e,n){switch(t.type){case"start":case"end":return"";case"any-character":return o.character();case"backspace":return"";case"word-boundary":return"";case"non-word-boundary":break;case"digit":return o.pick(s.split(""));case"non-digit":return o.pick((i+l+c).split(""));case"form-feed":break;case"line-feed":return t.body||t.text;case"carriage-return":break;case"white-space":return o.pick(p.split(""));case"non-white-space":return o.pick((i+l+s).split(""));case"tab":break;case"vertical-tab":break;case"word":return o.pick((i+l+s).split(""));case"non-word":return o.pick(c.replace("_","").split(""));case"null-character":}return t.body||t.text},alternate:function(t,e,n){return this.gen(o["boolean"]()?t.left:t.right,e,n)},match:function(t,e,n){e="";for(var r=0;r<t.body.length;r++)e+=this.gen(t.body[r],e,n);return e},"capture-group":function(t,e,n){return e=this.gen(t.body,e,n),n[n.guid++]=e,e},"non-capture-group":function(t,e,n){return this.gen(t.body,e,n)},"positive-lookahead":function(t,e,n){return this.gen(t.body,e,n)},"negative-lookahead":function(t,e,n){return""},quantified:function(t,e,n){e="";for(var r=this.quantifier(t.quantifier),a=0;r>a;a++)e+=this.gen(t.body,e,n);return e},quantifier:function(t,e,n){var r=Math.max(t.min,0),a=isFinite(t.max)?t.max:r+o.integer(3,7);return o.integer(r,a)},charset:function(t,e,n){if(t.invert)return this["invert-charset"](t,e,n);var r=o.pick(t.body);return this.gen(r,e,n)},"invert-charset":function(t,e,n){for(var r,a=h,u=0;u<t.body.length;u++)switch(r=t.body[u],r.type){case"literal":a=a.replace(r.body,"");break;case"range":for(var i=this.gen(r.start,e,n).charCodeAt(),l=this.gen(r.end,e,n).charCodeAt(),s=i;l>=s;s++)a=a.replace(String.fromCharCode(s),"");default:var c=f[r.text];if(c)for(var p=0;p<=c.length;p++)a=a.replace(c[p],"")}return o.pick(a.split(""))},range:function(t,e,n){var r=this.gen(t.start,e,n).charCodeAt(),a=this.gen(t.end,e,n).charCodeAt();return String.fromCharCode(o.integer(r,a))},literal:function(t,e,n){return t.escaped?t.body:t.text},unicode:function(t,e,n){return String.fromCharCode(parseInt(t.code,16))},hex:function(t,e,n){return String.fromCharCode(parseInt(t.code,16))},octal:function(t,e,n){return String.fromCharCode(parseInt(t.code,8))},"back-reference":function(t,e,n){return n[t.code]||""},CONTROL_CHARACTER_MAP:function(){for(var t="@ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ] ^ _".split(" "),e="\x00 \b \n \x0B \f \r ".split(" "),n={},r=0;r<t.length;r++)n[t[r]]=e[r];return n}(),"control-character":function(t,e,n){return this.CONTROL_CHARACTER_MAP[t.code]}}),t.exports
|
|
|
|
|
//# sourceMappingURL=mock-min.js.map
|