Skip to content

Commit a08e62c

Browse files
committed
Removed old isPlainObject impl
1 parent a2162e8 commit a08e62c

File tree

2 files changed

+4
-23
lines changed

2 files changed

+4
-23
lines changed

src/immer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export const setUseStrictShallowCopy = /* @__PURE__ */ immer.setUseStrictShallow
7272
)
7373

7474
/**
75-
* Pass false to use ultra-fast iteration that only processes enumerable string properties.
75+
* Pass false to use loose iteration that only processes enumerable string properties.
7676
* This skips symbols and non-enumerable properties for maximum performance.
7777
*
7878
* By default, strict iteration is enabled (includes all own properties).

src/utils/common.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,9 @@ export function isDraftable(value: any): boolean {
3535
}
3636

3737
const objectCtorString = Object.prototype.constructor.toString()
38-
/*#__PURE__*/
39-
export function isPlainObjectOriginal(value: any): boolean {
40-
if (!value || typeof value !== "object") return false
41-
const proto = getPrototypeOf(value)
42-
if (proto === null) {
43-
return true
44-
}
45-
const Ctor =
46-
Object.hasOwnProperty.call(proto, "constructor") && proto.constructor
47-
48-
if (Ctor === Object) return true
49-
50-
return (
51-
typeof Ctor == "function" &&
52-
Function.toString.call(Ctor) === objectCtorString
53-
)
54-
}
55-
5638
const cachedCtorStrings = new WeakMap()
57-
function isPlainObjectCached(value: any) {
39+
/*#__PURE__*/
40+
export function isPlainObject(value: any): boolean {
5841
if (!value || typeof value !== "object") return false
5942
const proto = Object.getPrototypeOf(value)
6043
if (proto === null || proto === Object.prototype) return true
@@ -74,8 +57,6 @@ function isPlainObjectCached(value: any) {
7457
return ctorString === objectCtorString
7558
}
7659

77-
export const isPlainObject = isPlainObjectCached
78-
7960
/** Get the underlying object that is represented by the given draft */
8061
/*#__PURE__*/
8162
export function original<T>(value: T): T | undefined
@@ -91,7 +72,7 @@ export function original(value: Drafted<any>): any {
9172
* @param obj The object to iterate over
9273
* @param iter The iterator function
9374
* @param strict When true (default), includes symbols and non-enumerable properties.
94-
* When false, uses ultra-fast iteration over only enumerable string properties.
75+
* When false, uses looseiteration over only enumerable string properties.
9576
*/
9677
export function each<T extends Objectish>(
9778
obj: T,

0 commit comments

Comments
 (0)