Skip to content

Commit

Permalink
refactor: drop lodash for lib/hexo/index.js (#3845)
Browse files Browse the repository at this point in the history
* refactor: drop lodash.cloneDeep for lib/hexo/index.js
* refactor: drop lodash.debounce for lib/hexo/index.js
  • Loading branch information
SukkaW authored Nov 30, 2019
1 parent 7846121 commit 5fba0a0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/hexo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ const resolve = require('resolve');
const full_url_for = require('../plugins/helper/full_url_for');
const { inherits } = require('util');

const { cloneDeep, debounce } = _;

const libDir = dirname(__dirname);
const dbVersion = 1;

Expand Down Expand Up @@ -73,6 +71,20 @@ const createLoadThemeRoute = function(generatorResult, locals, ctx) {
};
};

function debounce(func, wait, immediate) {
let timeout;
return function() {
const context = this;
const args = arguments;
clearTimeout(timeout);
timeout = setTimeout(() => {
timeout = null;
if (!immediate) func.apply(context, args);
}, wait);
if (immediate && !timeout) func.apply(context, args);
};
}

class Hexo {
constructor(base = process.cwd(), args = {}) {
Reflect.apply(EventEmitter, this, []);
Expand Down Expand Up @@ -109,7 +121,7 @@ class Hexo {
tag: new extend.Tag()
};

this.config = cloneDeep(defaultConfig);
this.config = Object.assign({}, defaultConfig);

this.log = logger(this.env);

Expand Down

0 comments on commit 5fba0a0

Please sign in to comment.