From 9ee63e834de01d393a4dd9ce31c0bb85548cf55c Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Sun, 8 Dec 2024 07:44:48 +0800 Subject: [PATCH] fix: rename `isObject` to `isPlainObject`, close #104 --- plugin/src/core/transform.ts | 4 ++-- plugin/src/core/validator.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/src/core/transform.ts b/plugin/src/core/transform.ts index 7dad480..55ac911 100644 --- a/plugin/src/core/transform.ts +++ b/plugin/src/core/transform.ts @@ -3,7 +3,7 @@ import { isArray, isEmptyObject, isFunction, - isObject, + isPlainObject, sortBy, toArray, } from '@pengzhanbo/utils' @@ -52,7 +52,7 @@ export function transformMockData( const mocks: Record = {} list - .filter(mock => isObject(mock) && mock.enabled !== false && mock.url) + .filter(mock => isPlainObject(mock) && mock.enabled !== false && mock.url) .forEach((mock) => { const { pathname, query } = urlParse(mock.url) const list = (mocks[pathname!] ??= []) diff --git a/plugin/src/core/validator.ts b/plugin/src/core/validator.ts index 1a26683..09fb34d 100644 --- a/plugin/src/core/validator.ts +++ b/plugin/src/core/validator.ts @@ -1,5 +1,5 @@ import type { ExtraRequest } from '../types' -import { isArray, isObject } from '@pengzhanbo/utils' +import { isArray, isPlainObject } from '@pengzhanbo/utils' export function validate( request: ExtraRequest, @@ -50,7 +50,7 @@ function isIncluded(source: unknown, target: unknown): boolean { }), ) } - if (isObject(source) && isObject(target)) + if (isPlainObject(source) && isPlainObject(target)) return isObjectSubset(source, target) // 相比于 === , 该方法能够正确的处理 NaN、 0、 +0、 -0 等特殊情况