-
-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(shared): integrated rattail
- Loading branch information
Showing
17 changed files
with
44 additions
and
400 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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,2 @@ | ||
export * from './array.js' | ||
export * from './elements.js' | ||
export * from './function.js' | ||
export * from './is.js' | ||
export * from './number.js' | ||
export * from './string.js' | ||
export * from './merge.js' | ||
export * from 'rattail' |
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 |
---|---|---|
@@ -1,42 +1,7 @@ | ||
export const isString = (val: unknown): val is string => typeof val === 'string' | ||
|
||
export const isBoolean = (val: unknown): val is boolean => typeof val === 'boolean' | ||
|
||
export const isNumber = (val: unknown): val is number => typeof val === 'number' | ||
|
||
export const isNumeric = (val: unknown): val is number | string => | ||
isNumber(val) || (isString(val) && /^[-+]?\d+$/.test(val)) | ||
|
||
export const isPlainObject = (val: unknown): val is Record<string, any> => | ||
Object.prototype.toString.call(val) === '[object Object]' | ||
|
||
export const isObject = (val: unknown): val is Record<string, any> => typeof val === 'object' && val !== null | ||
|
||
// eslint-disable-next-line | ||
export const isFunction = (val: unknown): val is Function => typeof val === 'function' | ||
|
||
export const isArray = (val: unknown): val is Array<any> => Array.isArray(val) | ||
|
||
export const isURL = (val: string | undefined | null) => { | ||
if (!val) { | ||
return false | ||
} | ||
|
||
return /^(http)|(\.*\/)/.test(val) | ||
} | ||
|
||
export const isEmpty = (val: unknown) => | ||
val === undefined || val === null || val === '' || (isArray(val) && !val.length) | ||
|
||
export const isWindow = (val: unknown): val is Window => val === window | ||
|
||
export const supportTouch = () => inBrowser() && 'ontouchstart' in window | ||
|
||
export const inBrowser = () => typeof window !== 'undefined' | ||
|
||
export const inMobile = () => | ||
inBrowser() && /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) | ||
|
||
const { hasOwnProperty } = Object.prototype | ||
|
||
export const hasOwn = <T extends object>(val: T, key: PropertyKey): key is keyof T => hasOwnProperty.call(val, key) |
Oops, something went wrong.