Simplify baseCreate.

This commit is contained in:
John-David Dalton
2017-01-10 21:25:41 -08:00
parent 41e6991d2e
commit 70379910f7

View File

@@ -1,8 +1,5 @@
import isObject from './isObject.js'; import isObject from './isObject.js';
/** Built-in value references. */
const objectCreate = Object.create;
/** /**
* The base implementation of `create` without support for assigning * The base implementation of `create` without support for assigning
* properties to the created object. * properties to the created object.
@@ -11,20 +8,8 @@ const objectCreate = Object.create;
* @param {Object} proto The object to inherit from. * @param {Object} proto The object to inherit from.
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
*/ */
const baseCreate = (() => { function baseCreate(proto) {
function object() {} return isObject(proto) ? Object.create(proto) : {};
return proto => { }
if (!isObject(proto)) {
return {};
}
if (objectCreate) {
return objectCreate(proto);
}
object.prototype = proto;
const result = new object;
object.prototype = undefined;
return result;
};
})();
export default baseCreate; export default baseCreate;