-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Marinerer/kitify
Kitify
- Loading branch information
Showing
7 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default { | ||
input: [ | ||
{ | ||
input: 'src/index.ts', | ||
name: 'kitify', | ||
}, | ||
{ | ||
input: 'src/type.ts', | ||
name: 'kitifyType', | ||
}, | ||
], | ||
formats: ['cjs', 'esm', 'umd'], | ||
target: ['es2015', 'es5'], | ||
outDir: 'dist', | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './type' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export function isType(value: any, type?: string): string | boolean { | ||
const valType = Object.prototype.toString.call(value).slice(8, -1).toLowerCase() | ||
if (type && typeof type === 'string') { | ||
return valType === type.toLowerCase() | ||
} | ||
return valType | ||
} | ||
|
||
export const isString = (value: any) => typeof value === 'string' | ||
export const isNumber = (value: any) => typeof value === 'number' | ||
export const isBoolean = (value: any) => typeof value === 'boolean' | ||
export const isArray = (value: any) => Array.isArray(value) | ||
export const isFunction = (value: any) => typeof value === 'function' | ||
export const isSymbol = (value: any) => typeof value === 'symbol' | ||
export const isBigInt = (value: any) => typeof value === 'bigint' | ||
export const isObject = (value: any) => isType(value, 'object') | ||
|
||
export const isNil = (value: any) => value === null || value === undefined | ||
|
||
export const isEmpty = (value: any) => { | ||
if (isNil(value)) { | ||
return true | ||
} | ||
if (typeof value === 'string') { | ||
return value.trim() === '' | ||
} | ||
if (Array.isArray(value)) { | ||
return value.length === 0 | ||
} | ||
if (typeof value === 'object') { | ||
return Object.keys(value).length === 0 | ||
} | ||
return false | ||
} | ||
|
||
export const isInvalid = (value: any) => isNil(value) || Number.isNaN(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters