Best JavaScript code snippet using fast-check-monorepo
querystring-parse-coverage.js
Source:querystring-parse-coverage.js
1/*2YUI 3.7.3 (build 5687)3Copyright 2012 Yahoo! Inc. All rights reserved.4Licensed under the BSD License.5http://yuilibrary.com/license/6*/7if (typeof _yuitest_coverage == "undefined"){8 _yuitest_coverage = {};9 _yuitest_coverline = function(src, line){10 var coverage = _yuitest_coverage[src];11 if (!coverage.lines[line]){12 coverage.calledLines++;13 }14 coverage.lines[line]++;15 };16 _yuitest_coverfunc = function(src, name, line){17 var coverage = _yuitest_coverage[src],18 funcId = name + ":" + line;19 if (!coverage.functions[funcId]){20 coverage.calledFunctions++;21 }22 coverage.functions[funcId]++;23 };24}25_yuitest_coverage["build/querystring-parse/querystring-parse.js"] = {26 lines: {},27 functions: {},28 coveredLines: 0,29 calledLines: 0,30 coveredFunctions: 0,31 calledFunctions: 0,32 path: "build/querystring-parse/querystring-parse.js",33 code: []34};35_yuitest_coverage["build/querystring-parse/querystring-parse.js"].code=["YUI.add('querystring-parse', function (Y, NAME) {","","/**"," * The QueryString module adds support for serializing JavaScript objects into"," * query strings and parsing JavaScript objects from query strings format."," *"," * The QueryString namespace is added to your YUI instance including static methods"," * `Y.QueryString.parse(..)` and `Y.QueryString.stringify(..)`."," *"," * The `querystring` module is a alias for `querystring-parse` and"," * `querystring-stringify`."," *"," * As their names suggest, `querystring-parse` adds support for parsing"," * Query String data (`Y.QueryString.parse`) and `querystring-stringify` for serializing"," * JavaScript data into Query Strings (`Y.QueryString.stringify`). You may choose to"," * include either of the submodules individually if you don't need the"," * complementary functionality, or include the rollup for both."," *"," * @module querystring"," * @main querystring","*/","/**"," * The QueryString module adds support for serializing JavaScript objects into"," * query strings and parsing JavaScript objects from query strings format."," * @class QueryString"," * @static"," */","var QueryString = Y.namespace(\"QueryString\"),","","// Parse a key=val string.","// These can get pretty hairy","// example flow:","// parse(foo[bar][][bla]=baz)","// return parse(foo[bar][][bla],\"baz\")","// return parse(foo[bar][], {bla : \"baz\"})","// return parse(foo[bar], [{bla:\"baz\"}])","// return parse(foo, {bar:[{bla:\"baz\"}]})","// return {foo:{bar:[{bla:\"baz\"}]}}","pieceParser = function (eq) {"," return function parsePiece (key, val) {",""," var sliced, numVal, head, tail, ret;",""," if (arguments.length !== 2) {"," // key=val, called from the map/reduce"," key = key.split(eq);"," return parsePiece("," QueryString.unescape(key.shift()),"," QueryString.unescape(key.join(eq))"," );"," }"," key = key.replace(/^\\s+|\\s+$/g, '');"," if (Y.Lang.isString(val)) {"," val = val.replace(/^\\s+|\\s+$/g, '');"," // convert numerals to numbers"," if (!isNaN(val)) {"," numVal = +val;"," if (val === numVal.toString(10)) {"," val = numVal;"," }"," }"," }"," sliced = /(.*)\\[([^\\]]*)\\]$/.exec(key);"," if (!sliced) {"," ret = {};"," if (key) {"," ret[key] = val;"," }"," return ret;"," }"," // [\"foo[][bar][][baz]\", \"foo[][bar][]\", \"baz\"]"," tail = sliced[2];"," head = sliced[1];",""," // array: key[]=val"," if (!tail) {"," return parsePiece(head, [val]);"," }",""," // obj: key[subkey]=val"," ret = {};"," ret[tail] = val;"," return parsePiece(head, ret);"," };","},","","// the reducer function that merges each query piece together into one set of params","mergeParams = function(params, addition) {"," return ("," // if it's uncontested, then just return the addition."," (!params) ? addition"," // if the existing value is an array, then concat it."," : (Y.Lang.isArray(params)) ? params.concat(addition)"," // if the existing value is not an array, and either are not objects, arrayify it."," : (!Y.Lang.isObject(params) || !Y.Lang.isObject(addition)) ? [params].concat(addition)"," // else merge them as objects, which is a little more complex"," : mergeObjects(params, addition)"," );","},","","// Merge two *objects* together. If this is called, we've already ruled","// out the simple cases, and need to do the for-in business.","mergeObjects = function(params, addition) {"," for (var i in addition) {"," if (i && addition.hasOwnProperty(i)) {"," params[i] = mergeParams(params[i], addition[i]);"," }"," }"," return params;","};","","/**"," * Provides Y.QueryString.parse method to accept Query Strings and return native"," * JavaScript objects."," *"," * @module querystring"," * @submodule querystring-parse"," * @for QueryString"," * @method parse"," * @param qs {String} Querystring to be parsed into an object."," * @param sep {String} (optional) Character that should join param k=v pairs together. Default: \"&\""," * @param eq {String} (optional) Character that should join keys to their values. Default: \"=\""," * @public"," * @static"," */","QueryString.parse = function (qs, sep, eq) {"," // wouldn't Y.Array(qs.split()).map(pieceParser(eq)).reduce(mergeParams) be prettier?"," return Y.Array.reduce("," Y.Array.map("," qs.split(sep || \"&\"),"," pieceParser(eq || \"=\")"," ),"," {},"," mergeParams"," );","};","","/**"," * Provides Y.QueryString.unescape method to be able to override default decoding"," * method. This is important in cases where non-standard delimiters are used, if"," * the delimiters would not normally be handled properly by the builtin"," * (en|de)codeURIComponent functions."," * Default: replace \"+\" with \" \", and then decodeURIComponent behavior."," * @module querystring"," * @submodule querystring-parse"," * @for QueryString"," * @method unescape"," * @param s {String} String to be decoded."," * @public"," * @static"," **/","QueryString.unescape = function (s) {"," return decodeURIComponent(s.replace(/\\+/g, ' '));","};","","","","","}, '3.7.3', {\"requires\": [\"yui-base\", \"array-extras\"]});"];36_yuitest_coverage["build/querystring-parse/querystring-parse.js"].lines = {"1":0,"28":0,"40":0,"42":0,"44":0,"46":0,"47":0,"52":0,"53":0,"54":0,"56":0,"57":0,"58":0,"59":0,"63":0,"64":0,"65":0,"66":0,"67":0,"69":0,"72":0,"73":0,"76":0,"77":0,"81":0,"82":0,"83":0,"89":0,"104":0,"105":0,"106":0,"109":0,"126":0,"128":0,"152":0,"153":0};37_yuitest_coverage["build/querystring-parse/querystring-parse.js"].functions = {"parsePiece:40":0,"pieceParser:39":0,"mergeParams:88":0,"mergeObjects:103":0,"parse:126":0,"unescape:152":0,"(anonymous 1):1":0};38_yuitest_coverage["build/querystring-parse/querystring-parse.js"].coveredLines = 36;39_yuitest_coverage["build/querystring-parse/querystring-parse.js"].coveredFunctions = 7;40_yuitest_coverline("build/querystring-parse/querystring-parse.js", 1);41YUI.add('querystring-parse', function (Y, NAME) {42/**43 * The QueryString module adds support for serializing JavaScript objects into44 * query strings and parsing JavaScript objects from query strings format.45 *46 * The QueryString namespace is added to your YUI instance including static methods47 * `Y.QueryString.parse(..)` and `Y.QueryString.stringify(..)`.48 *49 * The `querystring` module is a alias for `querystring-parse` and50 * `querystring-stringify`.51 *52 * As their names suggest, `querystring-parse` adds support for parsing53 * Query String data (`Y.QueryString.parse`) and `querystring-stringify` for serializing54 * JavaScript data into Query Strings (`Y.QueryString.stringify`). You may choose to55 * include either of the submodules individually if you don't need the56 * complementary functionality, or include the rollup for both.57 *58 * @module querystring59 * @main querystring60*/61/**62 * The QueryString module adds support for serializing JavaScript objects into63 * query strings and parsing JavaScript objects from query strings format.64 * @class QueryString65 * @static66 */67_yuitest_coverfunc("build/querystring-parse/querystring-parse.js", "(anonymous 1)", 1);68_yuitest_coverline("build/querystring-parse/querystring-parse.js", 28);69var QueryString = Y.namespace("QueryString"),70// Parse a key=val string.71// These can get pretty hairy72// example flow:73// parse(foo[bar][][bla]=baz)74// return parse(foo[bar][][bla],"baz")75// return parse(foo[bar][], {bla : "baz"})76// return parse(foo[bar], [{bla:"baz"}])77// return parse(foo, {bar:[{bla:"baz"}]})78// return {foo:{bar:[{bla:"baz"}]}}79pieceParser = function (eq) {80 _yuitest_coverfunc("build/querystring-parse/querystring-parse.js", "pieceParser", 39);81_yuitest_coverline("build/querystring-parse/querystring-parse.js", 40);82return function parsePiece (key, val) {83 _yuitest_coverfunc("build/querystring-parse/querystring-parse.js", "parsePiece", 40);84_yuitest_coverline("build/querystring-parse/querystring-parse.js", 42);85var sliced, numVal, head, tail, ret;86 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 44);87if (arguments.length !== 2) {88 // key=val, called from the map/reduce89 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 46);90key = key.split(eq);91 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 47);92return parsePiece(93 QueryString.unescape(key.shift()),94 QueryString.unescape(key.join(eq))95 );96 }97 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 52);98key = key.replace(/^\s+|\s+$/g, '');99 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 53);100if (Y.Lang.isString(val)) {101 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 54);102val = val.replace(/^\s+|\s+$/g, '');103 // convert numerals to numbers104 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 56);105if (!isNaN(val)) {106 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 57);107numVal = +val;108 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 58);109if (val === numVal.toString(10)) {110 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 59);111val = numVal;112 }113 }114 }115 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 63);116sliced = /(.*)\[([^\]]*)\]$/.exec(key);117 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 64);118if (!sliced) {119 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 65);120ret = {};121 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 66);122if (key) {123 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 67);124ret[key] = val;125 }126 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 69);127return ret;128 }129 // ["foo[][bar][][baz]", "foo[][bar][]", "baz"]130 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 72);131tail = sliced[2];132 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 73);133head = sliced[1];134 // array: key[]=val135 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 76);136if (!tail) {137 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 77);138return parsePiece(head, [val]);139 }140 // obj: key[subkey]=val141 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 81);142ret = {};143 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 82);144ret[tail] = val;145 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 83);146return parsePiece(head, ret);147 };148},149// the reducer function that merges each query piece together into one set of params150mergeParams = function(params, addition) {151 _yuitest_coverfunc("build/querystring-parse/querystring-parse.js", "mergeParams", 88);152_yuitest_coverline("build/querystring-parse/querystring-parse.js", 89);153return (154 // if it's uncontested, then just return the addition.155 (!params) ? addition156 // if the existing value is an array, then concat it.157 : (Y.Lang.isArray(params)) ? params.concat(addition)158 // if the existing value is not an array, and either are not objects, arrayify it.159 : (!Y.Lang.isObject(params) || !Y.Lang.isObject(addition)) ? [params].concat(addition)160 // else merge them as objects, which is a little more complex161 : mergeObjects(params, addition)162 );163},164// Merge two *objects* together. If this is called, we've already ruled165// out the simple cases, and need to do the for-in business.166mergeObjects = function(params, addition) {167 _yuitest_coverfunc("build/querystring-parse/querystring-parse.js", "mergeObjects", 103);168_yuitest_coverline("build/querystring-parse/querystring-parse.js", 104);169for (var i in addition) {170 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 105);171if (i && addition.hasOwnProperty(i)) {172 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 106);173params[i] = mergeParams(params[i], addition[i]);174 }175 }176 _yuitest_coverline("build/querystring-parse/querystring-parse.js", 109);177return params;178};179/**180 * Provides Y.QueryString.parse method to accept Query Strings and return native181 * JavaScript objects.182 *183 * @module querystring184 * @submodule querystring-parse185 * @for QueryString186 * @method parse187 * @param qs {String} Querystring to be parsed into an object.188 * @param sep {String} (optional) Character that should join param k=v pairs together. Default: "&"189 * @param eq {String} (optional) Character that should join keys to their values. Default: "="190 * @public191 * @static192 */193_yuitest_coverline("build/querystring-parse/querystring-parse.js", 126);194QueryString.parse = function (qs, sep, eq) {195 // wouldn't Y.Array(qs.split()).map(pieceParser(eq)).reduce(mergeParams) be prettier?196 _yuitest_coverfunc("build/querystring-parse/querystring-parse.js", "parse", 126);197_yuitest_coverline("build/querystring-parse/querystring-parse.js", 128);198return Y.Array.reduce(199 Y.Array.map(200 qs.split(sep || "&"),201 pieceParser(eq || "=")202 ),203 {},204 mergeParams205 );206};207/**208 * Provides Y.QueryString.unescape method to be able to override default decoding209 * method. This is important in cases where non-standard delimiters are used, if210 * the delimiters would not normally be handled properly by the builtin211 * (en|de)codeURIComponent functions.212 * Default: replace "+" with " ", and then decodeURIComponent behavior.213 * @module querystring214 * @submodule querystring-parse215 * @for QueryString216 * @method unescape217 * @param s {String} String to be decoded.218 * @public219 * @static220 **/221_yuitest_coverline("build/querystring-parse/querystring-parse.js", 152);222QueryString.unescape = function (s) {223 _yuitest_coverfunc("build/querystring-parse/querystring-parse.js", "unescape", 152);224_yuitest_coverline("build/querystring-parse/querystring-parse.js", 153);225return decodeURIComponent(s.replace(/\+/g, ' '));226};...
querystring-stringify-coverage.js
Source:querystring-stringify-coverage.js
1/*2YUI 3.7.3 (build 5687)3Copyright 2012 Yahoo! Inc. All rights reserved.4Licensed under the BSD License.5http://yuilibrary.com/license/6*/7if (typeof _yuitest_coverage == "undefined"){8 _yuitest_coverage = {};9 _yuitest_coverline = function(src, line){10 var coverage = _yuitest_coverage[src];11 if (!coverage.lines[line]){12 coverage.calledLines++;13 }14 coverage.lines[line]++;15 };16 _yuitest_coverfunc = function(src, name, line){17 var coverage = _yuitest_coverage[src],18 funcId = name + ":" + line;19 if (!coverage.functions[funcId]){20 coverage.calledFunctions++;21 }22 coverage.functions[funcId]++;23 };24}25_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"] = {26 lines: {},27 functions: {},28 coveredLines: 0,29 calledLines: 0,30 coveredFunctions: 0,31 calledFunctions: 0,32 path: "build/querystring-stringify/querystring-stringify.js",33 code: []34};35_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].code=["YUI.add('querystring-stringify', function (Y, NAME) {","","/**"," * Provides Y.QueryString.stringify method for converting objects to Query Strings."," *"," * @module querystring"," * @submodule querystring-stringify"," * @for QueryString"," * @static"," */","","var QueryString = Y.namespace(\"QueryString\"),"," stack = [],"," L = Y.Lang;","","/**"," * Provides Y.QueryString.escape method to be able to override default encoding"," * method. This is important in cases where non-standard delimiters are used, if"," * the delimiters would not normally be handled properly by the builtin"," * (en|de)codeURIComponent functions."," * Default: encodeURIComponent"," * @module querystring"," * @submodule querystring-stringify"," * @for QueryString"," * @static"," **/","QueryString.escape = encodeURIComponent;","","/**"," * <p>Converts an arbitrary value to a Query String representation.</p>"," *"," * <p>Objects with cyclical references will trigger an exception.</p>"," *"," * @method stringify"," * @public"," * @param obj {Variant} any arbitrary value to convert to query string"," * @param cfg {Object} (optional) Configuration object. The three"," * supported configurations are:"," * <ul><li>sep: When defined, the value will be used as the key-value"," * separator. The default value is \"&\".</li>"," * <li>eq: When defined, the value will be used to join the key to"," * the value. The default value is \"=\".</li>"," * <li>arrayKey: When set to true, the key of an array will have the"," * '[]' notation appended to the key. The default value is false."," * </li></ul>"," * @param name {String} (optional) Name of the current key, for handling children recursively."," * @static"," */","QueryString.stringify = function (obj, c, name) {"," var begin, end, i, l, n, s,"," sep = c && c.sep ? c.sep : \"&\","," eq = c && c.eq ? c.eq : \"=\","," aK = c && c.arrayKey ? c.arrayKey : false;",""," if (L.isNull(obj) || L.isUndefined(obj) || L.isFunction(obj)) {"," return name ? QueryString.escape(name) + eq : '';"," }",""," if (L.isBoolean(obj) || Object.prototype.toString.call(obj) === '[object Boolean]') {"," obj =+ obj;"," }",""," if (L.isNumber(obj) || L.isString(obj)) {"," return QueryString.escape(name) + eq + QueryString.escape(obj);"," }",""," if (L.isArray(obj)) {"," s = [];"," name = aK ? name + '[]' : name;"," l = obj.length;"," for (i = 0; i < l; i++) {"," s.push( QueryString.stringify(obj[i], c, name) );"," }",""," return s.join(sep);"," }"," // now we know it's an object.",""," // Check for cyclical references in nested objects"," for (i = stack.length - 1; i >= 0; --i) {"," if (stack[i] === obj) {"," throw new Error(\"QueryString.stringify. Cyclical reference\");"," }"," }",""," stack.push(obj);"," s = [];"," begin = name ? name + '[' : '';"," end = name ? ']' : '';"," for (i in obj) {"," if (obj.hasOwnProperty(i)) {"," n = begin + i + end;"," s.push(QueryString.stringify(obj[i], c, n));"," }"," }",""," stack.pop();"," s = s.join(sep);"," if (!s && name) {"," return name + \"=\";"," }",""," return s;","};","","","}, '3.7.3', {\"requires\": [\"yui-base\"]});"];36_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].lines = {"1":0,"12":0,"27":0,"49":0,"50":0,"55":0,"56":0,"59":0,"60":0,"63":0,"64":0,"67":0,"68":0,"69":0,"70":0,"71":0,"72":0,"75":0,"80":0,"81":0,"82":0,"86":0,"87":0,"88":0,"89":0,"90":0,"91":0,"92":0,"93":0,"97":0,"98":0,"99":0,"100":0,"103":0};37_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].functions = {"stringify:49":0,"(anonymous 1):1":0};38_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].coveredLines = 34;39_yuitest_coverage["build/querystring-stringify/querystring-stringify.js"].coveredFunctions = 2;40_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 1);41YUI.add('querystring-stringify', function (Y, NAME) {42/**43 * Provides Y.QueryString.stringify method for converting objects to Query Strings.44 *45 * @module querystring46 * @submodule querystring-stringify47 * @for QueryString48 * @static49 */50_yuitest_coverfunc("build/querystring-stringify/querystring-stringify.js", "(anonymous 1)", 1);51_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 12);52var QueryString = Y.namespace("QueryString"),53 stack = [],54 L = Y.Lang;55/**56 * Provides Y.QueryString.escape method to be able to override default encoding57 * method. This is important in cases where non-standard delimiters are used, if58 * the delimiters would not normally be handled properly by the builtin59 * (en|de)codeURIComponent functions.60 * Default: encodeURIComponent61 * @module querystring62 * @submodule querystring-stringify63 * @for QueryString64 * @static65 **/66_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 27);67QueryString.escape = encodeURIComponent;68/**69 * <p>Converts an arbitrary value to a Query String representation.</p>70 *71 * <p>Objects with cyclical references will trigger an exception.</p>72 *73 * @method stringify74 * @public75 * @param obj {Variant} any arbitrary value to convert to query string76 * @param cfg {Object} (optional) Configuration object. The three77 * supported configurations are:78 * <ul><li>sep: When defined, the value will be used as the key-value79 * separator. The default value is "&".</li>80 * <li>eq: When defined, the value will be used to join the key to81 * the value. The default value is "=".</li>82 * <li>arrayKey: When set to true, the key of an array will have the83 * '[]' notation appended to the key. The default value is false.84 * </li></ul>85 * @param name {String} (optional) Name of the current key, for handling children recursively.86 * @static87 */88_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 49);89QueryString.stringify = function (obj, c, name) {90 _yuitest_coverfunc("build/querystring-stringify/querystring-stringify.js", "stringify", 49);91_yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 50);92var begin, end, i, l, n, s,93 sep = c && c.sep ? c.sep : "&",94 eq = c && c.eq ? c.eq : "=",95 aK = c && c.arrayKey ? c.arrayKey : false;96 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 55);97if (L.isNull(obj) || L.isUndefined(obj) || L.isFunction(obj)) {98 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 56);99return name ? QueryString.escape(name) + eq : '';100 }101 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 59);102if (L.isBoolean(obj) || Object.prototype.toString.call(obj) === '[object Boolean]') {103 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 60);104obj =+ obj;105 }106 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 63);107if (L.isNumber(obj) || L.isString(obj)) {108 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 64);109return QueryString.escape(name) + eq + QueryString.escape(obj);110 }111 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 67);112if (L.isArray(obj)) {113 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 68);114s = [];115 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 69);116name = aK ? name + '[]' : name;117 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 70);118l = obj.length;119 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 71);120for (i = 0; i < l; i++) {121 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 72);122s.push( QueryString.stringify(obj[i], c, name) );123 }124 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 75);125return s.join(sep);126 }127 // now we know it's an object.128 // Check for cyclical references in nested objects129 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 80);130for (i = stack.length - 1; i >= 0; --i) {131 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 81);132if (stack[i] === obj) {133 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 82);134throw new Error("QueryString.stringify. Cyclical reference");135 }136 }137 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 86);138stack.push(obj);139 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 87);140s = [];141 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 88);142begin = name ? name + '[' : '';143 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 89);144end = name ? ']' : '';145 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 90);146for (i in obj) {147 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 91);148if (obj.hasOwnProperty(i)) {149 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 92);150n = begin + i + end;151 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 93);152s.push(QueryString.stringify(obj[i], c, n));153 }154 }155 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 97);156stack.pop();157 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 98);158s = s.join(sep);159 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 99);160if (!s && name) {161 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 100);162return name + "=";163 }164 _yuitest_coverline("build/querystring-stringify/querystring-stringify.js", 103);165return s;166};...
querystring-parse-simple-coverage.js
Source:querystring-parse-simple-coverage.js
1/*2YUI 3.7.3 (build 5687)3Copyright 2012 Yahoo! Inc. All rights reserved.4Licensed under the BSD License.5http://yuilibrary.com/license/6*/7if (typeof _yuitest_coverage == "undefined"){8 _yuitest_coverage = {};9 _yuitest_coverline = function(src, line){10 var coverage = _yuitest_coverage[src];11 if (!coverage.lines[line]){12 coverage.calledLines++;13 }14 coverage.lines[line]++;15 };16 _yuitest_coverfunc = function(src, name, line){17 var coverage = _yuitest_coverage[src],18 funcId = name + ":" + line;19 if (!coverage.functions[funcId]){20 coverage.calledFunctions++;21 }22 coverage.functions[funcId]++;23 };24}25_yuitest_coverage["build/querystring-parse-simple/querystring-parse-simple.js"] = {26 lines: {},27 functions: {},28 coveredLines: 0,29 calledLines: 0,30 coveredFunctions: 0,31 calledFunctions: 0,32 path: "build/querystring-parse-simple/querystring-parse-simple.js",33 code: []34};35_yuitest_coverage["build/querystring-parse-simple/querystring-parse-simple.js"].code=["YUI.add('querystring-parse-simple', function (Y, NAME) {","","// @TODO this looks like we are requiring the user to extract the querystring","// portion of the url, which isn't good. The majority use case will be to","// extract querystring from the document configured for this YUI instance.","// This should be the default if qs is not supplied.","","/*global Y */","/**"," * <p>Provides Y.QueryString.stringify method for converting objects to Query Strings."," * This is a simpler implementation than the full querystring-stringify.</p>"," * <p>Because some things may require basic query string escaping functionality,"," * this module provides the bare minimum functionality (decoding a hash of simple values),"," * without the additional support for arrays, objects, and so on.</p>"," * <p>This provides a friendly way to deserialize basic query strings, without necessitating"," * a lot of code for simple use-cases.</p>"," *"," * @module querystring"," * @submodule querystring-parse-simple"," * @for QueryString"," * @static"," */","","var QueryString = Y.namespace(\"QueryString\");","","/**"," * Provides Y.QueryString.parse method to accept Query Strings and return native"," * JavaScript objects."," *"," * @module querystring"," * @submodule querystring-parse"," * @for QueryString"," * @method parse"," * @param qs {String} Querystring to be parsed into an object."," * @param sep {String} (optional) Character that should join param k=v pairs together. Default: \"&\""," * @param eq {String} (optional) Character that should join keys to their values. Default: \"=\""," * @public"," * @static"," */","QueryString.parse = function (qs, sep, eq) {"," sep = sep || \"&\";"," eq = eq || \"=\";"," for ("," var obj = {},"," i = 0,"," pieces = qs.split(sep),"," l = pieces.length,"," tuple;"," i < l;"," i ++"," ) {"," tuple = pieces[i].split(eq);"," if (tuple.length > 0) {"," obj[QueryString.unescape(tuple.shift())] = QueryString.unescape(tuple.join(eq));"," }"," }"," return obj;","};","","/**"," * Provides Y.QueryString.unescape method to be able to override default decoding"," * method. This is important in cases where non-standard delimiters are used, if"," * the delimiters would not normally be handled properly by the builtin"," * (en|de)codeURIComponent functions."," * Default: replace \"+\" with \" \", and then decodeURIComponent behavior."," * @module querystring"," * @submodule querystring-parse"," * @for QueryString"," * @method unescape"," * @param s {String} String to be decoded."," * @public"," * @static"," **/","QueryString.unescape = function (s) {"," return decodeURIComponent(s.replace(/\\+/g, ' '));","};","","","}, '3.7.3', {\"requires\": [\"yui-base\"]});"];36_yuitest_coverage["build/querystring-parse-simple/querystring-parse-simple.js"].lines = {"1":0,"24":0,"40":0,"41":0,"42":0,"43":0,"52":0,"53":0,"54":0,"57":0,"74":0,"75":0};37_yuitest_coverage["build/querystring-parse-simple/querystring-parse-simple.js"].functions = {"parse:40":0,"unescape:74":0,"(anonymous 1):1":0};38_yuitest_coverage["build/querystring-parse-simple/querystring-parse-simple.js"].coveredLines = 12;39_yuitest_coverage["build/querystring-parse-simple/querystring-parse-simple.js"].coveredFunctions = 3;40_yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 1);41YUI.add('querystring-parse-simple', function (Y, NAME) {42// @TODO this looks like we are requiring the user to extract the querystring43// portion of the url, which isn't good. The majority use case will be to44// extract querystring from the document configured for this YUI instance.45// This should be the default if qs is not supplied.46/*global Y */47/**48 * <p>Provides Y.QueryString.stringify method for converting objects to Query Strings.49 * This is a simpler implementation than the full querystring-stringify.</p>50 * <p>Because some things may require basic query string escaping functionality,51 * this module provides the bare minimum functionality (decoding a hash of simple values),52 * without the additional support for arrays, objects, and so on.</p>53 * <p>This provides a friendly way to deserialize basic query strings, without necessitating54 * a lot of code for simple use-cases.</p>55 *56 * @module querystring57 * @submodule querystring-parse-simple58 * @for QueryString59 * @static60 */61_yuitest_coverfunc("build/querystring-parse-simple/querystring-parse-simple.js", "(anonymous 1)", 1);62_yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 24);63var QueryString = Y.namespace("QueryString");64/**65 * Provides Y.QueryString.parse method to accept Query Strings and return native66 * JavaScript objects.67 *68 * @module querystring69 * @submodule querystring-parse70 * @for QueryString71 * @method parse72 * @param qs {String} Querystring to be parsed into an object.73 * @param sep {String} (optional) Character that should join param k=v pairs together. Default: "&"74 * @param eq {String} (optional) Character that should join keys to their values. Default: "="75 * @public76 * @static77 */78_yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 40);79QueryString.parse = function (qs, sep, eq) {80 _yuitest_coverfunc("build/querystring-parse-simple/querystring-parse-simple.js", "parse", 40);81_yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 41);82sep = sep || "&";83 _yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 42);84eq = eq || "=";85 _yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 43);86for (87 var obj = {},88 i = 0,89 pieces = qs.split(sep),90 l = pieces.length,91 tuple;92 i < l;93 i ++94 ) {95 _yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 52);96tuple = pieces[i].split(eq);97 _yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 53);98if (tuple.length > 0) {99 _yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 54);100obj[QueryString.unescape(tuple.shift())] = QueryString.unescape(tuple.join(eq));101 }102 }103 _yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 57);104return obj;105};106/**107 * Provides Y.QueryString.unescape method to be able to override default decoding108 * method. This is important in cases where non-standard delimiters are used, if109 * the delimiters would not normally be handled properly by the builtin110 * (en|de)codeURIComponent functions.111 * Default: replace "+" with " ", and then decodeURIComponent behavior.112 * @module querystring113 * @submodule querystring-parse114 * @for QueryString115 * @method unescape116 * @param s {String} String to be decoded.117 * @public118 * @static119 **/120_yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 74);121QueryString.unescape = function (s) {122 _yuitest_coverfunc("build/querystring-parse-simple/querystring-parse-simple.js", "unescape", 74);123_yuitest_coverline("build/querystring-parse-simple/querystring-parse-simple.js", 75);124return decodeURIComponent(s.replace(/\+/g, ' '));125};...
Using AI Code Generation
1const querystring = require('querystring');2const qs = querystring.parse('foo=bar&baz=qux&baz=quux&corge');3console.log(qs);4const querystring = require('querystring');5const qs = querystring.parse('foo=bar&baz=qux&baz=quux&corge');6console.log(qs);7const querystring = require('querystring');8const qs = querystring.parse('foo=bar&baz=qux&baz=quux&corge');9console.log(qs);10const querystring = require('querystring');11const qs = querystring.parse('foo=bar&baz=qux&baz=quux&corge');12console.log(qs);13const querystring = require('querystring');14const qs = querystring.parse('foo=bar&baz=qux&baz=quux&corge');15console.log(qs);16const querystring = require('querystring');17const qs = querystring.parse('foo=bar&baz=qux&baz=quux&corge');18console.log(qs);19const querystring = require('querystring');20const qs = querystring.parse('foo=bar&baz=qux&baz=quux&corge');21console.log(qs);22const querystring = require('querystring');23const qs = querystring.parse('foo=bar&baz=qux&baz=quux&corge');24console.log(qs);25const querystring = require('querystring');26const qs = querystring.parse('foo=bar&baz=qux&baz
Using AI Code Generation
1const { querystring } = require('fast-check');2console.log(querystring.stringify({ a: 1, b: 2 }));3console.log(querystring.parse('a=1&b=2'));4const { querystring } = require('fast-check-monorepo');5console.log(querystring.stringify({ a: 1, b: 2 }));6console.log(querystring.parse('a=1&b=2'));7{ a: '1', b: '2' }8{ a: '1', b: '2' }9{ a: '1', b: '2' }10{ a: '1', b: '2' }
Using AI Code Generation
1const { querystring } = require('fast-check-monorepo');2const result = querystring.parse('a=1&b=2');3console.log(result);4const { querystring } = require('fast-check-monorepo');5const result = querystring.stringify({ a: '1', b: '2' });6console.log(result);7const { querystring } = require('fast-check-monorepo');8const result = querystring.escape('a=1&b=2');9console.log(result);10const { querystring } = require('fast-check-monorepo');11const result = querystring.unescape('a%3D1%26b%3D2');12console.log(result);13const { querystring } = require('fast-check-monorepo');14const result = querystring.decode('a=1&b=2');15console.log(result);16const { querystring } = require('fast-check-monorepo');17const result = querystring.encode({ a: '1', b: '2' });18console.log(result);19const { querystring } = require('fast-check-monorepo');20const result = querystring.encode({ a: '1', b: '2' }, ';', ':');21console.log(result);22const { querystring }
Using AI Code Generation
1const fc = require('fast-check')2const myArbitrary = fc.string()3fc.assert(fc.property(myArbitrary, s => s.length <= 10))4const fc = require('fast-check')5const myArbitrary = fc.string()6fc.assert(fc.property(myArbitrary, s => s.length <= 10))7const fc = require('fast-check')8const myArbitrary = fc.string()9fc.assert(fc.property(myArbitrary, s => s.length <= 10))10const fc = require('fast-check')11const myArbitrary = fc.string()12fc.assert(fc.property(myArbitrary, s => s.length <= 10))13const fc = require('fast-check')14const myArbitrary = fc.string()15fc.assert(fc.property(myArbitrary, s => s.length <= 10))16const fc = require('fast-check')17const myArbitrary = fc.string()18fc.assert(fc.property(myArbitrary, s => s.length <= 10))19const fc = require('fast-check')20const myArbitrary = fc.string()21fc.assert(fc.property(myArbitrary, s => s.length <= 10))22const fc = require('fast-check')23const myArbitrary = fc.string()24fc.assert(fc.property(myArbitrary, s => s.length <= 10))25const fc = require('fast-check')26const myArbitrary = fc.string()27fc.assert(fc.property(myArbitrary, s => s.length <= 10))28const fc = require('fast-check')29const myArbitrary = fc.string()30fc.assert(fc.property(my
Using AI Code Generation
1const { check, gen } = require("fast-check");2const { querystring } = require("fast-check-monorepo");3const isQuerystring = querystring();4check(gen.string, isQuerystring);5const { check, gen } = require("fast-check");6const { querystring } = require("fast-check-monorepo");7const isQuerystring = querystring();8check(gen.string, isQuerystring);
Using AI Code Generation
1const querystring = require('querystring');2var fastCheck = require('fast-check-monorepo');3var test = require('tape');4test('test querystring', function (t) {5 t.plan(1);6 var params = querystring.parse('foo=bar&baz=quux&baz=quuux&corge');7 t.deepEqual(params, { foo: 'bar', baz: ['quux', 'quuux'], corge: '' });8});9test('test fast-check', function (t) {10 t.plan(1);11 var fc = fastCheck.default;12 t.equal(fc, fastCheck.default);13});14var fastCheck = require('fast-check-monorepo');15var test = require('tape');16test('test fast-check', function (t) {17 t.plan(1);18 var fc = fastCheck.default;19 t.equal(fc, fastCheck.default);20});21var fastCheck = require('fast-check-monorepo');22var test = require('tape');23test('test fast-check', function (t) {24 t.plan(1);25 var fc = fastCheck.default;26 t.equal(fc, fastCheck.default);27});28var fastCheck = require('fast-check-monorepo');29var test = require('tape');30test('test fast-check', function (t) {31 t.plan(1);32 var fc = fastCheck.default;33 t.equal(fc, fastCheck.default);34});35var fastCheck = require('fast-check-monorepo');36var test = require('tape');37test('test fast-check', function (t) {38 t.plan(1);39 var fc = fastCheck.default;40 t.equal(fc, fastCheck.default);41});42var fastCheck = require('fast-check-monorepo');43var test = require('tape');44test('test fast-check', function (t) {45 t.plan(1);46 var fc = fastCheck.default;47 t.equal(fc, fastCheck.default);48});
Using AI Code Generation
1const { testProp, fc } = require('fast-check');2testProp('should always fail', [fc.string()], (a) => {3 return a.length > 5;4});5const { testProp, fc } = require('fast-check');6testProp('should always fail', [fc.string()], (a) => {7 return a.length > 5;8});9const { testProp, fc } = require('fast-check');10testProp('should always fail', [fc.string()], (a) => {11 return a.length > 5;12});13const { testProp, fc } = require('fast-check');14testProp('should always fail', [fc.string()], (a) => {15 return a.length > 5;16});17const { testProp, fc } = require('fast-check');18testProp('should always fail', [fc.string()], (a) => {19 return a.length > 5;20});21const { testProp, fc } = require('fast-check');22testProp('should always fail', [fc.string()], (a) => {23 return a.length > 5;24});25const { testProp, fc } = require('fast-check');26testProp('should always fail', [fc.string()], (a) => {27 return a.length > 5;28});29const { testProp, fc } = require('fast-check');30testProp('should always fail', [fc.string()], (a) => {31 return a.length > 5;32});33const { testProp, fc } = require('fast-check');34testProp('should always fail', [fc.string()], (a
Using AI Code Generation
1const { check, gen } = require('fast-check')2const querystring = require('querystring')3const URLSearchParams = require('url').URLSearchParams4const { URLSearchParams: URLSearchParamsPolyfill } = require('fast-check-monorepo')5const genURLSearchParams = () => {6 .record(gen.string(), gen.string())7 .map((record) => {8 const params = new URLSearchParams()9 for (const key in record) {10 params.append(key, record[key])11 }12 })13 .noShrink()14}15const genURLSearchParamsPolyfill = () => {16 .record(gen.string(), gen.string())17 .map((record) => {18 const params = new URLSearchParamsPolyfill()19 for (const key in record) {20 params.append(key, record[key])21 }22 })23 .noShrink()24}25const genURLSearchParamsAndPolyfill = () => {26 .tuple(genURLSearchParams(), genURLSearchParamsPolyfill())27 .noShrink()28}29describe('URLSearchParams', () => {30 it('should behave as the native URLSearchParams', () => {31 check(32 genURLSearchParamsAndPolyfill(),33 ([native, polyfill]) => {34 expect(native.toString()).toEqual(polyfill.toString())35 expect(Array.from(native)).toEqual(Array.from(polyfill))36 expect(Array.from(native.entries())).toEqual(Array.from(polyfill.entries()))37 expect(Array.from(native.keys())).toEqual(Array.from(polyfill.keys()))38 expect(Array.from(native.values())).toEqual(Array.from(polyfill.values()))39 expect(native.sort()).toEqual(polyfill.sort())40 expect(native.get('a')).toEqual(polyfill.get('a'))41 expect(native.getAll('a')).toEqual(polyfill.getAll('a'))42 expect(native.has('a')).toEqual(polyfill.has('a'))43 expect(native.append('a', 'b')).toEqual(polyfill.append('a', 'b'))44 expect(native.set('a', 'b')).toEqual(polyfill.set('a', 'b'))45 expect(native.delete('a')).toEqual(polyfill.delete('a'))46 expect(native.toString()).toEqual(polyfill.toString())47 expect(Array.from(native)).toEqual(Array.from(polyfill))48 expect(Array.from(native.entries())).toEqual(Array.from(polyfill.entries
Using AI Code Generation
1const { check, gen } = require('fast-check');2const { querystring } = require('fast-check-monorepo');3querystring(gen.array(gen.string()), (qs) => {4 const obj = qs.split('&').reduce((acc, pair) => {5 const [k, v] = pair.split('=');6 acc[k] = v;7 return acc;8 }, {});9 const qs2 = Object.entries(obj).map(([k, v]) => `${k}=${v}`).join('&');10 return qs === qs2;11});12const { check, gen } = require('fast-check');13const { querystring } = require('fast-check-monorepo');14querystring(gen.array(gen.string()), (qs) => {15 const obj = qs.split('&').reduce((acc, pair) => {16 const [k, v] = pair.split('=');17 acc[k] = v;18 return acc;19 }, {});20 const qs2 = Object.entries(obj).map(([k, v]) => `${k}=${v}`).join('&');21 return qs === qs2;22});23const { check, gen } = require('fast-check');24const { querystring } = require('fast-check-monorepo');25querystring(gen.array(gen.string()), (qs) => {26 const obj = qs.split('&').reduce((acc, pair) => {27 const [k, v] = pair.split('=');28 acc[k] = v;29 return acc;30 }, {});31 const qs2 = Object.entries(obj).map(([k, v]) => `${k}=${v}`).join('&');32 return qs === qs2;33});34const { check, gen } = require('fast-check');35const { querystring } = require('fast-check-monorepo');36querystring(gen.array(gen.string()), (qs) => {37 const obj = qs.split('&').reduce((acc, pair) => {38 const [k, v] = pair.split('=');39 acc[k] = v;40 return acc;41 }, {});42 const qs2 = Object.entries(obj).map(([k, v]) =>
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!