How to use objectToArray method in Playwright Internal

Best JavaScript code snippet using playwright-internal

TourMLParser.js

Source:TourMLParser.js Github

copy

Full Screen

...33 if (!_.isUndefined(tour)) {34 tours.push(tour);35 }36 } else if(tourML.tourSet && tourML.tourSet.tourMLRef) { // TourSet w/ external tours37 var tourRefs = TapAPI.helper.objectToArray(tourML.tourSet.tourMLRef);38 len = tourRefs.length;39 // TapAPI.tours.toursToParse += len;// if this is a tourset give the tour collection a length40 for(i = 0; i < len; i++) {41 this.addTourToMap(tourRefs[i].uri, tourML.uri);42 //check modified date before requesting tourml from server43 tour = TapAPI.tours.cache.where({tourUri:tourRefs[i].uri});44 if (tour.length > 0 && Date.parse(tourRefs[i].lastModified) <= Date.parse(tour[0].get('lastModified'))) {45 tours.push(tour[0]);46 } else {47 // also increment async counter48 TapAPI.tours.tourmlRequests++;49 TapAPI.helper.loadXMLDoc(tourRefs[i].uri);50 }51 }52 } else if(tourML.tourSet && tourML.tourSet.tour) { // TourSet w/ tours as children elements53 len = tourML.tourSet.tour.length;54 for(i = 0; i < len; i++) {55 tour = this.parseTour(tourML.tourSet.tour[i], tourML.uri);56 if (!_.isUndefined(tour)) {57 tours.push(tour);58 }59 }60 }61 // decrement async counter62 TapAPI.tours.tourmlRequests--;63 Backbone.trigger('tap.tourml.parsed', tours);64 },65 parseTourMLError : function (response) {66 TapAPI.tours.tourmlRequests--;67 Backbone.trigger('tap.tourml.parsed', []);68 },69 parseTour: function(data, tourUri) {70 this.trigger('willParseTour');71 var toursetUri = this.tourMap[tourUri];72 var tourOrder = _.indexOf(this.tourOrder, tourUri);73 // check to see if the tour has been updated74 var tour = TapAPI.tours.cache.get(data.id);75 if (tour && Date.parse(data.lastModified) <= Date.parse(tour.get('lastModified'))) return tour;76 var stops = [],77 assets = [];78 //clean stop data for consistant formatting79 data.stop = TapAPI.helper.objectToArray(data.stop);80 //if no stops do not continue with this tour81 if (_.isUndefined(data.stop)) {82 return undefined;83 }84 // create new tour85 tour = new TapAPI.classes.models.TourModel({86 id: data.id,87 toursetUri: toursetUri,88 tourUri: tourUri,89 tourOrder: tourOrder,90 appResource: data.tourMetadata && data.tourMetadata.appResource ? TapAPI.helper.objectToArray(data.tourMetadata.appResource) : undefined,91 connection: data.connection ? TapAPI.helper.objectToArray(data.connection) : undefined,92 description: data.tourMetadata && data.tourMetadata.description ? TapAPI.helper.objectToArray(data.tourMetadata.description) : undefined,93 lastModified: data.lastModified ? data.lastModified : undefined,94 propertySet: data.tourMetadata && data.tourMetadata.propertySet ? TapAPI.helper.objectToArray(data.tourMetadata.propertySet.property) : undefined,95 publishDate: data.tourMetadata && data.tourMetadata.publishDate ? TapAPI.helper.objectToArray(data.tourMetadata.publishDate) : undefined,96 rootStopRef: data.tourMetadata && data.tourMetadata.rootStopRef ? data.tourMetadata.rootStopRef : undefined,97 title: data.tourMetadata && data.tourMetadata.title ? TapAPI.helper.objectToArray(data.tourMetadata.title) : undefined98 });99 TapAPI.tours.create(tour);100 // create new instance of StopCollection101 var stopCollection = new TapAPI.classes.collections.StopCollection(null, data.id);102 // create new instance of AssetCollection103 var assetCollection = new TapAPI.classes.collections.AssetCollection(null, data.id);104 var i, j;105 // load tour models106 var connectionData = TapAPI.helper.objectToArray(data.connection);107 var numStops = data.stop.length;108 for (i = 0; i < numStops; i++) {109 this.trigger('willParseStop');110 var stop,111 outgoingConnections = [],112 incomingConnections = [];113 if(!_.isUndefined(data.connection)) {114 for(j = 0; j < connectionData.length; j++) {115 if(connectionData[j].srcId == data.stop[i].id) {116 outgoingConnections.push({priority: connectionData[j].priority, destId: connectionData[j].destId});117 }118 if (connectionData[j].destId == data.stop[i].id) {119 incomingConnections.push({srcId: connectionData[j].srcId});120 }121 }122 }123 stop = new TapAPI.classes.models.StopModel({124 id: data.stop[i].id,125 connection: outgoingConnections,126 incomingConnection: incomingConnections,127 view: data.stop[i].view,128 description: TapAPI.helper.objectToArray(data.stop[i].description),129 propertySet: data.stop[i].propertySet ? TapAPI.helper.objectToArray(data.stop[i].propertySet.property) : undefined,130 assetRef: TapAPI.helper.objectToArray(data.stop[i].assetRef),131 title: TapAPI.helper.objectToArray(data.stop[i].title),132 tour: data.id133 });134 stopCollection.create(stop);135 stops.push(stop);136 this.trigger('didParseStop', stop, tour);137 }138 // load asset models139 data.asset = TapAPI.helper.objectToArray(data.asset);140 var numAssets = data.asset.length;141 for (i = 0; i < numAssets; i++) {142 this.trigger('willParseAsset');143 var asset;144 // modifiy source propertySet child to match similar elements145 if(data.asset[i].source) {146 data.asset[i].source = TapAPI.helper.objectToArray(data.asset[i].source);147 var numSources = data.asset[i].source.length;148 for (j = 0; j < numSources; j++) {149 if(data.asset[i].source[j].propertySet) {150 data.asset[i].source[j].propertySet = TapAPI.helper.objectToArray(data.asset[i].source[j].propertySet.property);151 }152 }153 }154 if(data.asset[i].content) {155 data.asset[i].content = TapAPI.helper.objectToArray(data.asset[i].content);156 var numContent = data.asset[i].content.length;157 for (j = 0; j < numContent; j++) {158 if(data.asset[i].content[j].propertySet) {159 data.asset[i].content[j].propertySet = TapAPI.helper.objectToArray(data.asset[i].content[j].propertySet.property);160 }161 }162 }163 asset = new TapAPI.classes.models.AssetModel({164 assetRights: TapAPI.helper.objectToArray(data.asset[i].assetRights),165 content: data.asset[i].content,166 id: data.asset[i].id,167 source: data.asset[i].source,168 propertySet: data.asset[i].propertySet ? TapAPI.helper.objectToArray(data.asset[i].propertySet.property) : undefined,169 type: data.asset[i].type170 });171 assetCollection.create(asset);172 assets.push(asset);173 this.trigger('didParseAsset', asset, tour);174 }175 // clear out the temporary models176 stopCollection.reset();177 assetCollection.reset();178 // attempt to fetch existing models.179 stopCollection.fetch();180 assetCollection.fetch();181 // create/update new stops and assets182 stopCollection.set(stops);...

Full Screen

Full Screen

offsiteSchemaHelpers.js

Source:offsiteSchemaHelpers.js Github

copy

Full Screen

1compareFields = function (o1, o2, f1="k", f2="t") {2 return {$and:[ {$eq:[ o1+'.'+f1, o2+'.'+f1 ]}, {$eq:[ o1+'.'+f2, o2+'.'+f2 ]} ]};3}4mergeObjects = function ( o1, o2) {5 /* in order to have the second object "win" we need to remove the fields of o2 from o1 */6 return {$arrayToObject:{$let:{7 vars:{o2:{$objectToArray:o2} },8 in:{$concatArrays:[9 {$filter:{10 input:{$objectToArray:o1},11 cond:{$not:{$in:["$$this.k", "$$o2.k"]} }12 }},13 "$$o2"14 ]}}}}15}16addValueToObject = function (o, f, val) {17 var ad={$add:[ {$ifNull:[o+'.'+f,0]}, {$ifNull:[val,0]} ]};18 var newo = { };19 newo[f]=ad;20 return {$mergeObjects: [ o, newo ]};21}22ifObject = function(x,y,z) { return {"$cond":[{$eq:[{$type:x},"object"]},y,z]}};23ifArray=function(x,y,z) { return {"$cond":[{$eq:[{$type:x},"array"]},y,z]}};24isNull=function(x) { return {$eq:[{$ifNull:[x, null]},null]}; };25getktvs = function(input) {26 var m={"$map":{}};27 m["$map"]["input"]=input;28 m["$map"]["as"]="f";29 m["$map"]["in"]={k:"$$f.k",t:{$type:"$$f.v"}, v:"$$f.v"};30 return m;31};32/* given type, value, figure out type and return appropriate thing */33mapTV = function(t, v, i) {34 if (i>3) return {t:t, v:v};35 i=i+1;36 return {"t":t, "v":{"$switch":37 { "branches":[38 {"case":{$eq:[t,"objectId"]} , "then": "objectId" },39 {"case":{$eq:[t,"string"]} , "then": {$strLenCP:v} },40 {"case":{$eq:[t,"null"]} , "then": "null"},41 {"case":{$eq:[t,"object"]} , "then": { properties: mapObject(v,i) } },42 {"case":{$eq:[t,"array"]} , "then": { items: mapArray(v, i)} },43 ],44 "default":"$$o.v"45 }46 }}47}48/* given k/t/v, change value, based on type */49mapValue = function(o,i) {50 if (i>3) return o;51 i=i+1;52 return {"$map":{"input":o, "as":"o", "in": {"k":"$$o.k", "t":"$$o.t", "v":{"$switch":53 { "branches":[54 {"case":{$eq:["$$o.t","objectId"]} , "then": "objectId" },55 {"case":{$eq:["$$o.t","string"]} , "then": {$strLenCP:"$$o.v"} },56 {"case":{$eq:["$$o.t","null"]} , "then": "null"},57 {"case":{$eq:["$$o.t","object"]} , "then": { properties: mapObject("$$o.v",i) } },58 {"case":{$eq:["$$o.t","array"]} , "then": { items: mapArray("$$o.v", i)} },59 ],60 "default":"$$o.v"61 }62 }}}}63}64mapObject = function (o, i) {65 if (i>3) return o;66 i=i+1;67 return mapValue(getktvs({$objectToArray:o}),i);68}69mapArray = function(a, i) {70 return {$map:{71 input: a,72 as: "a",73 in: ifObject("$$a",mapValue(getktvs({$objectToArray:"$$a"}),i),mapTV({$type:"$$a"},"$$a", i))}}74}75/* from input array of objects, concat given field */76merge = function(input, field) {77 return {$reduce: { input: {$map:{input:input, as: "m", in: "$$m."+field}},78 initialValue: [],79 in: {$concatArrays:["$$value","$$this"]}80 } }81};82getKeysAsArray = function(obj) {83 return {$map:{input:{$objectToArray:obj},as:"o",in:"$$o.k"}}84}85mergeObjects34 = function(o1, o2) {86 return {$arrayToObject:{$concatArrays:[ {$objectToArray:o1}, {$objectToArray:o2} ]}};87}88load("/Users/asya/github/bits-n-pieces/scripts/sortArray.js")89/* merge objects differentiating on "k" expects an array of objects of {k:x, v:y} */90smartMergeObjects = function(oos) {91 /* var ok1 = {$objectToArray:o1};92 var ok2 = {$objectToArray:o2};93 var both = {$concatArrays: [ ok1, ok2 ]};94 var sz = {$size:both};95 var input = {$range:[0,sz]}; */96 var oWithCount = {$map:{input:oos,in:{$mergeObjects:[{count:1},"$$this"]}}};97 var redArray = {$reduce:{98 initialValue: [ ],99 input: oWithCount,100 in: {$let:{ 101 vars: { t:"$$this", v:"$$value" }, 102 in:{$let:{ /* thisElem is the matching key element in $$value to $$this */103 vars:{thisElem:{$arrayElemAt:[{$filter:{input:"$$v", cond:{$eq:["$$t.k","$$this.k"]}}},0]}},104 in: {$cond:[105 {$in:["$$t.k","$$v.k"]},106 {$concatArrays:[107 /* all elements except the one we have now */108 {$filter:{input:"$$v", cond:{$ne:["$$t.k","$$this.k"]}}},109 [ {k: "$$t.k", 110 t: {$cond:[{$in:["$$t.t",{$ifNull:[ifArray("$$thisElem.t","$thisElem.t",["$$thisElem.t"]),[]]}]},111 "$$t.t",112 {$concatArrays:[ 113 ifArray("$$t.t","$$t.t",[ "$$t.t" ]), 114 ifArray("$$thisElem.t","$$thisElem.t",[ "$$thisElem.t" ]), 115 ]} ]},116 v: {$concatArrays:[ 117 ifArray("$$t.v","$$t.v",[ "$$t.v" ]), 118 ifArray("$$thisElem.v","$$thisElem.v",[ "$$thisElem.v" ]), 119 ]},120 count: {$add:[{$ifNull:["$$t.count",1]},{$ifNull:["$$thisElem.count",1]}]}121 } ]122 ]},123 {$concatArrays:["$$v", [ "$$t" ] ]}124 ]}125 }}126 }}127 }};128 return redArray;129}130/* given array of objects, merge them by "k", appending "t" and "v" fields and adding counts */131/* expected object shape: { k:"x", t:"y", v:any, count:1+ */132groupObjects = function(input) {133}134concatReduceArrays = function() {135 return {$concatArrays:[ "$$value", ifArray("$$this", "$$this", [ "$$this" ]) ]}136};137concatIfArray = function(input) {138 return {$cond:[139 {$eq:["array",{$type:input}]},140 {"$reduce": {141 input: input,142 initialValue: [],143 in: {$concatArrays:["$$value",ifArray("$$this","$$this",["$$this"])]}144 } },145 input146 ]}147};148flattenField = function(input) {149 return {$map:{input:input,as:"o",150 in:{k:"$$o.k", t:"$$o.t",v:{$cond:[151 {$eq:["object","$$o.t"]},"$$o.v",152 {$cond:[{$eq:["array","$$o.t"]},{items:concatIfArray("$$o.v.items")}, "$$o.v"153 ]} ]}}154 }};155}156db.testcoll.aggregate([ 157 {$project:{__o:mapValue(getktvs({$objectToArray:"$$ROOT"}),0)}}, 158 {$addFields:{159 __o:flattenField("$__o")160 }}161]).pretty()162foo = db.testcoll.count()163db.testcoll.aggregate([ 164 {$project:{p:mapValue(getktvs({$objectToArray:"$$ROOT"}),0)}}, 165 {$unwind:"$p"}, 166 {$group:{_id:{k:"$p.k",t:"$p.t"},count:{$sum:1},v:{$addToSet:"$p.v"}}}, 167 {$group:{ _id:"$_id.k", types: {$push:{t:"$_id.t",c:"$count"}}, total:{$sum:"$count"}, items:{$push:{$cond:[{$eq:["$_id.t","array"]},"$v",null]}}, properties:{$push:{$cond:[{$eq:["$_id.t","object"]},"$v",null]}} }}, 168 {$project:{_id:0, k:"$_id", "v.description":{$concat:["The ","$_id"," field"]}, "v.t" : {$cond:[{$eq:[{$size:"$types"},1]},{$arrayElemAt:["$types.t",0]},"$types.t"]}, "v.items": {$cond:[{$in:["array","$types.t"]},"$items.items", "$REMOVE"]}, "v.properties":{$cond:[{$in:["object","$types.t"]},"$properties.properties", "$REMOVE"]}, count:"$total" }}, 169 {$group:{_id:0, p:{$push:{k:"$k",v:"$v"}},required:{$push:{$cond:[{$eq:["$count", foo ]},"$k","$REMOVE"]}}}}, 170 {$project:{_id:0, _$schema:"json-schema/blah-blah",title:"sample1",type:"object",properties:{$arrayToObject:"$p"}}} ...

Full Screen

Full Screen

furrysurvey.js

Source:furrysurvey.js Github

copy

Full Screen

...8 });9 },10 objectToChartData: function (n, obj) {11 return obj.map(function(item) {12 item.values = utils.objectToArray(item.values)13 .map(function(yearItem) {14 return {15 key: yearItem.key,16 values: yearItem.values / n[item.key] * 10017 }18 });19 return item;20 });21 },22 mean: function(n, obj) {23 _.each(obj, function(year) {24 year.values = utils.objectToArray(year.values);25 });26 return {27 n: _.reduce(_.values(n), function(m, n) {28 return m + (isNaN(parseInt(n)) ? 0 : n);29 }) / 60,30 values: _.map(obj[0].values, function(item, index) {31 return _.reduce(obj, function(m, year) {32 m.values += year.values[index].values;33 return m;34 }, {key: item.key, values: 0});35 })36 };37 },38 flip: function(arr) {39 var flipped = [];40 arr[0].values.forEach(function(item, idx) {41 flipped.push(arr.map(function(subArr) {42 return subArr[idx];43 }));44 });45 return flipped;46 }47 };48 function chartAge(n, _chartData) {49 var chartData = _chartData.map(function(item) {50 item.values = utils.objectToArray(item.values)51 .reverse()52 .map(function(yearItem) {53 return {54 key: parseInt(item.key) - parseInt(yearItem.key),55 values: yearItem.values / n[item.key] * 10056 };57 });58 return item;59 });60 nv.addGraph(function() {61 var vis = nv.models.lineChart()62 .useInteractiveGuideline(true)63 .isArea(true)64 .x(function(d) { return d.key; })65 .y(function(d) { return d.values; });66 vis.yAxis67 .tickFormat(function(d) { return d.toPrecision(2) + '%' })68 .axisLabel("Percentage of respondents");69 vis.xAxis.axisLabel("Age in years");70 d3.select('#age svg')71 .datum(chartData)72 .transition().duration(500)73 .call(vis);74 nv.utils.windowResize(vis.update);75 return vis;76 });77 }78 function chartStacked(n, _chartData, id) {79 var chartData = _.map(_.keys(_chartData[_chartData.length - 1].values), function(key) {80 return { key: key, values: _.map(_chartData, function(year) {81 return [ isNaN(year.values[key]) ? 0 : year.values[key] / n[year.key] * 100, parseInt(year.key) ];82 }) };83 });84 nv.addGraph(function() {85 var vis = nv.models.stackedAreaChart()86 .useInteractiveGuideline(true)87 .style('expand')88 .showControls(false)89 .x(function(d) { return d[1]; })90 .y(function(d) { return d[0]; });91 vis.xAxis.tickFormat(function(d) { return d.toString(); });92 d3.select('#' + id + ' svg')93 .datum(chartData)94 .transition().duration(500)95 .call(vis);96 nv.utils.windowResize(vis.update);97 return vis;98 });99 }100 function chartPie(n, _chartData, id) {101 var means = utils.mean(n, utils.objectToChartData(n, utils.objectToArray(_chartData)));102 nv.addGraph(function() {103 var vis = nv.models.pieChart()104 .x(function(d) { return d.key; })105 .y(function(d) { return d.values; })106 .labelType('percent');107 d3.select('#' + id + ' svg')108 .datum(means.values)109 .transition().duration(500)110 .call(vis)111 nv.utils.windowResize(vis.update);112 return vis;113 })114 }115 function chartSexImportance(n, _chartData, id) {116 var means = utils.mean(n, utils.objectToChartData(n, utils.objectToArray(_chartData)));117 n.mean = means.n;118 _chartData.mean = means.values;119 var chartData = utils.objectToChartData(n, utils.objectToArray(_chartData));120 nv.addGraph(function() {121 var vis = nv.models.lineChart()122 .useInteractiveGuideline(true)123 .x(function(d) { return parseInt(d.key); })124 .y(function(d) { return d.values; });125 vis.yAxis126 .tickFormat(function(d) { return d.toPrecision(2) + '%'; })127 .axisLabel('Percentage of respondents');128 vis.xAxis.axisLabel('How sexual is furry - ' + id);129 d3.select('#sex_importance__' + id + ' svg')130 .datum(chartData)131 .transition().duration(500)132 .call(vis);133 nv.utils.windowResize(vis.update);134 return vis;135 });136 }137 chartPie(138 _data.n,139 utils.objectToArray(_data.furry_metadata.furry_status),140 'furry_status');141 chartAge(142 _data.n,143 utils.objectToArray(_data.demographics.age));144 chartPie(145 _data.n,146 utils.objectToArray(_data.demographics.gender_alignment),147 'gender_alignment')148 chartStacked(149 _data.n,150 utils.objectToArray(utils.objectToArray(_data.demographics.biological_sex)),151 'biological_sex');152 chartStacked(153 _data.n,154 utils.objectToArray(_data.demographics.gender_identity),155 'gender_identity');156 chartStacked(157 _data.n,158 utils.objectToArray(_data.demographics.sexual_orientation),159 'sexual_orientation');160 chartStacked(161 _data.n,162 utils.objectToArray(_data.demographics.race),163 'race');164 chartStacked(165 _data.n,166 utils.objectToArray(_data.demographics.political_views.social),167 'political_views__social');168 chartStacked(169 _data.n,170 utils.objectToArray(_data.demographics.political_views.economic),171 'political_views__economic');172 chartStacked(173 _data.n,174 utils.objectToArray(_data.demographics.relationship_status),175 'relationship');176 chartPie(177 _data.n,178 utils.objectToArray(_data.furry_metadata.partner_is_furry),179 'partner_is_furry');180 chartPie(181 _data.n,182 utils.objectToArray(_data.demographics.polyamory.sexuality),183 'polyamory__sexuality');184 chartPie(185 _data.n,186 utils.objectToArray(_data.demographics.polyamory.romantic),187 'polyamory__romantic');188 chartSexImportance(189 _data.n,190 _data.perception_of_fandom.importance_of_sex.self,191 'self');192 chartSexImportance(193 _data.n,194 _data.perception_of_fandom.importance_of_sex.others,195 'others');196 chartSexImportance(197 _data.n,198 _data.perception_of_fandom.importance_of_sex.public,199 'public');200};...

