Skip to content

Commit ecd6523

Browse files
SukkaWThomas Parisot
authored andcommitted
refactor: drop lodash for lib/hexo/index.js (hexojs#3845)
* refactor: drop lodash.cloneDeep for lib/hexo/index.js * refactor: drop lodash.debounce for lib/hexo/index.js
1 parent 2c01bae commit ecd6523

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/hexo/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ const resolve = require('resolve');
2828
const full_url_for = require('../plugins/helper/full_url_for');
2929
const { inherits } = require('util');
3030

31-
const { cloneDeep, debounce } = _;
32-
3331
const libDir = dirname(__dirname);
3432
const dbVersion = 1;
3533

@@ -73,6 +71,20 @@ const createLoadThemeRoute = function(generatorResult, locals, ctx) {
7371
};
7472
};
7573

74+
function debounce(func, wait, immediate) {
75+
let timeout;
76+
return function() {
77+
const context = this;
78+
const args = arguments;
79+
clearTimeout(timeout);
80+
timeout = setTimeout(() => {
81+
timeout = null;
82+
if (!immediate) func.apply(context, args);
83+
}, wait);
84+
if (immediate && !timeout) func.apply(context, args);
85+
};
86+
}
87+
7688
class Hexo {
7789
constructor(base = process.cwd(), args = {}) {
7890
Reflect.apply(EventEmitter, this, []);
@@ -109,7 +121,7 @@ class Hexo {
109121
tag: new extend.Tag()
110122
};
111123

112-
this.config = cloneDeep(defaultConfig);
124+
this.config = Object.assign({}, defaultConfig);
113125

114126
this.log = logger(this.env);
115127

0 commit comments

Comments
 (0)