This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 单例模式 | |
* 避免重复创建相同对象 | |
* example: | |
* let a = new TestClass(); | |
* let b = new TestClass(); | |
* a === b // false | |
* 如何a===b 为 true | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Car() { | |
console.log(this); | |
console.log(this instanceof Car); | |
this.a = 'i am a '; | |
} | |
var t = new Car(); | |
var tt = Car(); | |
console.log(t); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let carFactory = (function (name) { | |
function Benz() { | |
this.name = 'benz'; | |
} | |
function BMW() { | |
this.name = 'bmw'; | |
} | |
return function(name) { | |
switch (name) { | |
case 'benz': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 步骤 | |
* 1. 先读取文件夹 再 读取所有的json文件 | |
* 2. 再依次读取json内容 | |
* 3. 替换文件中的内容 | |
* 4. 写新的文件 到dist文件夹 | |
*/ | |
function minifyJson(rootPath) { | |
const saveDirName = 'dist'; | |
const baseFolderName = path.basename(rootPath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function PubSub() { | |
this.eventList = []; | |
} | |
PubSub.prototype.subscrible = function (eventName, callback) { | |
const currentEvent = this.eventList.find(obj => obj && obj.name === eventName); | |
if (currentEvent) { | |
this.eventList.find(obj => obj && obj.name === eventName).callback = callback; | |
} else { | |
this.eventList.push({ name: eventName, callback, }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"rules": { | |
"no-unused-expression": true, | |
"no-duplicate-variable": true, | |
"no-unused-variable": true, | |
"curly": false, | |
"class-name": true, | |
"semicolon": [true,"always"], | |
"triple-equals": true, | |
"no-var-requires": false, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
webpackJsonp([0],[ | |
/* 0 */, | |
/* 1 */ | |
/***/ (function(module, __webpack_exports__, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | |
const a = 2; | |
/* harmony default export */ __webpack_exports__["default"] = (a); | |
function run() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
webpackJsonp([0],{ | |
/***/ 9: | |
/***/ (function(module, exports, __webpack_require__) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (process.env.NODE_ENV === undefined) { | |
process.env.NODE_ENV = 'development'; | |
} | |
const webpack = require('webpack'); | |
const brfs = require('brfs'); | |
const autoprefixer = require('autoprefixer'); | |
const libraryName = process.env.NODE_ENV === 'development' ? '[name]' : '[name]_[chunkhash]'; | |
const styleLoaderName = 'style-loader'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.Aa = undefined; | |
var _berequired = require('./berequired'); | |
var _berequired2 = _interopRequireDefault(_berequired); |
OlderNewer