Skip to content

Commit 4747c8d

Browse files
Merge pull request #3 from garydavisonos/task/gd/babel
Task/gd/babel
2 parents a672910 + 1c816d6 commit 4747c8d

File tree

7 files changed

+70
-61
lines changed

7 files changed

+70
-61
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules/
2+
dist/

index.d.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

index.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

package-lock.json

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
8-
"lint": "eslint ."
8+
"lint": "eslint .",
9+
"build": "tsc"
910
},
1011
"repository": {
1112
"type": "git",
@@ -29,6 +30,7 @@
2930
"devDependencies": {
3031
"@eslint/js": "^9.18.0",
3132
"eslint": "^9.18.0",
32-
"globals": "^15.14.0"
33+
"globals": "^15.14.0",
34+
"typescript": "^5.7.3"
3335
}
3436
}

src/index.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
export const isArray = (value: any): value is any[] => Array.isArray(value);
2+
export const isString = (value: any): value is string =>
3+
typeof value === "string";
4+
export const isFunction = (value: any): value is Function =>
5+
typeof value === "function";
6+
export const isObject = (value: any): value is object =>
7+
Object.prototype.toString.call(value) === "[object Object]";
8+
export const hasLength = (arg: any): boolean => Boolean(arg && arg.length > 0);
9+
export const isBoolean = (value: any): value is boolean =>
10+
typeof value === "boolean";
11+
export const isDate = (value: any): value is Date =>
12+
value instanceof Date && !isNaN(value as any);
13+
export const isNumber = (value: any): value is number =>
14+
typeof value === "number";
15+
export const isObjectEmpty = (value: any): boolean =>
16+
Object.keys(value).length === 0;
17+
export const isStringHasLength = (value: any): boolean =>
18+
isString(value) && hasLength(value);
19+
export const isStringEmpty = (value: any): boolean =>
20+
isString(value) && !hasLength(value);
21+
export const isArrayHasLength = (value: any): boolean =>
22+
isArray(value) && hasLength(value);
23+
export const isArrayEmpty = (value: any): boolean =>
24+
isArray(value) && !hasLength(value);
25+
export const isObjectHasProps = (value: any): boolean =>
26+
isObject(value) && !isObjectEmpty(value);
27+
export const isBooleanTruthy = (value: any): boolean =>
28+
isBoolean(value) && value;
29+
export const isBooleanFalsey = (value: any): boolean =>
30+
isBoolean(value) && !value;
31+
export const isHTML = (value: any): boolean => {
32+
const htmlRegex = /<[^>]*>/g;
33+
return htmlRegex.test(value);
34+
};

tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES6",
4+
"module": "ES6",
5+
"outDir": "./dist",
6+
"rootDir": "./src",
7+
"strict": true,
8+
"esModuleInterop": true,
9+
"skipLibCheck": true,
10+
"forceConsistentCasingInFileNames": true,
11+
"declaration": true, // Generate declaration files
12+
"declarationDir": "./dist" // Place declaration files in the dist directory
13+
},
14+
"include": ["src/**/*"]
15+
}

0 commit comments

Comments
 (0)