Ensure getObjectType is defined before first use
This commit is contained in:
parent
e3f729ec7c
commit
c20141b366
1 changed files with 6 additions and 5 deletions
|
|
@ -34,11 +34,6 @@ export enum TypeName {
|
|||
|
||||
const toString = Object.prototype.toString;
|
||||
const isOfType = (type: string) => (value: any) => typeof value === type; // tslint:disable-line:strict-type-predicates
|
||||
const isObjectOfType = (typeName: string | TypeName) => (value: any) => {
|
||||
const type = typeName === 'string' ? TypeName[typeName] : typeName;
|
||||
|
||||
return getObjectType(value) === type;
|
||||
};
|
||||
|
||||
const getObjectType = (value: any): TypeName | null => {
|
||||
const objectName = toString.call(value).slice(8, -1) as string;
|
||||
|
|
@ -87,6 +82,12 @@ const getObjectType = (value: any): TypeName | null => {
|
|||
}
|
||||
};
|
||||
|
||||
const isObjectOfType = (typeName: string | TypeName) => (value: any) => {
|
||||
const type = typeName === 'string' ? TypeName[typeName] : typeName;
|
||||
|
||||
return getObjectType(value) === type;
|
||||
};
|
||||
|
||||
function is(value: any): TypeName { // tslint:disable-line:only-arrow-functions
|
||||
if (value === null) {
|
||||
return TypeName.null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue