From 79289737370f13d077ffa4b07d342562b19133c3 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 27 Oct 2019 14:40:42 +0800 Subject: [PATCH] refactor: simplify assignIn --- lib/theme/view.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/theme/view.js b/lib/theme/view.js index 04e5cb6e8f..7689356b64 100644 --- a/lib/theme/view.js +++ b/lib/theme/view.js @@ -4,14 +4,6 @@ const { dirname, extname, join } = require('path'); const yfm = require('hexo-front-matter'); const Promise = require('bluebird'); -const assignIn = (target, ...sources) => { - let source = []; - sources.forEach(src => { - source.push(...[src, Object.getPrototypeOf(src)]); - }); - return Object.assign(target, ...source); -}; - function View(path, data) { this.path = path; this.source = join(this._theme.base, 'layout', path); @@ -70,7 +62,8 @@ View.prototype._buildLocals = function(locals) { const data = Object.assign({}, this.data); delete data.layout; delete data._concat; - return assignIn({}, locals, data, { + + return Object.assign({}, locals, Object.getPrototypeOf(locals), data, { filename: this.source }); };