-
-
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.
- Loading branch information
1 parent
0bb4ef1
commit ad4fd10
Showing
6 changed files
with
35 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,6 @@ | ||
export function isArray(object: any): boolean { | ||
return Object.prototype.toString.call(object) === '[object Array]' | ||
} | ||
|
||
export function hasOwnProperty(obj: any, key: any) { | ||
if (!obj || !key) return false | ||
return Object.prototype.hasOwnProperty.call(obj, key) | ||
} | ||
|
||
export function isFile(object: any): boolean { | ||
if (typeof window === 'undefined' || typeof File !== 'function' || typeof FileList !== 'function') { | ||
return false | ||
} | ||
return object instanceof File || object instanceof FileList | ||
} | ||
|
||
export function is(errors: any, error: any): boolean { | ||
return isArray(error) ? error.some((w: string) => is(errors, w)) : errors.includes(error) | ||
export function is(errors: string[], errorsToCheck: string[] | string): boolean { | ||
return Array.isArray(errorsToCheck) ? errorsToCheck.some((w) => is(errors, w)) : errors.includes(errorsToCheck) | ||
} |
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 const toCamelCase = (e: string) => { | ||
return e.replace(/_([a-z])/g, (g) => g[1].toUpperCase()) | ||
} | ||
export const toSnakeCase = (e: string) => { | ||
if (!e.match(/([A-Z])/g)) return e | ||
return e.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`) | ||
} | ||
export const toCamelCase = (e: string) => e.replace(/_([a-z])/g, (g) => g[1].toUpperCase()) | ||
export const toSnakeCase = (e: string) => (e.match(/([A-Z])/g) ? e.replace(/[A-Z]/g, (l) => `_${l.toLowerCase()}`) : e) |