Ensure getObjectType is defined before first use

This commit is contained in:
Mario Nebl 2017-11-10 16:05:32 +01:00
parent e3f729ec7c
commit c20141b366

View file

@ -34,11 +34,6 @@ export enum TypeName {
const toString = Object.prototype.toString; const toString = Object.prototype.toString;
const isOfType = (type: string) => (value: any) => typeof value === type; // tslint:disable-line:strict-type-predicates 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 getObjectType = (value: any): TypeName | null => {
const objectName = toString.call(value).slice(8, -1) as string; 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 function is(value: any): TypeName { // tslint:disable-line:only-arrow-functions
if (value === null) { if (value === null) {
return TypeName.null; return TypeName.null;