Skip to content

Commit a891796

Browse files
committedJan 15, 2023
fix(path): add upath test functions
1 parent 6a34606 commit a891796

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed
 

‎packages/core/src/utils/path.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import basepath from 'path';
2-
import { isString, isUrl } from './assertion';
2+
import { isUrl } from './assertion';
33
import { getExtension } from './extension';
44
import { getFileInfo } from './file';
55

@@ -8,8 +8,22 @@ import { getFileInfo } from './file';
88
type Path = typeof basepath;
99
const path = {} as Path;
1010

11+
const isFunction = (val: any) => typeof val == 'function';
12+
13+
const isString = (val: any) => {
14+
if (typeof val === 'string') {
15+
return true;
16+
}
17+
18+
if (typeof val === 'object' && val !== null) {
19+
return Object.toString.call(val) == '[object String]';
20+
}
21+
22+
return false;
23+
};
24+
1125
Object.entries(basepath).forEach(([propName, propValue]) => {
12-
if (typeof propValue === 'function') {
26+
if (isFunction(propValue)) {
1327
// @ts-ignore
1428
path[propName] = ((propName) => {
1529
return (...args: any[]) => {

1 commit comments

Comments
 (1)

vercel[bot] commented on Jan 15, 2023

@vercel[bot]
Please sign in to comment.