Best JavaScript code snippet using fast-check-monorepo
gulpfile.js
Source:gulpfile.js
1// ä¿®å¤ gulp-uglify exceptä¸å¯ç¨çbugï¼éè¦æ¹æreserved2var config = require('./config');3var gulp = require('gulp');4var minifyCss = require('gulp-clean-css'); //- å缩CSS为ä¸è¡ï¼5var htmlmin = require('gulp-htmlmin');6var rev = require('gulp-rev'); //- 对æ件åå MD5åç¼7var revCollector = require('gulp-rev-collector'); //- è·¯å¾æ¿æ¢8var clean = require('gulp-clean');9var uglify = require('gulp-uglify')10 //串è¡æ§è¡ä»»å¡11var runSequence = require('run-sequence');12//å个taskä¸å并å¤ä¸ªæ¥éª¤13var mergeStream = require('merge-stream');14//å¾çå缩ç¸å
³15var imagemin = require('gulp-imagemin');16//cach17var cache = require('gulp-cache');18//é误æåºçè¡¥ä¸->é²æ¢å¼å¸¸æ
åµä¸åæ¢ç¨åº19var plumber = require('gulp-plumber');2021var handleErrors = function(error) {22 //继ç»çå¬23 console.log("~~~é误:" + error);24};25//æ
åµä»¥åç®å½26gulp.task('clean', function() {27 return gulp.src([28 config.clean.src29 ])30 //å¼å¸¸å¤ççè¡¥ä¸31 .pipe(plumber({32 errorHandler: handleErrors33 }))34 .pipe(clean({35 force: true36 }));37});38//å¤çéè¦md5ç¾åçå¾ç39gulp.task('dealMd5Img', function() {40 //æé¤html/**/imgä¸é¢ç41 //æé¤/libs/**/imgä¸ç42 return gulp.src([config.img.src, '!' + config.html.img.src, '!' + config.libs.img.src])43 .pipe(plumber({44 errorHandler: handleErrors45 }))46 .pipe(cache(imagemin({47 optimizationLevel: 3,48 progressive: true,49 interlaced: true50 })))51 .pipe(rev())52 .pipe(gulp.dest(config.img.dest))53 .pipe(rev.manifest(config.img.revJson, {54 //ä¸å并55 merge: false56 }))57 //å 为已ç»è¿å
¥äºjsonäº,æ以é»è®¤./å°±è¡58 .pipe(gulp.dest('./'));59});60//å¤çå
¶ä»çå¾ç-é¤å»ä¸é¢å缩åç61gulp.task('dealOtherImg', function() {62 //html/**/imgä¸é¢ç63 ///libs/**/imgä¸ç64 var htmlImg = gulp.src([config.html.img.src])65 .pipe(plumber({66 errorHandler: handleErrors67 }))68 .pipe(cache(imagemin({69 optimizationLevel: 3,70 progressive: true,71 interlaced: true72 })))73 .pipe(gulp.dest(config.html.img.dest));74 var libsImg = gulp.src([config.libs.img.src])75 .pipe(plumber({76 errorHandler: handleErrors77 }))78 .pipe(cache(imagemin({79 optimizationLevel: 3,80 progressive: true,81 interlaced: true82 })))83 .pipe(gulp.dest(config.libs.img.dest));8485 return mergeStream(htmlImg, libsImg);86});87//å缩并å¤ç json-è¿ä¸ªæ¯jsonæ件夹ä¸é¢çé
ç½®,åªå¤çè¿ä¸ªæ件夹88gulp.task('dealJSON', function() {89 return gulp.src([config.json.src])90 .pipe(plumber({91 errorHandler: handleErrors92 }))93 .pipe(cache(imagemin({94 optimizationLevel: 3,95 progressive: true,96 interlaced: true97 })))98 .pipe(rev())99 .pipe(gulp.dest(config.json.dest))100 .pipe(rev.manifest(config.json.revJson, {101 //ä¸å并102 merge: false103 }))104 //å 为已ç»è¿å
¥äºjsonäº,æ以é»è®¤./å°±è¡105 .pipe(gulp.dest('./'));106});107//å¤çcss108gulp.task('dealCss', function() {109 //- éè¦å¤ççcssæ件ï¼å
æ¿æ¢éé¢çå¾ç,ç¶ååå缩md5ç¾å110 //æé¤libsä¸çcss111 return gulp.src([config.rev.revJson, config.css.src])112 .pipe(plumber({113 errorHandler: handleErrors114 }))115 .pipe(revCollector())116 .pipe(minifyCss()) //- å缩å¤çæä¸è¡117 .pipe(rev()) //- æ件åå MD5åç¼118 .pipe(gulp.dest(config.css.dest)) //- è¾åºæ件æ¬å°,*å·ä¼èªå¨è¾åº119 .pipe(rev.manifest(config.css.revJson, {120 merge: false121 }))122 .pipe(gulp.dest('./')); //- å° rev-manifest.json ä¿åå° rev ç®å½å
123});124//å
å¤çæ¡æ¶ç¬¬ä¸æ¹ä¸ä¼ä¾èµå
¶å®èæ¬çæ件,æé¤seajsçé
ç½®,æé¤cacheConfigé
ç½®125//å
å¤ççcss,æ以coreéå°±ç®æå¼ç¨cssä¹æ²¡é®é¢126gulp.task('dealCoreJs', function() {127 //- éè¦å¤ççcssæ件ï¼å
æ¿æ¢éé¢çå¾ç,ç¶ååå缩md5ç¾å128 return gulp.src([config.rev.revJson, config.js.coreJs.src, '!' + config.js.seaConfigJs.src, '!' + config.js.cacheConfigJs.src])129 .pipe(plumber({130 errorHandler: handleErrors131 }))132 .pipe(revCollector())133 .pipe(uglify({134 //mangle: true,//ç±»åï¼Boolean é»è®¤ï¼true æ¯å¦ä¿®æ¹åéå135 mangle: {136 reserved: ['require', 'exports', 'module', '$']137 } //æé¤æ··æ·å
³é®å138 }))139 .pipe(rev())140 .pipe(gulp.dest(config.js.coreJs.dest))141 .pipe(rev.manifest(config.js.coreJs.revJson, {142 merge: false143 }))144 .pipe(gulp.dest('./'));145});146//åå¤çä¸å¡js,ä¼ä¾èµäºä»¥ä¸ç两ç§js147//æé¤ä¸å¡å¤ççconfig148gulp.task('dealBizlogicJs', function() {149 //- éè¦å¤ççcssæ件ï¼å
æ¿æ¢éé¢çå¾ç,ç¶ååå缩md5ç¾å150 return gulp.src([config.rev.revJson, config.js.bizlogicJs.src, '!' + config.js.bizConfigJs.src])151 .pipe(plumber({152 errorHandler: handleErrors153 }))154 .pipe(revCollector())155 .pipe(uglify({156 //mangle: true,//ç±»åï¼Boolean é»è®¤ï¼true æ¯å¦ä¿®æ¹åéå157 mangle: {158 reserved: ['require', 'exports', 'module', '$']159 } //æé¤æ··æ·å
³é®å160 }))161 .pipe(rev())162 .pipe(gulp.dest(config.js.bizlogicJs.dest))163 .pipe(rev.manifest(config.js.bizlogicJs.revJson, {164 merge: false165 }))166 .pipe(gulp.dest('./'));167});168169//åå¤çseajsçé
ç½®,æè
æ¯é¡¹ç®ä¸çé
ç½®170gulp.task('dealSeaConfig', function() {171 //- éè¦å¤ççcssæ件ï¼å
æ¿æ¢éé¢çå¾ç,ç¶ååå缩md5ç¾å172 return gulp.src([config.rev.revJson, config.js.seaConfigJs.src])173 .pipe(plumber({174 errorHandler: handleErrors175 }))176 .pipe(revCollector())177 .pipe(uglify({178 //mangle: true,//ç±»åï¼Boolean é»è®¤ï¼true æ¯å¦ä¿®æ¹åéå179 mangle: {180 reserved: ['require', 'exports', 'module', '$']181 } //æé¤æ··æ·å
³é®å182 }))183 .pipe(rev())184 .pipe(gulp.dest(config.js.seaConfigJs.dest))185 .pipe(rev.manifest(config.js.seaConfigJs.revJson, {186 //å
许å并以åçbizConfig187 //è¿é注æ,å¦ææ¯éè¿è·¯å¾æ¾å°çjsonï¼åmergeæç¨,å¦åmerge并没æç¨188 merge: true189 }))190 .pipe(gulp.dest('./'));191});192//å¤çbizConfigJsçé
ç½®,æè
æ¯é¡¹ç®ä¸çé
ç½®193//æé¤ä¸å¡è®¾ç½®çè·¯å¾194gulp.task('dealBizConfig', function() {195 //- éè¦å¤ççcssæ件ï¼å
æ¿æ¢éé¢çå¾ç,ç¶ååå缩md5ç¾å196 return gulp.src([config.rev.revJson, config.js.bizConfigJs.src])197 .pipe(plumber({198 errorHandler: handleErrors199 }))200 .pipe(revCollector())201 .pipe(uglify({202 //mangle: true,//ç±»åï¼Boolean é»è®¤ï¼true æ¯å¦ä¿®æ¹åéå203 mangle: {204 reserved: ['require', 'exports', 'module', '$']205 } //æé¤æ··æ·å
³é®å206 }))207 .pipe(rev())208 .pipe(gulp.dest(config.js.bizConfigJs.dest))209 .pipe(rev.manifest(config.js.bizConfigJs.revJson, {210 merge: true211 }))212 .pipe(gulp.dest('./'));213});214//cacheController->æ§å¶å¼å
¥seaConfig215gulp.task('dealCacheConfigJs', function() {216 //- éè¦å¤ççcssæ件ï¼å
æ¿æ¢éé¢çå¾ç,ç¶ååå缩md5ç¾å217 return gulp.src([config.rev.revJson, config.js.cacheConfigJs.src])218 .pipe(plumber({219 errorHandler: handleErrors220 }))221 .pipe(revCollector())222 .pipe(uglify({223 //mangle: true,//ç±»åï¼Boolean é»è®¤ï¼true æ¯å¦ä¿®æ¹åéå224 mangle: {225 reserved: ['require', 'exports', 'module', '$']226 } //æé¤æ··æ·å
³é®å227 }))228 .pipe(rev())229 .pipe(gulp.dest(config.js.cacheConfigJs.dest))230 .pipe(rev.manifest(config.js.cacheConfigJs.revJson, {231 merge: true232 }))233 .pipe(gulp.dest('./'));234});235//å¤çhtml236gulp.task('dealHtml', function() {237 //- éè¦å¤ççcssæ件ï¼å
æ¿æ¢éé¢çå¾ç,ç¶ååå缩md5ç¾å238 return gulp.src([config.rev.revJson, config.html.src])239 .pipe(plumber({240 errorHandler: handleErrors241 }))242 .pipe(revCollector())243 .pipe(htmlmin({244 collapseWhitespace: true,245 collapseBooleanAttributes: true,246 removeComments: true,247 removeEmptyAttributes: true,248 removeScriptTypeAttributes: true,249 removeStyleLinkTypeAttributes: true,250 //ææ¶åæè¿ä¸ªé
ç½®ä¼åºé(å½ä»£ç ä½ä¸ºç¤ºä¾æ¾ç¤ºæ¶),æ以èæ¬åcssåªå缩åç¬çæ件251 minifyJS: true,252 minifyCSS: true253 })) //å缩254 .pipe(gulp.dest(config.html.dest));255});256//å¤çå
¶å®,é¤å»img,css,html,js,以å¤ç,åç¬å
æ¬.projectæ件257gulp.task('dealOthers', function() {258 //åºå»svn259 return gulp.src([config.other.src, config.other.project.src, '!' + config.js.coreJs.src, '!' + config.js.bizlogicJs.src, '!' + config.css.src, '!' + config.html.src, '!' + config.json.src, '!' + config.img.src, '!' + config.other.svn.src, '!' + config.other.settings.src])260 .pipe(plumber({261 errorHandler: handleErrors262 }))263 .pipe(gulp.dest(config.other.dest));264});265266// çå®267gulp.task('watch', function() {268269 console.log("è·¯å¾:" + config.src + '/gulpWatch.json');270 // çå®ææä½å¨ dist/ ç®å½ä¸çæ¡£æ¡ï¼ä¸æ¦ææ´å¨ï¼ä¾¿è¿è¡éæ´271 // gulp.watch([config.src+'/gulpWatch.json']).on('change', function(file) {272 // console.log("æ¹å¨");273 // });274 gulp.watch(config.src + '/gulpWatch.json', ['default']);275276});277//å缩æ¡æ¶æ件,ä»
ä»
å缩278gulp.task('MiniCoreJs', function() {279 //- éè¦å¤ççcssæ件ï¼å
æ¿æ¢éé¢çå¾ç,ç¶ååå缩md5ç¾å280 return gulp.src([config.js.coreJs.src])281 .pipe(plumber({282 errorHandler: handleErrors283 }))284 //.pipe(revCollector())285 .pipe(uglify({286 //mangle: true,//ç±»åï¼Boolean é»è®¤ï¼true æ¯å¦ä¿®æ¹åéå287 mangle: {288 reserved: ['require', 'exports', 'module', '$']289 } //æé¤æ··æ·å
³é®å290 }))291 //.pipe(rev())292 .pipe(gulp.dest(config.js.coreJs.dest))293// .pipe(rev.manifest(config.js.coreJs.revJson, {294// merge: false295// }))296// .pipe(gulp.dest('./'));297});298gulp.task('default', function(callback) {299 if(!config.isMiniJs){300 runSequence('clean', 'dealMd5Img', 'dealOtherImg', 'dealJSON', 'dealCss', 'dealCoreJs', 'dealBizlogicJs', 'dealSeaConfig', 'dealBizConfig', 'dealCacheConfigJs', 'dealHtml', 'dealOthers',301 callback);302 }else{303 runSequence('MiniCoreJs',304 callback);305 }306
...
config.js
Source:config.js
1/**2 * ä½è
: dailc3 * æ¶é´: 2016-06-22 4 * æè¿°: gulpçä¸äºé
ç½®,å
æ¬è·¯å¾,项ç®å±çº§5 * 6 */7(function() {8 //项ç®path,é»è®¤ä¸º''代表ä¸ä½¿ç¨é¡¹ç®path9 //示ä¾/testproject10 //var projectPath = '/testDemo'11 var projectPath = '/showcase.dcloud.rayapp'12 var src = './src' + projectPath;13 var dest = './build' + projectPath;14 var rev = './rev' + projectPath;15 var isMiniJs = false;16 //å®ä¹çä¸äºæ件ç¼è¯åè¾åºè·¯å¾,å¯ä»¥ä¸ç¨ç®¡å¤ªå¤17 module.exports = {18 //å¦æsrcåæ**,ç®å½ä¼èªå¨è¡¥é½19 src:src,20 dest:dest,21 rev:rev,22 css: {23 //ææéè¦ç¼è¯çcss24 src: src + '/**/css/**/*.css',25 //è¾åºç®å½26 dest: dest + "",27 //jsonç®å½28 revJson: rev + "/rev-manifest-css.json"29 },30 js: {31 src: src + '/js/**/*.js',32 coreJs: {33 src: src + '/**/js/core/**/*.js',34 dest: dest + "",35 revJson: rev + "/rev-manifest-coreJs.json"36 },37 bizlogicJs: {38 src: src + '/**/js/bizlogic/**/*.js',39 dest: dest + "",40 revJson: rev + "/rev-manifest-bizlogicJs.json"41 },42 //seaConfig-以ä¸ä¸ä¸ªconfigä¼å并43 seaConfigJs: {44 src: src + '/**/sea.config.js',45 dest: dest + "",46 revJson: rev + "/rev-manifest-config.json"47 },48 //ä¸å¡å¤ççconfig ->å
æ¬èªå®ä¹seaå«åç49 bizConfigJs: {50 src: src + '/**/bizlogic/config/seaBizConfig.js',51 dest: dest + "",52 revJson: rev + "/rev-manifest-config.json"53 },54 //cacheController->æ§å¶å¼å
¥seaConfig55 cacheConfigJs: {56 src: src + '/**/cacheControl.config.js',57 dest: dest + "",58 revJson: rev + "/rev-manifest-config.json"59 }60 },61 //é»è®¤å¾çåªå¤çimgç®å½ä¸ç,å
¶å®ç®å½ä¸çç±äºè·¯å¾é®é¢ä¸å¥½æ¿æ¢62 //æ以imgæ件夹ä¸è¯·å«æ¾å
¶å®æ件63 //ç±äºæäºé¡¹ç®ç´æ¥å¨htmléåæimg,æ以æ建æ¶å¾åç¬æé¤é£ä¸é¨å64 img: {65 jpg: {66 src: src + '/img/**/*.jpg'67 },68 png: {69 src: src + '/img/**/*.png'70 },71 gif: {72 src: src + '/img/**/*.gif'73 },74 src: src + '/**/img/**/*',75 dest: dest + "",76 revJson: rev + "/rev-manifest-img.json"77 },78 //åªå¤çjsonæ件夹ä¸é¢çjson79 json: {80 src: src + '/**/json/**/*.json',81 dest: dest + "",82 revJson: rev + "/rev-manifest-json.json"83 },84 clean: {85 src: dest86 },87 html: {88 img: {89 src: src + '/html/**/img/**/*',90 dest: dest + "/html"91 },92 src: src + "/**/*.html",93 dest: dest + ""94 },95 //å¼ç¨,æ建å¾çæ¶éè¦è¿æ»¤ælibsä¸å¼ç¨çå¾ç96 libs: {97 img: {98 src: src + '/libs/**/img/**/*',99 dest: dest + "/libs"100 }101 },102 other: {103 project: {104 src: src + "/**/.project",105 },106 svn: {107 src: src + "/**/.svn/*",108 },109 settings: {110 src: src + "/**/.settings/*",111 },112 src: src + "/**/*",113 dest: dest + ""114 },115 rev: { //use rev to reset html resource url116 revJson: rev + "/**/*.json"117 },118 isMiniJs:isMiniJs119 };...
Using AI Code Generation
1const { revJson } = require('fast-check-monorepo');2const revJsonResult = revJson({ a: 1, b: 2 });3console.log(revJsonResult);4const { revJson } = require('fast-check-monorepo');5const revJsonResult = revJson({ a: 1, b: 2 });6console.log(revJsonResult);7const { revJson } = require('fast-check-monorepo');8const revJsonResult = revJson({ a: 1, b: 2 });9console.log(revJsonResult);10const { revJson } = require('fast-check-monorepo');11const revJsonResult = revJson({ a: 1, b: 2 });12console.log(revJsonResult);13const { revJson } = require('fast-check-monorepo');14const revJsonResult = revJson({ a: 1, b: 2 });15console.log(revJsonResult);16const { revJson } = require('fast-check-monorepo');17const revJsonResult = revJson({ a: 1, b: 2 });18console.log(revJsonResult);19const { revJson } = require('fast-check-monorepo');20const revJsonResult = revJson({ a: 1, b: 2 });21console.log(revJsonResult);22const { revJson } = require('fast-check-monorepo');23const revJsonResult = revJson({ a: 1, b: 2 });24console.log(revJsonResult);25const { revJson } = require('fast-check-monorepo');
Using AI Code Generation
1const revJson = require('fast-check-monorepo').revJson;2const input = { a: 1, b: 2, c: 3 };3const output = revJson(input);4console.log(output);5const revJson = require('fast-check-monorepo').revJson;6const input = { a: 1, b: 2, c: 3 };7const output = revJson(input);8console.log(output);9const revJson = require('fast-check-monorepo').revJson;10const input = { a: 1, b: 2, c: 3 };11const output = revJson(input);12console.log(output);13const revJson = require('fast-check-monorepo').revJson;14const input = { a: 1, b: 2, c: 3 };15const output = revJson(input);16console.log(output);17const revJson = require('fast-check-monorepo').revJson;18const input = { a: 1, b: 2, c: 3 };19const output = revJson(input);20console.log(output);21const revJson = require('fast-check-monorepo').revJson;22const input = { a: 1, b: 2, c: 3 };23const output = revJson(input);24console.log(output);25const revJson = require('fast-check-monorepo').revJson;26const input = { a: 1, b: 2, c: 3 };27const output = revJson(input);28console.log(output);29const revJson = require('fast-check-monorepo').revJson;30const input = { a: 1, b: 2, c: 3 };
Using AI Code Generation
1const revJson = require('fast-check-monorepo').revJson;2const obj = {a: 1, b: 2};3const rev = revJson(obj);4console.log(rev);5const revJson = require('fast-check-monorepo').revJson;6const obj = {a: 1, b: 2};7const rev = revJson(obj);8console.log(rev);
Using AI Code Generation
1const { revJson } = require('fast-check-monorepo');2const json = {3 d: { e: 1, f: 2 }4};5const rev = revJson(json);6console.log(rev);7const { revJson } = require('fast-check-monorepo');8const json = {9 d: { e: 1, f: 2 }10};11const rev = revJson(json);12console.log(rev);13const { revJson } = require('fast-check-monorepo');14const json = {15 d: { e: 1, f: 2 }16};17const rev = revJson(json);18console.log(rev);19const { revJson } = require('fast-check-monorepo');20const json = {21 d: { e: 1, f: 2 }22};23const rev = revJson(json);24console.log(rev);25const { revJson } = require('fast-check-monorepo');26const json = {27 d: { e: 1, f: 2 }28};29const rev = revJson(json);30console.log(rev);31const { revJson } = require('fast-check-monorepo');32const json = {33 d: { e:
Using AI Code Generation
1const { revJson } = require('fast-check-monorepo');2const { fc } = require('fast-check');3const arb = fc.object();4const revJsonArb = arb.map(revJson);5fc.assert(6 fc.property(revJsonArb, (a) => {7 return JSON.parse(revJson(JSON.stringify(a))) === a;8 })9);
Using AI Code Generation
1const fc = require('fast-check');2const revJson = require('fast-check').revJson;3const revJsonTests = () => {4 it('should return an empty string when given an empty string', () => {5 fc.assert(6 fc.property(fc.string(), (s) => {7 revJson(s).should.equal('');8 })9 );10 });11};12describe('revJson', revJsonTests);
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!!