From 70379910f7d8d435aa7e43a79097a1953806e4c8 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 10 Jan 2017 21:25:41 -0800 Subject: [PATCH] Simplify `baseCreate`. --- .internal/baseCreate.js | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/.internal/baseCreate.js b/.internal/baseCreate.js index ca4dd1195..66776d99c 100644 --- a/.internal/baseCreate.js +++ b/.internal/baseCreate.js @@ -1,8 +1,5 @@ import isObject from './isObject.js'; -/** Built-in value references. */ -const objectCreate = Object.create; - /** * The base implementation of `create` without support for assigning * properties to the created object. @@ -11,20 +8,8 @@ const objectCreate = Object.create; * @param {Object} proto The object to inherit from. * @returns {Object} Returns the new object. */ -const baseCreate = (() => { - function object() {} - return proto => { - if (!isObject(proto)) { - return {}; - } - if (objectCreate) { - return objectCreate(proto); - } - object.prototype = proto; - const result = new object; - object.prototype = undefined; - return result; - }; -})(); +function baseCreate(proto) { + return isObject(proto) ? Object.create(proto) : {}; +} export default baseCreate;