Full Screen

Full Screen

config.js

Source:config.js Github

copy

Full Screen

2var country = 'Singapore';3var locationSymbol = 'SG';4var db = require('./lib/database')5var logger = require('./lib/logger')6function objectToArray(obj) {7 if (Array.isArray(obj)) {8 return obj9 }10 var arr = []11 for (var groupid in obj) {12 if( obj.hasOwnProperty( groupid ) ) {13 arr.push(obj[groupid])14 }15 }16 return arr17}18module.exports = function(callback) {19 db.once('value', function(snapshotAll) {20 var snapshot = snapshotAll.val()21 return callback({22 originalDB: snapshot,23 location: city,24 city: city,25 country: country,26 symbol: locationSymbol,27 api_version: 'v1',28 apiUrl: 'https://webuild.sg/api/v1/',29 displayTimeformat: 'DD MMM YYYY, ddd, h:mm a',30 dateFormat: 'YYYY-MM-DD HH:mm Z',31 timezone: '+0800',32 timezoneInfo: 'Asia/Singapore',33 debug: process.env.NODE_ENV === 'development',34 calendarTitle: 'We Build SG Events',35 podcastApiUrl: 'http://webuildsg.github.io/live/api/v1/podcasts.json',36 domain: 'webuild.sg',37 facebookGroups : objectToArray(snapshot.facebookGroups),38 blacklistEvents: objectToArray(snapshot.blacklistEvents),39 whitelistEvents: objectToArray(snapshot.whitelistEvents),40 icsGroups: objectToArray(snapshot.icsGroups),41 whitelistGroups: objectToArray(snapshot.whitelistGroups),42 archives: {43 githubRepoFolder: 'webuildsg/data/',44 committer: {45 name: 'We Build SG Bot',46 email: 'webuildsg@gmail.com'47 }48 },49 ignoreWordsInDuplicateEvents: [50 "meetup", "group", "event",51 "centre", "center", "tower", "road", "boulevard", "ayer",52 "avenue", "ave",53 "building", "city",54 "jalan", "jln",55 "lane", "ln",56 "street", "st",57 "plaza", "town", "new",58 "level", "floor",59 "first",60 "second",61 "third",62 "jan", "january",63 "feb", "february",64 "mar", "march",65 "apr", "april",66 "may",67 "jun", "june",68 "jul", "july",69 "aug", "august",70 "sep", "sept", "september",71 "oct", "october",72 "nov", "november",73 "dec", "december",74 "-",75 "mon", "monday",76 "tue", "tues", "tuesday",77 "wed", "wednesday",78 "thu", "thurs", "thursday",79 "fri", "friday",80 "sat", "saturday",81 "sun", "sunday",82 "topic", "create", "talk", "session", "workshop", "tell", "share", "coding", "venue", "about",83 "speaker", "member",84 "a", "i", "will", "be", "who", "want", "or", "have", "if", "go", "of", "with", "from", "for",85 "the", "others", "another", "all", "which", "project",86 "your", "you", "our", "you\"re", "we\"re", "we\'re",87 "how","view","get","sponsor","thank","join",88 "please","into","also","over","see"89 ],90 auth0: {91 domain: 'webuildsg.auth0.com',92 clientId: process.env.WEBUILD_AUTH0_CLIENT_ID,93 clientSecret: process.env.WEBUILD_AUTH0_CLIENT_SECRET,94 clientToken: process.env.WEBUILD_AUTH0_CLIENT_TOKEN95 },96 githubParams: {97 version: '3.0.0',98 clientID: process.env.GITHUB_CLIENT_ID,99 clientSecret: process.env.GITHUB_CLIENT_SECRET,100 location: process.env.LOCATION || city,101 maxUsers: process.env.MAX_USERS || 1000,102 maxRepos: process.env.MAX_REPOS || 150,103 starLimit: process.env.STAR_LIMIT || 50,104 outfile: __dirname + '/cache.json'105 },106 meetupParams: {107 key: process.env.MEETUP_API_KEY,108 country: locationSymbol,109 state: locationSymbol,110 city: city,111 category_id: 34, // Tech category112 page: 500,113 fields: 'next_event',114 offset: 0,115 blacklistGroups: objectToArray(snapshot.meetupBlacklistGroups)116 },117 eventbriteParams: {118 token: process.env.EVENTBRITE_TOKEN,119 url: 'https://www.eventbriteapi.com/v3/events/search',120 venueUrl: 'https://www.eventbriteapi.com/v3/venues/',121 organizerUrl: 'https://www.eventbriteapi.com/v3/organizers/',122 categories: [123 '102',124 '119'125 ],126 blacklistOrganiserId: objectToArray(snapshot.eventbriteBlacklistOrganiserIds)127 }128 })129 })...

Full Screen

Full Screen

BarChart.spec.js

Source:BarChart.spec.js Github

copy

Full Screen

...5 data: {},6 width: 0,7 height: 0,8};9function objectToArray(objdata) {10 return _.map(_.keys(objdata), key => ({11 name: key,12 value: objdata[key],13 }));14}15describe('BarChart.vue', () => {16 let chart;17 describe('with only required props', () => {18 beforeEach(() => {19 const Constructor = Vue.extend(BarChart);20 chart = new Constructor({ propsData: props }).$mount();21 });22 test('the chart object should not be null', () => {23 expect(chart.chart).not.toBeNull();24 });25 test('the initial chart data should be empty', () => {26 expect(_.isEmpty(chart.chart.data())).toBeTruthy();27 });28 test('setting data creates categories on the chart object', () => {29 chart.setData({30 foo: objectToArray({ a: 1, b: 2, c: 3 }),31 bar: objectToArray({ a: 4, b: 5, c: 6 }),32 });33 const data = chart.chart.data();34 expect(data).toHaveLength(2);35 expect(data[0].id).toEqual('foo');36 expect(data[0].values).toHaveLength(3);37 expect(data[1].id).toEqual('bar');38 expect(data[1].values).toHaveLength(3);39 });40 test('setting new data with missing category removes absent category', () => {41 chart.setData({42 foo: objectToArray({ a: 1, b: 2, c: 3 }),43 bar: objectToArray({ a: 4, b: 5, c: 6 }),44 });45 chart.setData({46 foo: objectToArray({ a: 4, b: 8 }),47 });48 const data = chart.chart.data();49 expect(data).toHaveLength(1);50 expect(data[0].id).toEqual('foo');51 });52 });53 describe('with group legend', () => {54 beforeEach(() => {55 const Constructor = Vue.extend(BarChart);56 const propsWithLegend = {57 data: {},58 width: 0,59 height: 0,60 groupLegend: {61 foo: 'Foo',62 bar: 'Bar',63 },64 };65 chart = new Constructor({ propsData: propsWithLegend }).$mount();66 });67 test('setting data uses group keys to set categories', () => {68 chart.setData({69 foo: objectToArray({ a: 1, b: 2, c: 3 }),70 bar: objectToArray({ a: 4, b: 5, c: 6 }),71 });72 const data = chart.chart.data();73 expect(data).toHaveLength(2);74 expect(data[0].id).toEqual('foo');75 expect(data[0].values).toHaveLength(3);76 expect(data[1].id).toEqual('bar');77 expect(data[1].values).toHaveLength(3);78 });79 test('setting new data with missing category removes absent category', () => {80 chart.setData({81 foo: objectToArray({ a: 1, b: 2, c: 3 }),82 bar: objectToArray({ a: 4, b: 5, c: 6 }),83 });84 chart.setData({85 foo: objectToArray({ a: 1, b: 2, c: 3 }),86 });87 const data = chart.chart.data();88 expect(data).toHaveLength(1);89 expect(data[0].id).toEqual('foo');90 expect(data[0].values).toHaveLength(3);91 });92 });...

Full Screen

Full Screen

objecttoarray.js

Source:objecttoarray.js Github

copy

Full Screen

...14 fileLoader.load("objecttoarray", "library");15 done();16 });17 });18 suite("| __objectToArray()__", function() {19 /**20 * Test case for ObjectToArray.21 * 22 * @input objectToArray({a:1, b:2, c:3})23 * @expected [a:1, b:2, c:3] 24 */25 test("| Object with only named keys", function() {26 eval(fileLoader.getContent());27 var input = {a:1, b:2, c:3};28 var expected = [];29 expected.a = 1;30 expected.b = 2;31 expected.c = 3;32 var output = objectToArray(input);33 assert(expected instanceof Array);34 assert.deepEqual(output, expected);35 });36 /**37 * Test case for ObjectToArray.38 * 39 * @input objectToArray({'0':1, '1':2, '2':3})40 * @expected [1,2,3] 41 */42 test("| Object with only numerical keys", function() {43 eval(fileLoader.getContent());44 var input = {'0':1, '1':2, '2':3};45 var expected = [1,2,3];46 var output = objectToArray(input);47 assert(expected instanceof Array);48 assert.deepEqual(output, expected);49 });50 /**51 * Test case for ObjectToArray.52 * 53 * @input objectToArray({'0':1, '2':3, '1':2})54 * @expected [1,2,3] 55 */56 test("| Object with only numerical keys shuffled", function() {57 eval(fileLoader.getContent());58 var input = {'0':1, '2':3, '1':2};59 var expected = [1,2,3];60 61 var output = objectToArray(input);62 assert(expected instanceof Array);63 assert.deepEqual(output, expected);64 }); 65 /**66 * Test case for ObjectToArray.67 * 68 * @input objectToArray({'0':1, a:3, '1':2})69 * @expected [1, 2, a:3] 70 */71 test("| Object mixed keys", function() {72 eval(fileLoader.getContent());73 var input = {'0':1, a:3, '1':2};74 var expected = [1,2];75 expected.a = 3;76 77 var output = objectToArray(input);78 assert(expected instanceof Array);79 assert.deepEqual(output, expected);80 });81 });...

Full Screen

Full Screen

getters.js

Source:getters.js Github

copy

Full Screen

1/* eslint-disable */2function objectToArray(payload) {3 return Object.keys(payload).sort().map(index => payload[index])4}5function addAllDataToConstantTop(constantData, allData = [{id: '', name: '全部', description: '全部'}]) {6 return allData.concat(constantData)7}8export default {9 handleJobType({ constant }) {10 return constant ? addAllDataToConstantTop(objectToArray(constant.JobType)) || [] : [];11 },12 handleWorkPlace({ constant }) {13 return constant ? constant.WorkPlace|| [] : [];14 },15 handleRecruitType({ constant }) {16 return constant ? addAllDataToConstantTop(objectToArray(constant.RecruitType)) || [] : [];17 },18 handleGender({ constant }) {19 return constant ? objectToArray(constant.Gender) || [] : [];20 },21 handleScheduleState({ constant }) {22 return constant ? addAllDataToConstantTop(objectToArray(constant.ScheduleState)) || [] : [];23 },24 handleReviewType({ constant }) {25 return constant ? addAllDataToConstantTop(objectToArray(constant.ReviewType)) || [] : [];26 },27 handleNewsType({ constant }) {28 return constant ? addAllDataToConstantTop(objectToArray(constant.NewsType)) || [] : [];29 },30 handleEducationType({ constant }) {31 return constant ? objectToArray(constant.Education) || [] : [];32 },33 handleIsSchool(state) {34 return state.isSchool;35 },36 getWechatSignUrl(state) {37 return state.wxSignUrl38 }...

Full Screen

Full Screen

test_00.js

Source:test_00.js Github

copy

Full Screen

1const { assert } = require('chai');2const { objectToArray } = require('../answers/00.js');3describe("objectToArray", () => {4 it("converts an empty object to an empty array", () => {5 assert.deepEqual(objectToArray({}), []);6 });7 it("tends to return an array", () => {8 const input = { key: "value" };9 assert.isArray(objectToArray(input));10 });11 it("converts { key: 'value' } => [['key', 'value']]", () => {12 const input = { key: "value" };13 assert.deepEqual(objectToArray(input), [["key", "value"]]);14 });15 it("converts multiple key-value pairs to individual arrays", () => {16 const input = { name: "Jon", lastName: "Snow", pet: "Ghost" };17 assert.deepEqual(objectToArray(input), [18 ["name", "Jon"],19 ["lastName", "Snow"],20 ["pet", "Ghost"]21 ]);22 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { objectToArray } = require('@playwright/test/lib/utils/utils');2const obj = { a: 1, b: 2, c: 3 };3const arr = objectToArray(obj);4console.log(arr);5const { objectToArray } = require('@playwright/test/lib/utils/utils');6const obj = { a: 1, b: 2, c: 3 };7const arr = objectToArray(obj);8console.log(arr);9const { objectToArray } = require('@playwright/test/lib/utils/utils');10const obj = { a: 1, b: 2, c: 3 };11const arr = objectToArray(obj);12console.log(arr);13const { objectToArray } = require('@playwright/test/lib/utils/utils');14const obj = { a: 1, b: 2, c: 3 };15const arr = objectToArray(obj);16console.log(arr);17const { objectToArray } = require('@playwright/test/lib/utils/utils');18const obj = { a: 1, b: 2, c: 3 };19const arr = objectToArray(obj);20console.log(arr);21const { objectToArray } = require('@playwright/test/lib/utils/utils');22const obj = { a: 1, b: 2, c: 3 };23const arr = objectToArray(obj);24console.log(arr);25const { objectToArray } = require('@playwright/test/lib/utils/utils');26const obj = { a: 1, b: 2, c: 3 };27const arr = objectToArray(obj);

Full Screen

Using AI Code Generation

copy

Full Screen

1const {objectToArray} = require('playwright/lib/protocol/serializers');2const myObject = {a: "a", b: "b", c: "c"};3console.log(objectToArray(myObject));4const {objectToArray} = require('playwright/lib/protocol/serializers');5const myObject = {a: "a", b: "b", c: "c"};6console.log(objectToArray(myObject));7const {objectToArray} = require('playwright/lib/protocol/serializers');8const myObject = {a: "a", b: "b", c: "c"};9console.log(objectToArray(myObject));10const {objectToArray} = require('playwright/lib/protocol/serializers');11const myObject = {a: "a", b: "b", c: "c"};12console.log(objectToArray(myObject));13const {objectToArray} = require('playwright/lib/protocol/serializers');14const myObject = {a: "a", b: "b", c: "c"};15console.log(objectToArray(myObject));16const {objectToArray} = require('playwright/lib/protocol/serializers');17const myObject = {a: "a", b: "b", c: "c"};18console.log(objectToArray(myObject));19const {objectToArray} = require('playwright/lib/protocol/serializers');20const myObject = {a: "a", b: "b", c: "c"};21console.log(objectToArray(myObject));

Full Screen

Using AI Code Generation

copy

Full Screen

1const {chromium} = require('playwright');2(async () => {3 const browser = await chromium.launch({headless: false});4 const context = await browser.newContext();5 const page = await context.newPage();6 const search = await page.$('input[name="q"]');7 await search.fill('playwright');8 const searchButton = await page.$('input[name="btnK"]');9 await searchButton.click();10 await page.waitForSelector('h3');11 const results = await page.$$eval('h3', (elements) => {12 return elements.map((element) => element.textContent);13 });14 console.log(results);15 await browser.close();16})();

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful