Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules/
dist/
19 changes: 0 additions & 19 deletions index.d.ts

This file was deleted.

38 changes: 0 additions & 38 deletions index.js

This file was deleted.

16 changes: 15 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint ."
"lint": "eslint .",
"build": "tsc"
},
"repository": {
"type": "git",
Expand All @@ -29,6 +30,7 @@
"devDependencies": {
"@eslint/js": "^9.18.0",
"eslint": "^9.18.0",
"globals": "^15.14.0"
"globals": "^15.14.0",
"typescript": "^5.7.3"
}
}
34 changes: 34 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
export const isArray = (value: any): value is any[] => Array.isArray(value);
export const isString = (value: any): value is string =>
typeof value === "string";
export const isFunction = (value: any): value is Function =>
typeof value === "function";
export const isObject = (value: any): value is object =>
Object.prototype.toString.call(value) === "[object Object]";
export const hasLength = (arg: any): boolean => Boolean(arg && arg.length > 0);
export const isBoolean = (value: any): value is boolean =>
typeof value === "boolean";
export const isDate = (value: any): value is Date =>
value instanceof Date && !isNaN(value as any);
export const isNumber = (value: any): value is number =>
typeof value === "number";
export const isObjectEmpty = (value: any): boolean =>
Object.keys(value).length === 0;
export const isStringHasLength = (value: any): boolean =>
isString(value) && hasLength(value);
export const isStringEmpty = (value: any): boolean =>
isString(value) && !hasLength(value);
export const isArrayHasLength = (value: any): boolean =>
isArray(value) && hasLength(value);
export const isArrayEmpty = (value: any): boolean =>
isArray(value) && !hasLength(value);
export const isObjectHasProps = (value: any): boolean =>
isObject(value) && !isObjectEmpty(value);
export const isBooleanTruthy = (value: any): boolean =>
isBoolean(value) && value;
export const isBooleanFalsey = (value: any): boolean =>
isBoolean(value) && !value;
export const isHTML = (value: any): boolean => {
const htmlRegex = /<[^>]*>/g;
return htmlRegex.test(value);
};
15 changes: 15 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "ES6",
"module": "ES6",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"declaration": true, // Generate declaration files
"declarationDir": "./dist" // Place declaration files in the dist directory
},
"include": ["src/**/*"]
}