- 判断成员是否是一个函数:
if (typeof options.sourceMapName === 'function') { mapNameGenerator = options.sourceMapName; } |
- Try/Catch
var result; try { result = uglify.minify(availableFiles, f.dest, options); } catch (e) { console.log(e); err = new Error('Uglification failed.'); if (e.message) { err.message += '\n' + e.message + '. \n'; if (e.line) { err.message += 'Line ' + e.line + ' in ' + availableFiles + '\n'; } } err.origError = e; grunt.log.warn('Uglifying source ' + chalk.cyan(availableFiles) + ' failed.'); grunt.fail.warn(err); } |
- 将一个数组里面的值用某个符号拼接起来。
var unCompiledJSString = availableFiles.map(function (file) { return grunt.file.read(file); }).join(''); |