Best JavaScript code snippet using appium-android-driver
StylingService.js
Source:StylingService.js
1BH.add('StylingService', function() {2 3 "use strict";4 eval(BH.System);5 var StylingService = BH.Class(BH.Widget, {6 addressVerification: function(data, successCb, errorCb) {7 BH.BaseService._get(8 data,9 BH.properties.stylingServiceAjaxHost + '/commerce-service/address-verification/',10 function(responseData) {11 if (successCb) {12 successCb(responseData);13 }14 },15 errorCb,16 false // Don't JSON.stringify17 );18 },19 /* BEGIN Quiz APIs */20 getNext: function(data, successCb, errorCb) {21 var me = this,22 serviceUrl = BH.properties.stylingServicePythonAjaxHost + '/quiz/get_next/';23 24 if (data.get_next_unfinished_step) {25 serviceUrl = BH.properties.stylingServicePythonAjaxHost + '/quiz/get_next_unfinished_step/';26 }27 28 BH.BaseService._get(29 data,30 serviceUrl,31 function(responseData) {32 if (successCb) {33 if (data.get_next_unfinished_step) {34 if ((responseData.incomplete_quiz_in_other_device) && (!responseData.has_user_email_paid_styling_fee)) {35 BH.GlobalEvents.get('incompleteQuizInOtherDeviceEvent').fire();36 }37 }38 successCb(responseData);39 }40 },41 errorCb42 );43 },44 getPrevious: function(data, successCb, errorCb) {45 var me = this;46 BH.BaseService._get(47 data,48 BH.properties.stylingServicePythonAjaxHost + '/quiz/get_previous/',49 function(responseData) {50 if (successCb) {51 successCb(responseData);52 }53 },54 errorCb55 );56 },57 58 isUserLoggedIn: function(successCb, errorCb) {59 var me = this;60 BH.BaseService._get(61 {},62 BH.properties.stylingServicePythonAjaxHost + '/quiz/is_user_logged_in/',63 function(responseData) {64 if (successCb) {65 successCb(responseData);66 }67 },68 errorCb69 );70 }, 71 72 // https://github.com/allumestyle/styling-service/blob/master/web/quiz_app/apis.py73 saveUserAnswer: function(data, successCb, errorCb) {74 var me = this;75 76 if (data) {77 BH.BaseService._get(78 data,79 BH.properties.stylingServicePythonAjaxHost + '/quiz/save_user_answer/',80 function(responseData) {81 if (successCb) {82 successCb(responseData);83 }84 },85 errorCb86 );87 } else {88 if (errorCb) {89 errorCb();90 }91 }92 93 },94 uploadUserPhoto: function(formData, successCb, errorCb) {95 var me = this;96 97 $.ajax({98 crossDomain: true,99 xhrFields: {100 withCredentials: true101 },102 cache: false,103 contentType: false, // Set content type to false as jQuery will tell the server its a query string request104 data: formData,105 dataType: 'json',106 processData: false, // Don't process the files107 type: 'POST',108 url: BH.properties.stylingServicePythonAjaxHost + '/quiz/upload_user_photo/'109 }).done(function(response) {110 111 if ((response.code === 'ok') || (response.status === 'success')) {112 successCb(response.data);113 } else {114 if (errorCb) {115 errorCb(response);116 } else {117 BH.log('ERROR', response);118 }119 }120 121 }).fail(function(error) {122 if (errorCb) {123 errorCb(error);124 } else {125 BH.log('FAIL (upload_user_photo)', error);126 }127 }); 128 },129 /* END Quiz APIs */130 postPayment: function(data, successCb, errorCb) {131 132 BH.BaseService._get(133 data,134 BH.properties.stylingServiceAjaxHost + '/user-service/post-payment/',135 function(responseData) {136 if (successCb) {137 successCb(responseData);138 }139 },140 errorCb,141 false // Don't JSON.stringify142 );143 },144 assignJobsToStylist: function(data, successCb, errorCb) {145 BH.BaseService._get(146 data,147 BH.properties.stylingServicePythonAjaxHost + '/assign_jobs_to_stylist/',148 function(responseData) {149 if (successCb) {150 successCb(responseData);151 }152 },153 errorCb, true);154 },155 postQuiz: function(data, successCb, errorCb) {156 157 BH.BaseService._get(158 data,159 BH.properties.stylingServiceAjaxHost + '/user-service/post-quiz/',160 function(responseData) {161 if (successCb) {162 successCb(responseData);163 }164 },165 errorCb,166 false // Don't JSON.stringify167 );168 },169 payStylingFee: function(data, successCb, errorCb) {170 BH.BaseService._get(171 data,172 BH.properties.stylingServiceAjaxHost + '/commerce-service/purchase/',173 function(responseData) {174 if (successCb) {175 successCb(responseData);176 }177 },178 errorCb,179 false // Don't JSON.stringify180 );181 },182 getProduct: function(data, successCb, errorCb) {183 var me = this;184 185 BH.BaseService._get(186 data,187 BH.properties.stylingServiceAjaxHost + '/styling-session-service/get-product/',188 function(responseData) {189 if (successCb) {190 successCb(me.getProductStructuredData(responseData));191 }192 },193 errorCb,194 false // Don't JSON.stringify195 );196 },197 198 getStylingSession: function(data, successCb, errorCb) {199 var me = this;200 201 BH.BaseService._get(202 data,203 BH.properties.stylingServiceAjaxHost + '/styling-session-service/get-styling-sessions/',204 function(responseData) {205 if (successCb) {206 successCb(me._getStylingSessionStructuredData(responseData));207 }208 },209 errorCb,210 false // Don't JSON.stringify211 );212 },213 send_welcome_email: function(data, successCb, errorCb) {214 BH.BaseService._get(215 data,216 BH.properties.stylingServiceAjaxHost + '/client-service/send-welcome-email/',217 function(responseData) {218 if (successCb) {219 successCb(responseData);220 }221 },222 errorCb,223 false // Don't JSON.stringify224 );225 },226 setStylingFeeStatus: function(data, successCb, errorCb) {227 BH.BaseService._get(228 data,229 BH.properties.stylingServiceAjaxHost + '/client-service/set-styling-fee-status/',230 function(responseData) {231 if (successCb) {232 successCb(responseData);233 }234 },235 errorCb,236 false // Don't JSON.stringify237 );238 },239 processStripeError: function (error, cb) {240 241 var msg = null;242 if (error) {243 244 if (error.code) {245 if (error.code === 'invalid_token') {246 247 if (error.data) {248 if (error.data.stripeCode) {249 250 if (error.data.stripeCode === 'incorrect_zip') {251 msg = 'Incorrect Zip';252 253 } else if (error.data.stripeCode === 'incorrect_cvc') {254 msg = 'Incorrect CVV';255 } else if (error.data.stripeCode === 'card_declined') {256 msg = 'Card Declined';257 258 } else if (error.data.stripeCode === 'expired_card') {259 msg = 'Expired Card';260 261 } else if (error.data.stripeCode === 'processing_error') {262 263 if (error.data.jsonBody) {264 if (error.data.jsonBody) {265 if (error.data.jsonBody.error) {266 if (error.data.jsonBody.error.message) {267 msg = error.data.jsonBody.error.message; // An error occurred while processing your card. Try again in a little bit.268 } 269 } 270 } 271 }272 if (msg === null) {273 msg = BH.Constants.DEFAULT_ERROR_MESSAGE;274 }275 }276 277 } 278 }279 280 } 281 }282 }283 if (cb) {284 cb(msg);285 }286 },287 getProductStructuredData: function(data) {288 if (data.length > 0) {289 290 // Alternate images 291 var alternateImages = [];292 _.each(data, function(item, idx) {293 alternateImages[idx] = {294 'image_color': item.alt_product_image_color,295 'image_size': item.alt_product_image_size,296 'image_url': item.alt_product_image_url297 };298 });299 var colors = null,300 sizes = null,301 color_sizes = null;302 if (data[0].size_color_info) {303 var size_color_info = JSON.parse(data[0].size_color_info);304 305 if ((size_color_info) && (size_color_info != "false")) {306 colors = size_color_info.color.value.split(' | ').sort();307 color_sizes = size_color_info['color-size'].value.split(' | '); // Valid color/size combos308 sizes = size_color_info.size.value.split(' | '); 309 } 310 }311 // Hearted or unhearted 312 var hearted = false;313 if (data[0].social_action) {314 if ((data[0].social_action === 'hearted') && (data[0].social_action_value === '1')) {315 hearted = true;316 }317 }318 319 var newData = {320 'alternate_images': alternateImages,321 'colors': colors,322 'color-size': color_sizes,323 'external_url': data[0].external_url,324 'hearted': hearted,325 'in_stock': data[0].in_stock,326 'look_id': data[0].look_id,327 'product_brand': data[0].product_brand,328 'product_descrip': data[0].product_descrip,329 'product_id': data[0].product_id,330 'product_image': data[0].product_image,331 'product_name': data[0].product_name,332 'product_price': data[0].product_price,333 'product_retailer': data[0].product_retailer,334 'product_sale_price': data[0].product_sale_price,335 'product_token': data[0].product_token,336 'return_policy': data[0].return_policy,337 'shipping_policy': data[0].shipping_policy,338 'sizes': sizes,339 'tips': data[0].tips340 };341 if (data[0].look_token) {342 newData.look_token = data[0].look_token;343 }344 return newData;345 346 } else {347 return {};348 }349 },350 351 _getStylingSessionStructuredData: function(data) {352 353 var me = this,354 looks = _.groupBy(data, 'look_id'),355 newDataLooks = {},356 products = _.groupBy(data, 'look_id');357 358 _.each(looks, function(look) {359// newDataLooks[look[0].look_id] = BH.Util.filterObject(look[0], ['hearted', 'look_collage', 'look_descrip', 'look_id', 'look_last_modified', 'look_name', 'look_token', 'rating', 'stylist_first_name']);360 newDataLooks[look[0].look_id] = BH.Util.filterObject(look[0], ['hearted', 'look_collage', 'look_descrip', 'look_id', 'look_last_modified', 'look_name', 'look_token', 'rating']);361 newDataLooks[look[0].look_id].products = {};362 });363 364 for (var look_id in products) {365 366 var look_products = products[look_id];367 _.each(look_products, function(product) {368// var filteredProduct = BH.Util.filterObject(product, ['product_brand', 'product_descrip', 'product_id', 'product_image', 'product_name', 'product_price', 'product_retailer', 'product_sale_price', 'product_token']);369 var filteredProduct = BH.Util.filterObject(product, ['product_brand', 'product_id', 'product_image', 'product_name', 'product_price', 'product_retailer', 'product_sale_price', 'product_token']);370 newDataLooks[product.look_id].products[filteredProduct.product_id] = filteredProduct;371 });372 }373 var _products = _.groupBy(data, 'product_id');374 375 for (var look_name in newDataLooks) {376 for (var product_id in newDataLooks[look_name].products) {377 if (product_id !== 'undefined') {378// var size_color_info = JSON.parse(Object.keys(_.groupBy(_products[product_id], 'size_color_info'))[0]);379//380// var colors = null,381// color_sizes = null,382// piece = newDataLooks[look_name].products[product_id],383// sizes = null;384 var piece = newDataLooks[look_name].products[product_id];385// if ((size_color_info) && (size_color_info != "false")) {386// colors = size_color_info.color ? size_color_info.color.value.split(' | ').sort() : [];387// color_sizes = size_color_info['color-size'] ? size_color_info['color-size'].value.split(' | ') : []; // Valid color/size combos388// sizes = size_color_info.size ? size_color_info.size.value.split(' | ') : [];389// }390 391 // Alternate images392 var altImages = _.groupBy(_products[product_id], 'image_name')['undefined'],393 alternate_images = [];394 _.each(altImages, function(atlImage, idx) {395 alternate_images[idx] = BH.Util.filterObject(atlImage, ['image_color', 'image_size', 'image_url']);396 });397 piece.alternate_images = alternate_images;398 399// //piece.colors = BH.Util.capitalize(colors); // May screw up color/size check and adding to cart?400// piece.colors = colors;401//402// piece['color-size'] = color_sizes;403//404// //piece.sizes = this._sortSizes(sizes); // May screw up color/size check and adding to cart?405// piece.sizes = sizes;406 407 } else {408 BH.log('ERROR: invalid data');409 }410 }411 }412 413 var sortedNewDataLooks = _.sortBy(newDataLooks, 'look_last_modified');414 sortedNewDataLooks = sortedNewDataLooks.reverse();415 var newData = {416 'client_first_name': '', 417 'client_last_name': '',418 'looks': sortedNewDataLooks,419// 'stylist_first_name': '',420// 'styling_session_end_date': null,421 'styling_session_id': 0, 422// 'styling_session_name': '',423// 'styling_session_start_date': null,424 'styling_session_token': ''425 };426 427 if (typeof(data[0]) != 'undefined') {428 429 newData = {430 'client_first_name': data[0].client_first_name, 431 'client_last_name': data[0].client_last_name,432 'looks': sortedNewDataLooks,433// 'stylist_first_name': data[0].stylist_first_name,434// 'styling_session_end_date': data[0].styling_session_end_date,435 'styling_session_id': data[0].styling_session_id, 436// 'styling_session_name': data[0].styling_session_name,437// 'styling_session_start_date': data[0].styling_session_start_date,438 'styling_session_token': data[0].styling_session_token439 };440 }441 442 return newData;443 },444 445 _getAttribute: function(values, id_property, name_property) {446 var _values = {};447 for (var attribute_name in values) {448 449 var id = values[attribute_name][0][id_property],450 name = values[attribute_name][0][name_property];451 452 _values[id] = name;453 }454 455 return _values; 456 }457 });458 if (!BH.StylingService) {459 BH.StylingService = new StylingService();460 BH.StylingService.render();461 }...
util-specs.js
Source:util-specs.js
...245 a: 'a',246 b: 'b',247 c: undefined,248 };249 util.filterObject(obj).should.eql({250 a: 'a',251 b: 'b',252 });253 });254 it('should leave nulls alone', function () {255 let obj = {256 a: 'a',257 b: 'b',258 c: null,259 };260 util.filterObject(obj).should.eql({261 a: 'a',262 b: 'b',263 c: null,264 });265 });266 });267 describe('with value predicate', function () {268 it('should filter elements by their value', function () {269 let obj = {270 a: 'a',271 b: 'b',272 c: 'c',273 d: 'a',274 };275 util.filterObject(obj, 'a').should.eql({276 a: 'a',277 d: 'a',278 });279 });280 });281 describe('with function predicate', function () {282 it('should filter elements', function () {283 let obj = {284 a: 'a',285 b: 'b',286 c: 'c',287 };288 util.filterObject(obj, (v) => v === 'a' || v === 'c').should.eql({289 a: 'a',290 c: 'c',291 });292 });293 });294 });295 describe('isSubPath', function () {296 it('should detect simple subpath', function () {297 util.isSubPath('/root/some', '/root').should.be.true;298 });299 it('should detect complex subpath', function () {300 util.isSubPath('/root/some/other/../../.', '/root').should.be.true;301 });302 it('should detect subpath ending with a slash', function () {...
util.test.js
Source:util.test.js
...128 }, that), {map: 'BOX'});129 });130 t.test('filterObject', (t) => {131 t.plan(6);132 t.deepEqual(util.filterObject({}, () => { t.ok(false); }), {});133 const that = {};134 util.filterObject({map: 'box'}, function(value, key, object) {135 t.equal(value, 'box');136 t.equal(key, 'map');137 t.deepEqual(object, {map: 'box'});138 t.equal(this, that);139 return true;140 }, that);141 t.deepEqual(util.filterObject({map: 'box', box: 'map'}, (value) => {142 return value === 'box';143 }), {map: 'box'});144 t.end();145 });146 t.test('deepEqual', (t) => {147 const a = {148 foo: 'bar',149 bar: {150 baz: 5,151 lol: ["cat", 2]152 }153 };154 const b = JSON.parse(JSON.stringify(a));155 const c = JSON.parse(JSON.stringify(a));...
views.js
Source:views.js
1var registry=global.registry2var Q = require('q')3var view_analytics_hit=function(params,user){4 var Analytics = registry.getSharedObject('models_Analytics')5 var analytics_obj=new Analytics();6 console.log(params)7 analytics_obj.timeStamp=params.time || Date.now();8 analytics_obj.user=user.id;9 analytics_obj.metric=params.metric;10 analytics_obj.dimensions=params.dimensions;11 analytics_obj.test=params.test||false;12 return Q(analytics_obj.save())13}14var compute_analytics=function(map,reduce,query,scope){15 debugger;16 var deferred = Q.defer();17 registry.getSharedObject('models_Analytics').mapReduce({18 query:query,19 map:map,20 reduce:reduce,21 scope:scope,22 verbose:true23 }, function (err, data, stats) {24 debugger; 25 //console.log('map reduce took %d ms', stats.processtime)26 if(err) console.log(err);27 else console.log(data);28 deferred.resolve( data );29 });30// process.nextTick( function(){ deferred.resolve({"hello":"world"}) } );31 return deferred.promise;32}33function makeArray(obj) {34 if(obj == undefined) {35 return [];36 }37 else if(obj.constructor != Array) {38 return [ obj ];39 }40 else {41 return obj;42 }43}44var view_analytics_byDay = function(params,user){45 var scope = {};46 scope.filterObject = global.registry.getSharedObject('util').filterObject;47 scope.filterDimension = function(dim_this, dim_filter) {48 if(dim_filter.length != 0) {49 return filterObject(dim_this, dim_filter).data;50 }51 else {52 return dim_this;53 }54 }55 scope.filterMetric = function(metric_this, metric_filter) {56 if(metric_filter.length != 0) {57 if(metric_filter.indexOf(metric_this) != -1) {58 return true;59 }60 else {61 return false;62 }63 }64 else {65 return true;66 }67 }68 scope.dimensions = makeArray(params.dimensions);69 //scope.metric = params.metric;70 var map_byDay=function(){71 if(filterMetric(this.metric, metric)) {72 emit({73 metric:this.metric,74 dimensions:filterDimension(this.dimensions, dimensions),75 time:new Date(this.timeStamp.getFullYear(),76 this.timeStamp.getMonth(),77 this.timeStamp.getDate(),78 0,0,0,0)79 },1)80 }81 }82 var reduce=function(key,values){83 return Array.sum(values)84 }85 if(params.start && params.end)86 query={timeStamp:{87 $gte:(new Date(params.start*1)).toISOString(),88 $lte:(new Date(params.end*1)).toISOString(),89 }90 }91 else92 query={}93 94 query.metric = params.metric;95 console.log(query)96 return compute_analytics(map_byDay,reduce,query,scope);97}98var view_analytics_vendor_get = function(params, user) {99 var deferred = Q.defer();100 var scope = {};101 /*scope.filterObject = global.registry.getSharedObject('util').filterObject;102 scope.filterDimension = function(dim_this, dim_filter) {103 if(dim_filter.length != 0) {104 return filterObject(dim_this, dim_filter,false).data;105 }106 else {107 return dim_this;108 }109 }110 scope.filterMetric = function(metric_this, metric_filter) {111 if(metric_filter.length != 0) {112 if(metric_filter.indexOf(metric_this) != -1) {113 return true;114 }115 else {116 return false;117 }118 }119 else {120 return true;121 }122 }*/123 scope.dimensions = makeArray(params.dimensions);124 scope.metric = makeArray(params.metric);125 if(params.time_interval) {126 scope.time_interval = params.time_interval*1;127 }128 else {129 scope.time_interval = 24*60*60*1000;//1 day130 }131 debugger;132 if(user.type == "Vendor") {133 scope.vendor_id = user.vendor_id.toString();134 135 136 var map_byVendor = function() {137 var obj = {};138 139 var dims = {};140 for( var i = 0; i < dimensions.length; i++ ){141 var dim = dimensions[i];142 dims[dim] = this.dimensions[dim];143 }144 obj.dimensions = dims;145 obj.metric = this.metric; 146 obj.time = parseInt((this.timeStamp.getTime())/time_interval);147 //if( this.dimensions && this.dimensions.vendor_id && this.dimensions.vendor_id == vendor_id )148 emit( obj, 1 );149 }150 var reduce = function(key, values) {151 return Array.sum(values);152 }153 var query = {};154 debugger;155 if(params.time_start && params.time_end) {156 query = {timeStamp:{157 $gte:(new Date(params.time_start*1)).toISOString(),158 $lte:(new Date(params.time_end*1)).toISOString()159 }}160 }161 query.metric = params.metric;162 console.log(query);163 return compute_analytics(map_byVendor, reduce, query, scope);164 }165 else {166 process.nextTick(function(){167 deferred.resolve(registry.getSharedObject("view_error").makeError({ error:{message:"Permission denied"}, code:909 }));168 });169 return deferred.promise;170 }171}172var view_analytics_vendor = function(params, user) {173 var scope = {174 metrics: [params.metric],175 dimensions: params.dimensions,176 getDimensions: function(thisD, reqD) {177 d = {}178 for (var dim in reqD) {179 var key = reqD[dim]180 if (thisD[key])181 d[key] = thisD[key]182 }183 return d184 },185 vendor_id:user.vendor_id186 }187 var map_byVendor = function() {188 if ((this.dimensions.vendor_id)&&189 (metrics.indexOf(this.metric) != -1)&&190 (this.dimensions.vendor_id==vendor_id)) {191 emit({192 metric: this.metric,193 dimensions: getDimensions(this.dimensions, dimensions),194 time: new Date(this.timeStamp.getFullYear(),195 this.timeStamp.getMonth(),196 this.timeStamp.getDate(),197 0, 0, 0, 0)198 }, 1)199 }200 }201 var reduce = function(key, values) {202 return Array.sum(values)203 }204 return compute_analytics()205}206registry.register("view_analytics_hit",{get:view_analytics_hit,post:view_analytics_hit})207registry.register('view_analytics_vendor_get', { get : view_analytics_vendor_get });...
view.js
Source:view.js
...54exports.contact = function contact(event, x, args, err) {55 switch(event) {56 case "readdir":57 readdir.apply(this, [{}, function (node) {58 return extend(util.filterObject(node.children, function (name, child) {59 return !child.model || !(child.model instanceof model.Roster);60 }));61 }].concat(__slice.call(arguments)));62 break;63 default:64 defaultcallback.apply(this, __slice.call(arguments));65 break;66 }67};68exports.account = function account(event, x, args, err) {69 switch(event) {70 case "readdir":71 readdir.apply(this, [{}, function (node) {72 return util.filterObject(node.children, function (name, child) {73 return !child.model || !(child.model instanceof model.Resource);74 });75 }].concat(__slice.call(arguments)));76 break;77 case "mkdir":78 mkdir.apply(this, [function (account, node, jid, barejid) {79 account.node.add(80 barejid,81 account.add(jid, node).contact.node,82 'overwrite');83 }].concat(__slice.call(arguments)));84 break;85 case "rmdir":86 rmdir.apply(this, [function (node, child, barejid) {87 if (child) { // replace with dummy88 node.children[barejid] = null;89 node.add(barejid, new fs.Directory()).protected = false;90 }91 }].concat(__slice.call(arguments)));92 break;93 default:94 defaultcallback.apply(this, __slice.call(arguments));95 break;96 }97};98exports.roster = function roster(event, x, args, err) {99 switch(event) {100 case "readdir":101 readdir.apply(this, [{}, function (node) {102 return util.filterObject(node.children, function (name, child) {103 return !child.model || (child.model instanceof model.Contact);104 });105 }].concat(__slice.call(arguments)));106 break;107 case "mkdir":108 mkdir.apply(this, [function (account, node, jid) {109 account.client.subscribe(account.add(jid, node).get('jid'));110 }].concat(__slice.call(arguments)));111 break;112// case "rmdir":113// rmdir.apply(this, [function (node, child, barejid) {114// if (child) { // replace with dummy115// node.children[barejid] = null;116// node.add(barejid, new fs.Directory()).protected = false;117// }118// }].concat(__slice.call(arguments)));119// break;120 default:121 defaultcallback.apply(this, __slice.call(arguments));122 break;123 }124};125exports.resource = function resource(event, x, args, err) {126 switch(event) {127 case "readdir":128 readdir.apply(this, [{}, function (node) {129 return util.filterObject(node.children, function (name, child) {130 return !child.model || !(child.model instanceof model.Roster);131 });132 }].concat(__slice.call(arguments)));133 break;134 default:135 defaultcallback.apply(this, __slice.call(arguments));136 break;137 }138};139exports.contacts = defaultcallback;...
search.js
Source:search.js
...47 )48 }49 }50 async search(params) {51 const data = util.filterObject(52 params,53 [54 'page', 'page_size', 'sort_by', 'sort_order',55 'user_id', 'user_number', 'status', 'max_content_length'56 ]57 )58 data.type = params.types.join(',')59 data._and = 'and' in params ? params.and : 060 const { account } = this.service61 const currentUser = await account.session.getCurrentUser()62 data._user_id = currentUser ? currentUser.id : ''63 // æç´¢å段64 const fields = params.fields65 const query = params.query66 if (util.type(query) === 'string' && util.type(fields) === 'array') {67 fields.forEach(68 field => {69 data[ field ] = query70 }71 )72 }73 const response = await this.ctx.curl(74 config.server.search + '/search',75 {76 method: 'GET',77 dataType: 'json',78 data,79 }80 )81 // status/headers/res/data82 if (response.status !== 200) {83 this.throw(84 code.INNER_ERROR,85 'SEARCH ç´¢å¼é误'86 )87 }88 return response.data89 }90 async news(params) {91 const data = util.filterObject(92 params,93 [94 'page', 'page_size', 'user_number', 'user_ids', 'max_content_length', 'ts',95 ]96 )97 const { account } = this.service98 const currentUser = await account.session.getCurrentUser()99 data._user_id = currentUser ? currentUser.id : ''100 const response = await this.ctx.curl(101 config.server.search + '/news',102 {103 method: 'GET',104 dataType: 'json',105 data,...
timeline_sender.js
Source:timeline_sender.js
1(function() {2 function TimelineSender(timeline, options) {3 this.timeline = timeline;4 this.options = options || {};5 }6 var prototype = TimelineSender.prototype;7 prototype.send = function(encrypted, callback) {8 if (this.timeline.isEmpty()) {9 return;10 }11 var self = this;12 var scheme = "http" + (encrypted ? "s" : "") + "://";13 var sendJSONP = function(data, callback) {14 var params = {15 data: Pusher.Util.filterObject(data, function(v) {16 return v !== undefined;17 }),18 url: scheme + (self.host || self.options.host) + self.options.path,19 receiver: Pusher.JSONP20 };21 return Pusher.JSONPRequest.send(params, function(error, result) {22 if (result && result.host) {23 self.host = result.host;24 }25 if (callback) {26 callback(error, result);27 }28 });29 };30 self.timeline.send(sendJSONP, callback);31 };32 Pusher.TimelineSender = TimelineSender;...
OutlinedDiv.js
Source:OutlinedDiv.js
1//Courtesy of https://github.com/mui-org/material-ui/issues/147892import React from "react";3import SmoothIn from "util/transitionSmoothIn";4import { filterObject } from "util/filterObject";5import TextField from "@material-ui/core/TextField";6const InputComponent = ({ inputRef, ...other }) => <div {...other} />;7const OutlinedDiv = ({8 children,9 inputClassName,10 inputRootClasses,11 ...props12}) => (13 <TextField14 {...filterObject(props, ["label", "style", "className", "classes"])}15 variant="outlined"16 fullWidth17 multiline18 InputLabelProps={{ shrink: true }}19 InputProps={{20 classes: { root: inputRootClasses },21 inputComponent: InputComponent22 }}23 inputProps={{24 className: inputClassName,25 children: children26 }}27 />28);...
Using AI Code Generation
1var util = require('util');2var driver = require('appium-android-driver');3var obj = { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6 };4var keep = ['a', 'c', 'e'];5var result = util.filterObject(obj, keep);6console.log(result);
Using AI Code Generation
1var util = require('util');2var filterObject = util.filterObject;3var obj = {a: 1, b: 2, c: 3};4var newObj = filterObject(obj, ['a', 'c']);5console.log(newObj);6var util = require('util');7var hasValue = util.hasValue;8var obj = {a: 1, b: 2, c: 3};9var hasValue = hasValue(obj, 'a');10console.log(hasValue);11var util = require('util');12var hasValue = util.hasValue;13var obj = {a: 1, b: 2, c: 3};14var hasValue = hasValue(obj, 'd');15console.log(hasValue);16var util = require('util');17var hasValue = util.hasValue;18var obj = {a: 1, b: 2, c: 3};19var hasValue = hasValue(obj, 'a', 2);20console.log(hasValue);21var util = require('util');22var hasValue = util.hasValue;23var obj = {a: 1, b: 2, c: 3};24var hasValue = hasValue(obj, 'a', 1);25console.log(hasValue);26var util = require('util');27var hasValue = util.hasValue;28var obj = {a: 1, b: 2, c: 3};29var hasValue = hasValue(obj, 'a', 1, 2);30console.log(hasValue);31var util = require('util');32var hasValue = util.hasValue;33var obj = {a: 1, b
Using AI Code Generation
1var util = require("util");2var filterObject = util.filterObject;3var obj = {4};5var filteredObject = filterObject(obj, ["a", "c", "e", "g"]);6console.log("Filtered Object: ", filteredObject);
Using AI Code Generation
1const util = require('util');2const AndroidDriver = require('appium-android-driver').AndroidDriver;3const driver = new AndroidDriver();4const objectToFilter = {a: 1, b: 2, c: 3};5const keysToFilter = ['b', 'c'];6util.filterObject(objectToFilter, keysToFilter);7const util = require('util');8const BaseDriver = require('appium-base-driver').BaseDriver;9const driver = new BaseDriver();10const objectToFilter = {a: 1, b: 2, c: 3};11const keysToFilter = ['b', 'c'];12util.filterObject(objectToFilter, keysToFilter);13const util = require('util');14const BaseDriver = require('appium-base-driver').BaseDriver;15const driver = new BaseDriver();16const objectToFilter = {a: 1, b: 2, c: 3};17const valueToFind = 2;18util.hasValue(objectToFilter, valueToFind);19const util = require('util');20const BaseDriver = require('appium-base-driver').BaseDriver;21const driver = new BaseDriver();22const objectToFilter = {a: 1, b: 2, c: 3};23const valueToFind = 4;24util.hasValue(objectToFilter, valueToFind);25const util = require('util');26const BaseDriver = require('appium-base-driver').BaseDriver;27const driver = new BaseDriver();28const objectToFilter = {a: 1, b: 2, c: 3};29const valueToFind = 4;30util.hasValue(objectToFilter, valueToFind);31const util = require('util');32const BaseDriver = require('appium-base-driver').BaseDriver;
Using AI Code Generation
1var util = require('appium-android-driver').androidHelpers.util;2var obj = {a:1, b:2, c:3, d:4, e:5, f:6};3var filter = ['a', 'c', 'e'];4var filteredObj = util.filterObject(obj, filter);5console.log(filteredObj);6var util = require('appium-android-driver').androidHelpers.util;7var obj = {a:1, b:2, c:3, d:4, e:5, f:6};8var util = require('appium-android-driver').androidHelpers.util;9var obj = {a:1, b:2, c:3, d:4, e:5, f:6};10var util = require('appium-android-driver').androidHelpers.util;11var obj = {a:1, b:2, c:3, d:4, e:5, f:6};12var util = require('appium-android-driver').androidHelpers.util;13var obj = {a:1, b:2, c:3, d:4, e:5, f:6};14var util = require('appium-android-driver').androidHelpers.util;15var obj = {a:1, b:
Using AI Code Generation
1var util = require('util');2var filterObject = require('util').filterObject;3var obj = {a:1, b:2, c:3, d:4};4var filteredObj = filterObject(obj, ['a', 'c']);5console.log(filteredObj);6{ a: 1, c: 3 }7var util = require('util');8var result = util.format('%s %s', 'Hello', 'World');9console.log(result);10var util = require('util');11function Base() {12 this.name = 'base';13 this.base = 1992;14 this.sayHello = function() {15 console.log('Hello ' + this.name);16 };17}18Base.prototype.showName = function() {19 console.log(this.name);20};21function Sub() {22 this.name = 'sub';23}24util.inherits(Sub, Base);25var objBase = new Base();26var objSub = new Sub();27var util = require('util');28var arr = [1, 2, 3];
Using AI Code Generation
1var filtered = util.filterObject(obj, ['platformName', 'platformVersion', 'deviceName', 'appPackage', 'appActivity', 'app']);2console.log(filtered);3{ platformName: 'Android',4 app: '/Users/username/Documents/appium-tests/apps/Calculator_v7.1_apkpure.com.apk' }5var parsed = util.parseCaps(obj);6console.log(parsed);7{ platformName: 'Android',8 app: '/Users/username/Documents/appium-tests/apps/Calculator_v7.1_apkpure.com.apk' }
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!!