Skip to content

Commit 369ba70

Browse files
committed
share isObject code
1 parent 0e48535 commit 369ba70

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/node/config.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { resolvePages } from './plugins/dynamicRoutesPlugin'
1616
import {
1717
APPEARANCE_KEY,
1818
VP_SOURCE_KEY,
19+
isObject,
1920
slash,
2021
type AdditionalConfig,
2122
type Awaitable,
@@ -309,10 +310,6 @@ export function mergeConfig(a: UserConfig, b: UserConfig, isRoot = true) {
309310
return merged
310311
}
311312

312-
function isObject(value: unknown): value is Record<string, any> {
313-
return Object.prototype.toString.call(value) === '[object Object]'
314-
}
315-
316313
export async function resolveSiteData(
317314
root: string,
318315
userConfig?: UserConfig,

src/shared/shared.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ function reportConfigLayers(path: string, layers: SiteData[]) {
291291
*/
292292
export function stackView<T extends object>(...layers: Partial<T>[]): T {
293293
layers = layers.filter((layer) => layer !== undefined)
294-
if (!isStackable(layers[0])) return layers[0] as T
295-
layers = layers.filter(isStackable)
294+
if (!isObject(layers[0])) return layers[0] as T
295+
layers = layers.filter(isObject)
296296
if (layers.length <= 1) return layers[0] as T
297297
return new Proxy(
298298
{},
@@ -331,11 +331,11 @@ export function stackView<T extends object>(...layers: Partial<T>[]): T {
331331
) as T
332332
}
333333

334-
function isStackable(obj: any) {
335-
return typeof obj === 'object' && obj !== null && !Array.isArray(obj)
336-
}
337-
338334
const UnpackStackView = Symbol('stack-view:unpack')
339335
stackView.unpack = function <T>(obj: T): T[] | undefined {
340336
return (obj as any)?.[UnpackStackView]
341337
}
338+
339+
export function isObject(value: unknown): value is Record<string, any> {
340+
return Object.prototype.toString.call(value) === '[object Object]'
341+
}

0 commit comments

Comments
 (0)