Skip to content

Commit b0980a9

Browse files
committed
Remove baseCreate.
1 parent 7479d28 commit b0980a9

File tree

7 files changed

+6
-143
lines changed

7 files changed

+6
-143
lines changed

Diff for: .internal/baseClone.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import arrayEach from './arrayEach.js'
33
import assignValue from './assignValue.js'
44
import baseAssign from './baseAssign.js'
55
import baseAssignIn from './baseAssignIn.js'
6-
import baseCreate from './baseCreate.js'
76
import cloneBuffer from './cloneBuffer.js'
87
import copyArray from './copyArray.js'
98
import cloneArrayBuffer from './cloneArrayBuffer.js'
@@ -88,7 +87,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty
8887
*/
8988
function initCloneObject(object) {
9089
return (typeof object.constructor == 'function' && !isPrototype(object))
91-
? baseCreate(Object.getPrototypeOf(object))
90+
? Object.create(Object.getPrototypeOf(object))
9291
: {}
9392
}
9493

@@ -150,7 +149,7 @@ function initCloneByTag(object, tag, cloneFunc, isDeep) {
150149
*/
151150
function initCloneArray(array) {
152151
const length = array.length
153-
const result = array.constructor(length)
152+
const result = new array.constructor(length)
154153

155154
// Add properties assigned by `RegExp#exec`.
156155
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {

Diff for: .internal/baseCreate.js

-15
This file was deleted.

Diff for: .internal/createCtor.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import baseCreate from './baseCreate.js'
21
import isObject from '../isObject.js'
32

43
/**
@@ -24,7 +23,8 @@ function createCtor(Ctor) {
2423
case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5])
2524
case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6])
2625
}
27-
const thisBinding = baseCreate(Ctor.prototype)
26+
const proto = Ctor.prototype
27+
const thisBinding = proto == null ? {} : Object.create(Object(proto))
2828
const result = Ctor.apply(thisBinding, args)
2929

3030
// Mimic the constructor's `return` behavior.

Diff for: .internal/initCloneArray.js

-23
This file was deleted.

Diff for: .internal/initCloneByTag.js

-80
This file was deleted.

Diff for: .internal/initCloneObject.js

-17
This file was deleted.

Diff for: create.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import baseCreate from './.internal/baseCreate.js'
2-
31
/**
42
* Creates an object that inherits from the `prototype` object. If a
53
* `properties` object is given, its own enumerable string keyed properties
@@ -33,7 +31,8 @@ import baseCreate from './.internal/baseCreate.js'
3331
* // => true
3432
*/
3533
function create(prototype, properties) {
36-
const result = baseCreate(prototype)
34+
prototype = prototype === null ? null : Object(prototype)
35+
const result = Object.create(prototype)
3736
return properties == null ? result : Object.assign(result, properties)
3837
}
3938

0 commit comments

Comments
 (0)