Best JavaScript code snippet using stryker-parent
index.js
Source:index.js
1new Vue({2 el: '#domains',3 data: {4 LANG_MESSAGES: LANG_MESSAGES,5 LANG_DOMAINS: LANG_DOMAINS,6 USER_PERMISSIONS: USER_PERMISSIONS,7 CDN_HOST: CDN_HOST,8 domains: [],9 flows: [],10 is_cloaking_enabled: null,11 settings_modal: null,12 action: null,13 is_new_cloaking: 0,14 domain: {15 donor_url: '',16 fallback_flow_hash: null,17 domain: '',18 is_public: 1,19 type: 'parked',20 entity_type: 'flow',21 },22 availability: [23 {title: LANG_DOMAINS.all_flows, value: 1},24 {title: LANG_DOMAINS.selected_flows, value: 0},25 ],26 selected_availability: {},27 selected_flow: {},28 domains_loading: false,29 flows_loading: false,30 replace_modal: null,31 replacements_info: {32 cloak_domain_path_hash: '',33 replacements: [],34 },35 original_replacements: [],36 replacements_changed: false,37 pending_refresh_replacements: false,38 },39 components: {40 'multiselect': window.VueMultiselect.default41 },42 computed: {43 loading() {44 return this.domains_loading || this.flows_loading;45 },46 },47 created() {48 this.is_cloaking_enabled = in_array('CLOAKING', USER_PERMISSIONS);49 this.getFlowsForModal();50 },51 mounted() {52 this.getDomains();53 this.settings_modal = $('#settings-domain-modal');54 this.replace_modal = $('#replace_modal');55 let self = this;56 $(this.replace_modal).on('hide.bs.modal', function (event) {57 self.onCloseReplacementsModal(event, self.replace_modal);58 });59 },60 watch: {61 'is_new_cloaking'() {62 if (!this.is_new_cloaking) {63 this.domain.donor_url = '';64 }65 },66 'selected_availability.value'(value) {67 this.domain.is_public = value;68 },69 'selected_flow'() {70 if (!Object.size(this.selected_flow)) {71 return;72 }73 this.domain.fallback_flow_hash = this.selected_flow.hash;74 },75 'loading'() {76 if (this.loading) {77 return ContentPreloader.show('#domains-list-wrap');78 }79 ContentPreloader.hide();80 },81 'replacements_info.replacements'() {82 this.replacements_changed = !_.isEqual(this.replacements_info.replacements, this.original_replacements);83 }84 },85 methods: {86 openLinkModal(domain) {87 this.$refs.link_modal.openForDomains(domain);88 },89 openCreateDomainModal() {90 this.action = 'create';91 this.is_new_cloaking = 0;92 this.domain = {93 donor_url: '',94 fallback_flow_hash: null,95 domain: '',96 is_public: 1,97 type: 'parked',98 entity_type: 'flow',99 };100 this.selected_flow = {};101 this.selected_availability = {};102 this.settings_modal.modal();103 },104 createDomain() {105 let params = _.clone(this.domain),106 ladda = LaddaPreloader.start('#create_domain_submit');107 if (is_null(params.fallback_flow_hash)) {108 delete params.fallback_flow_hash;109 }110 if (this.is_new_cloaking) {111 params = _.omit(params, ['fallback_flow_hash']);112 }113 api.post('/domain.create', params).then(response => {114 this.domains.unshift(response.data.response);115 LaddaPreloader.stop(ladda);116 showMessage('success', response.data.message);117 this.settings_modal.modal('hide');118 }, error => {119 LaddaPreloader.stop(ladda);120 });121 },122 openEditDomainModal(domain) {123 this.action = 'edit';124 this.domain = {125 donor_url: domain.donor_url,126 fallback_flow_hash: _.get(domain, 'flow.hash', null),127 domain: domain.domain,128 domain_hash: domain.hash,129 is_public: domain.is_public,130 type: 'parked',131 entity_type: 'flow',132 };133 if (domain.donor_url.length) {134 this.is_new_cloaking = 1;135 } else {136 this.is_new_cloaking = 0;137 }138 this.selected_flow = _.find(this.flows, {hash: this.domain.fallback_flow_hash});139 this.selected_availability = _.find(this.availability, {value: this.domain.is_public});140 this.settings_modal.modal();141 },142 editDomain() {143 let params = _.clone(this.domain),144 ladda = LaddaPreloader.start('#edit_domain_submit');145 if (is_null(params.fallback_flow_hash)) {146 delete params.fallback_flow_hash;147 }148 if (this.is_new_cloaking) {149 params = _.omit(params, ['fallback_flow_hash', 'is_public']);150 }151 api.post('/domain.edit', params).then(response => {152 let index = _.findIndex(this.domains, {hash: response.data.response.hash});153 this.domains.splice(index, 1, response.data.response);154 LaddaPreloader.stop(ladda);155 showMessage('success', response.data.message);156 this.settings_modal.modal('hide');157 }, error => {158 LaddaPreloader.stop(ladda);159 });160 },161 deleteDomain(domain_hash) {162 Swal.show(LANG_DOMAINS.on_delete_msg).then(() => {163 api.post('/domain.delete', {domain_hash: domain_hash})164 .then(response => {165 let index = _.findIndex(this.domains, {hash: domain_hash});166 this.domains.splice(index, 1);167 showMessage('success', response.data.message);168 })169 .catch(error => {170 showMessage('error', error.message);171 });172 }, () => {173 });174 },175 getDomains() {176 this.domains_loading = true;177 let params = {178 with_system: 0,179 with: ['flow', 'paths', 'replacements'],180 entity_types: ['flow'],181 };182 api.get('/domain.getList', {params: params}).then(response => {183 this.domains = response.data.response;184 showMessage('success', response.data.message);185 this.domains_loading = false;186 }, error => {187 showMessage('error', error.message);188 this.domains_loading = false;189 });190 },191 getFlowsForModal() {192 this.flows_loading = true;193 api.get('/flow.getList', {params: {with: ['offer']}}).then(response => {194 this.flows = response.data.response;195 this.flows_loading = false;196 });197 },198 openReplacementsModal(domain) {199 if (this.pending_refresh_replacements) {200 return;201 }202 this.replacements_info.domain_hash = domain.hash;203 let params = {204 domain_hash: this.replacements_info.domain_hash205 };206 this.replacements_info.replacements = domain.replacements.map(replacement => {207 return {208 from: replacement.from,209 to: replacement.to210 }211 });212 this.original_replacements = _.clone(this.replacements_info.replacements);213 this.replace_modal.modal();214 },215 onCloseReplacementsModal(e, modal) {216 if (!this.replacements_changed) {217 return;218 }219 e.preventDefault();220 e.stopImmediatePropagation();221 Swal.showSuccess(LANG_MESSAGES.on_unsaved_changes, LANG_MESSAGES.save).then(() => {222 modal.modal('hide');223 this.saveReplacements();224 }, () => {225 });226 },227 saveReplacements() {228 let ladda = LaddaPreloader.start('#replacements-save');229 this.replacements_info.replacements = this.rejectEmptyReplacements(this.replacements_info.replacements);230 api.post('/domain_replacements.sync', this.replacements_info).then(response => {231 this.replacements_changed = false;232 this.refreshDomainReplacements(this.replacements_info.domain_hash);233 this.replace_modal.modal('hide');234 showMessage('success', response.data.message);235 LaddaPreloader.stop(ladda);236 }, () => {237 LaddaPreloader.stop(ladda);238 });239 },240 refreshDomainReplacements(domain_hash) {241 this.pending_refresh_replacements = true;242 this.getReplacements(domain_hash).then(replacements => {243 let domain = _.find(this.domains, {hash: domain_hash});244 domain.replacements.splice(0);245 replacements.forEach(replacement => {246 domain.replacements.push(replacement);247 })248 this.pending_refresh_replacements = false;249 });250 },251 getReplacements(domain_hash) {252 return new Promise((resolve, reject) => {253 api254 .get('/domain_replacements.getList', {params: {domain_hash: domain_hash}})255 .then(response => resolve(response.data.response))256 });257 },258 rejectEmptyReplacements(replacements) {259 return replacements.filter(replacement => replacement.from.length);260 },261 addReplacement() {262 this.replacements_info.replacements.push({from: '', to: ''});263 },264 deleteReplacementItem(index) {265 this.replacements_info.replacements.splice(index, 1);266 },267 clearCache(domain) {268 api.post('/domain.clearCache', {hash: domain.hash}).then(response => {269 showMessage('success', response.data.message);270 });271 }272 },...
db.js
Source:db.js
1234(function(ns){5 ns.Database = function(filename, version, name, size){67 var self = this;8 9 //most recent SQL query10 self.lastQuery = null;11 12 //database connection13 self.connection = openDatabase(filename, version, name, size);14 15 16 /**17 * close the connection to the database (this doesn't appear to work, the database file is still locked :()18 */19 self.close = function(){20 self.connection = null;21 }2223 24 /**25 * executes a command (INSERT, UPDATE, CREATE, etc..) against the current database26 * returns an array of rows (if any)27 */28 self.exe = function(query, replacements, callback, errorHandler){29 30 //replacements is optional31 if (typeof replacements == "function"){32 errorHandler = callback;33 callback = replacements;34 replacements = null;35 }36 37 self.runQuery(query, replacements, function(sqlTrans, sqlRs){38 var rs = self.SQLResultSetToArray(sqlRs);39 callback(rs);40 }, errorHandler);41 }42 43 44 /**45 * execute a statement against the database46 * lowest level platform specific query, should return platform specific results47 **/48 self.runQuery = function(query, replacements, callback, errorHandler){49 50 //replacements is optional51 if (typeof replacements == "function"){52 errorHandler = callback;53 callback = replacements;54 replacements = null;55 }56 57 //set default error handler58 errorHandler = errorHandler || self.errorHandler;59 60 //and execute the query61 if (replacements){62 query = self.formatQuery(query, replacements);63 }64 65 self.lastQuery = query;66 Lazarus.logger.log("SQL: "+ query);67 var st = (new Date()).getTime();68 69 self.connection.transaction(function(transaction){70 transaction.executeSql(query, [], function(sqlTrans, sqlRs){71 var el = (new Date()).getTime() - st;72 Lazarus.logger.log("SQL: "+ el +"ms");73 Lazarus.Event.fire('databaseExecute', query);74 callback(sqlTrans, sqlRs);75 }, errorHandler);76 });77 }78 79 80 /**81 * execute a series of queries wrapped in a single transaction82 **/83 self.transaction = function(queries, origReplacementsList, callback, errorHandler){84 85 //replacements is optional86 if (typeof origReplacementsList == "function"){87 errorHandler = callback;88 callback = origReplacementsList;89 origReplacementsList = [];90 }91 92 //build the list of queries to run93 var results = [];94 95 //set default error handler96 errorHandler = errorHandler || self.errorHandler;97 98 //and execute the query99 self.lastQuery = queries;100 Lazarus.logger.log("SQL:x"+ origReplacementsList.length +":"+ queries);101 102 //allow us to send a single query with a list of different replacements 103 //eg ("INSERT INTO x (name) VALUES ({name})", [{name:"arthur"}, {name:"ford"}, {name:"zaphod"}, {name:"trillian"}])104 if (typeof queries == "string"){105 queries = [queries];106 for(var i=1; i<origReplacementsList.length; i++){107 queries[i] = queries[0];108 }109 }110 111 //make a copy of the original replacements so we don't alter it when 112 //we move from one statement to the next statement113 var replacementsList = Lazarus.Utils.clone(origReplacementsList);114 115 var st = (new Date()).getTime();116 var completedQueries = [];117 118 //all the queries should be wrapped in a single transaction119 self.connection.transaction(function(transaction){120 121 var runNextQuery = function(){ 122 var replacements = replacementsList.shift();123 var query = self.formatQuery(queries.shift(), replacements);124 Lazarus.logger.log(query);125 transaction.executeSql(query, [], function(sqlTrans, sqlRs){126 results.push({127 trans: sqlTrans,128 result: sqlRs129 });130 completedQueries.push(query);131 if (queries.length > 0){132 runNextQuery();133 }134 else {135 //finished all queries136 var el = (new Date()).getTime() - st;137 Lazarus.logger.log("SQL: "+ el +"ms");138 Lazarus.Event.fire('databaseTransaction', completedQueries);139 callback(results);140 }141 }, errorHandler);142 }143 runNextQuery();144 });145 };146 147 148 /**149 * return a query that is safe to run150 */151 self.formatQuery = function(query, replacements){152 //dont re-format queries passed twice153 if (!replacements){154 return query;155 }156 157 return query.replace(/\{\w+\}/g, function(m){158 var key = m.replace(/\{|\}/g, '');159 if (typeof replacements[key] == "number"){160 return replacements[key];161 }162 else if (typeof replacements[key] != "undefined" && replacements[key] !== null){163 return ("'"+ replacements[key].toString().replace(/'/g, "''") +"'");164 }165 else {166 Lazarus.logger.error("formatQuery: missing replacement in query", query, replacements);167 throw Error("formatQuery: missing replacement in query");168 }169 });170 }171 172 173 /**174 * execute an INSERT statement and return the last_insert_rowid 175 */176 self.insert = function(query, replacements, callback, errorHandler){177 178 //replacements is optional179 if (typeof replacements == "function"){180 errorHandler = callback;181 callback = replacements;182 replacements = null;183 }184 185 self.runQuery(query, replacements, function(sqlTr, sqlRs){186 callback(sqlRs.insertId || null);187 }, function(){188 callback(null);189 });190 }191 192 193 /**194 * return a single row of results as an associate array (js object)195 */196 self.getObj = function(query, replacements, callback, errorHandler){197 198 //replacements is optional199 if (typeof replacements == "function"){200 errorHandler = callback;201 callback = replacements;202 replacements = null;203 }204 205 self.exe(query, replacements, function(rs){206 callback(rs[0] || null);207 }, errorHandler);208 }209 210 211 /**212 * returns a single STRING result from a query.213 */214 self.getStr = function(query, replacements, callback, errorHandler){215 216 //replacements is optional217 if (typeof replacements == "function"){218 errorHandler = callback;219 callback = replacements;220 replacements = null;221 }222 223 self.exe(query, replacements, function(rs){224 if (rs.length == 0){225 //no results 226 callback("");227 }228 else {229 for(var col in rs[0]){230 var val = rs[0][col].toString();231 callback(val);232 return;233 }234 //we should never get here235 //there should always be at least one property for the object, but if not then throw an error236 throw Error("SQL: getStr: failed to return an object");237 }238 }, errorHandler);239 }240 241 /**242 * returns a single INTEGER result from a query.243 */244 self.getInt = function(query, replacements, callback, errorHandler){245 246 //replacements is optional247 if (typeof replacements == "function"){248 errorHandler = callback;249 callback = replacements;250 replacements = null;251 }252 253 self.getStr(query, replacements, function(result){254 var val = parseInt(result);255 callback(isNaN(val) ? 0 : val);256 }, errorHandler); 257 }258 259 260 261 self.getColumn = function(query, replacements, callback, errorHandler){262 //replacements is optional263 if (typeof replacements == "function"){264 errorHandler = callback;265 callback = replacements;266 replacements = null;267 }268 269 self.exe(query, replacements, function(rs){270 var fields = [];271 for(var i=0; i<rs.length; i++){272 for(var field in rs[i]){273 fields.push(rs[i][field]);274 break;275 }276 }277 callback(fields)278 }, errorHandler); 279 }280 281 282 /**283 * default error handler284 **/285 self.errorHandler = function(err, fatal){286 Lazarus.logger.error("Database error", self.lastQuery, err);287 if (fatal){288 throw Error(err);289 }290 }291 292 293 /**294 * return TRUE if table exists in the current database295 */296 self.tableExists = function(name, callback){297 var query = "SELECT count(*) FROM sqlite_master WHERE name = {name}";298 self.getInt(query, {name:name}, function(result){299 var val = parseInt(result);300 callback(val > 0);301 }); 302 }303 304 305 /**306 * convert a resultset into a simple array of objects307 **/308 self.SQLResultSetToArray = function(resultSet){309 var arr = [];310 if (resultSet && resultSet.rows){311 for(var i=0; i<resultSet.rows.length; i++){312 //FFS: cannot just copy the object, it becomes read only, and properties cannot be changed!313 //arr[i] = resultSet.rows.item(i);314 //arr[i].summary = "overwritten"; 315 //FAILS TO OVERWRITE arr[i].summary316 //using clone instead.317 arr[i] = Lazarus.Utils.clone(resultSet.rows.item(i));318 } 319 }320 return arr;321 }322 }323324})(Lazarus);
...
replacements.module.ts
Source:replacements.module.ts
1import { NgModule } from '@angular/core';2import { CommonModule } from '@angular/common';3import { ReplacementsRoutingModule } from './replacements-routing.module';4import { ReplacementsComponent } from './replacements.component';5import { MaterialModule } from 'src/app/material/material.module';6import { CreateDialogReplacementsComponent } from './dialogs/create-dialog-replacements/create-dialog-replacements.component';7import { EditDialogReplacementsComponent } from './dialogs/edit-dialog-replacements/edit-dialog-replacements.component';8import { DeleteDialogReplacementsComponent } from './dialogs/delete-dialog-replacements/delete-dialog-replacements.component';9import { UploadFileDialogReplacementsComponent } from './dialogs/upload-file-dialog-replacements/upload-file-dialog-replacements.component';10@NgModule({11 declarations: [12 ReplacementsComponent,13 CreateDialogReplacementsComponent,14 EditDialogReplacementsComponent,15 DeleteDialogReplacementsComponent,16 UploadFileDialogReplacementsComponent17 ],18 imports: [19 CommonModule,20 ReplacementsRoutingModule,21 MaterialModule22 ]23})...
Using AI Code Generation
1module.exports = function (config) {2 config.set({3 mochaOptions: {4 },5 replacements: {6 'src/replace.js': {7 }8 }9 });10};11module.exports = function () {12 return 'replace';13};14const assert = require('assert');15const replace = require('../src/replace.js');16describe('replace', function () {17 it('should replace', function () {18 assert.equal(replace(), 'replaced');19 });20});
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var strykerParent = require('stryker-parent');3var strykerParent = require('stryker-parent');4var strykerParent = require('stryker-parent');5var strykerParent = require('stryker-parent');6var strykerParent = require('stryker-parent');7var strykerParent = require('stryker-parent');8var strykerParent = require('stryker-parent');9var strykerParent = require('stryker-parent');10var strykerParent = require('stryker-parent');11var strykerParent = require('stryker-parent');12var strykerParent = require('stryker-parent');13var strykerParent = require('stryker-parent');14var strykerParent = require('stryker-parent');15var strykerParent = require('stryker-parent');16var strykerParent = require('stryker-parent');17var strykerParent = require('stryker-parent');18var strykerParent = require('stryker-parent');19var strykerParent = require('stryker-parent');20var strykerParent = require('stryker-parent');21var strykerParent = require('stryker-parent');22var strykerParent = require('stryker-parent');23var strykerParent = require('stryker-parent');24var strykerParent = require('stryker-parent');25var strykerParent = require('stryker-parent');26var strykerParent = require('stryker-parent');27var strykerParent = require('stryker-parent');28var strykerParent = require('stryker-parent');29var strykerParent = require('stryker-parent');30var strykerParent = require('stryker-parent');31var strykerParent = require('stryker-parent');32var strykerParent = require('stryker-parent');33var strykerParent = require('stryker-parent');34var strykerParent = require('stryker-parent');35var strykerParent = require('stryker-parent');
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var result = strykerParent.replacements('Hello ${name}', {name: 'John'});3console.log(result);4var strykerParent = require('stryker-parent');5var result = strykerParent.replacements('Hello ${name}', {name: 'John'});6console.log(result);7var strykerParent = require('stryker-parent');8var result = strykerParent.replacements('Hello ${name}', {name: 'John'});9console.log(result);10var strykerParent = require('stryker-parent');11var result = strykerParent.replacements('Hello ${name}', {name: 'John'});12console.log(result);13var strykerParent = require('stryker-parent');14var result = strykerParent.replacements('Hello ${name}', {name: 'John'});15console.log(result);16var strykerParent = require('stryker-parent');17var result = strykerParent.replacements('Hello ${name}', {name: 'John'});18console.log(result);19var strykerParent = require('stryker-parent');20var result = strykerParent.replacements('Hello ${name}', {name: 'John'});21console.log(result);22var strykerParent = require('stryker-parent');23var result = strykerParent.replacements('Hello ${name}', {name: 'John'});24console.log(result);25var strykerParent = require('stryker-parent
Using AI Code Generation
1var stryker = require('stryker');2var replacements = stryker.replacements;3var str = 'foo';4str = replacements.replace(str, 'foo', 'bar');5console.log(str);6var stryker = require('stryker');7var str = 'foo';8str = stryker.replacements.replace(str, 'foo', 'bar');9console.log(str);10var stryker = require('stryker');11var str = 'foo';12str = stryker.replacements.replace(str, 'foo', 'bar');13console.log(str);14var stryker = require('stryker');15var str = 'foo';16str = stryker.replacements.replace(str, 'foo', 'bar');17console.log(str);18var stryker = require('stryker');19var str = 'foo';20str = stryker.replacements.replace(str, 'foo', 'bar');21console.log(str);22var stryker = require('stryker');23var str = 'foo';24str = stryker.replacements.replace(str, 'foo', 'bar');25console.log(str);26var stryker = require('stryker');27var str = 'foo';28str = stryker.replacements.replace(str, 'foo', 'bar');29console.log(str);30var stryker = require('stryker');31var str = 'foo';32str = stryker.replacements.replace(str, 'foo', 'bar');33console.log(str);34var stryker = require('stryker');35var str = 'foo';36str = stryker.replacements.replace(str, 'foo', 'bar');37console.log(str);38var stryker = require('stry
Using AI Code Generation
1var strykerParent = require('stryker-parent');2var stryker = strykerParent.createStryker({ files: ['src/**/*.js'] });3stryker.runMutationTest();4module.exports = function (config) {5 config.set({6 });7}8var Stryker = require('stryker');9var stryker = new Stryker({ files: ['src/**/*.js'] });10stryker.runMutationTest();11Install a test runner (if you don't have one yet):12Install a test framework (if you don't have one yet):
Using AI Code Generation
1var stryker = require("stryker-parent");2var strykerConfig = stryker.getConfig();3var replacements = strykerConfig.replacements;4console.log(replacements);5var stryker = require("stryker-parent");6var strykerConfig = stryker.getConfig();7var replacements = strykerConfig.replacements;8console.log(replacements);9module.exports = function(config) {10 config.set({11 files: ['src/**/*.{js,jsx}'],12 mutate: ['src/**/*.{js,jsx}'],13 jest: {14 config: require('./jest.config'),15 },16 replacements: {17 'src/foo.js': {18 }19 }20 });21};
Using AI Code Generation
1var strykerParent = require('stryker-parent');2strykerParent.replacements.add('foo', 'bar');3var strykerParent = require('stryker-parent');4strykerParent.replacements.remove('foo');5var strykerParent = require('stryker-parent');6var replacements = strykerParent.replacements.getAll();7var strykerParent = require('stryker-parent');8var replacement = strykerParent.replacements.get('foo');9var strykerParent = require('stryker-parent');10strykerParent.replacements.clear();11var strykerParent = require('stryker-parent');12var replacement = strykerParent.replacements.get('foo');13var strykerParent = require('stryker-parent');14strykerParent.replacements.add('foo', 'bar');15var replacement = strykerParent.replacements.get('foo');16var strykerParent = require('stryker-parent');17strykerParent.replacements.add('foo', 'bar');18strykerParent.replacements.remove('foo');19var replacement = strykerParent.replacements.get('foo');
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!!