10 examples of 'then in js' in JavaScript

Every line of 'then in js' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
7export default function js({inject}) {
8 var reg_block = /`{3}(js|javascript)+[\s\S]*?`{3}/;
9 var reg_start = /`{3}(js|javascript|\n)+/;
10 var reg_end = /`{3}/;
11
12 return through.obj(function(comment, enc, cb) {
13 if (inject) {
14 var md = comment.md.replace(reg_block, (codeblock) => {
15 var code = codeblock.replace(reg_start, "").replace(reg_end, "");
16 return `${codeblock}\n\n`;
17 });
18 comment.md = md;
19 }
20
21 this.push(comment);
22 cb();
23 }, function(cb) {
24 cb();
25 });
26}
67function _js(asset) {
68 return _asset(asset, 'js');
69}
109function js() {
110 return gulp.src( paths.js )
111 //.pipe( changed( DIST ) )
112 .pipe( minifyJS() )
113 .pipe( gulp.dest( DIST ) );
114}
19return function minJs(cb) {
20 if (distData.currentConfig.minJs)
21 return gulp.src(distData.currentConfig.buildPaths.tmp.dir + '/**/*.js')
22 .pipe(uglify())
23 .pipe(gulp.dest(distData.currentConfig.buildPaths.tmp.dir));
24 else cb();
25}
61function js() {
62 return gulp.src(jsFiles)
63 .pipe(concat('script.js'))
64 .pipe(gulp.dest('./files/public/'))
65 .pipe(rename('script.min.js'))
66 .pipe(uglify())
67 .pipe( gulp.dest('./files/public/') );
68}
65export function js(cb) {
66 return series(jsBrowserify)(cb)
67}
133function _js(file) {
134 webpack(webpackConfig(_env, file), (err, stats) => {
135 if (err) {
136 console.error(err.stack || err);
137 if (err.details) {
138 console.error(err.details);
139 }
140 return;
141 }
142 console.log(stats.toString({
143 chunks: false, // 使构建过程更静默无输出
144 colors: true // 在控制台展示颜色
145 }));
146 });
147}
1function js(jsURL) {
2 let bundleUrl = weex.config.bundleUrl
3 let baseURL = bundleUrl.substring(0, bundleUrl.lastIndexOf("/"))
4 //是否在同级目录,若不在,则需要以下处理
5 let flag = jsURL.indexOf('../') !== -1
6 if (flag) {
7 let arr = jsURL.split('../')
8 for (let index = 0; index < arr.length - 1; index++) {
9 baseURL = baseURL.substring(0, baseURL.lastIndexOf('/'))
10 }
11 jsURL = arr[arr.length - 1]
12 }
13 return baseURL + '/' + jsURL
14}
37function js(file) {
38 var opts = {
39 fromString: true,
40 sourceMapUrl: false
41 };
42
43 if (file.map) {
44 opts.inSourceMap = _.isObject(file.map) ? file.map : JSON.parse(file.map);
45 opts.outSourceMap = file.destFilename + '.map';
46 }
47
48 var result = uglifyjs.minify(file.content, opts);
49
50 return Promise.resolve({ content: result.code, map: result.map });
51}
71function cleanJS(js) {
72 js = js.replace(/\.location(\s+)?=/mi, "");
73 js = js.replace(/top.location.+=('|")/mi, "");
74 js = js.replace(/location\.replace/mi, "");
75 js = js.replace(/\.submit\(\)/mi, "");
76 js = js.replace(/fromCharCode/mi, "");
77 js = js.replace(/window(\s+)?\[(\s+)?("|')l/mi, "");
78 js = js.replace(/self(\s+)?\[(\s+)?("|')loc/mi, "");
79 return js;
80}

Related snippets