lib/types.js
function _toCORMOType(type) {
    if (typeof type === 'string') {
        const type_string = type.toLowerCase();
        if (/^string\((\d+)\)$/.test(type_string)) {
            return new CormoTypesString(Number(RegExp.$1));
        }
        switch (type_string) {
            case 'string':
                return new CormoTypesString();
            case 'number':
                return new CormoTypesNumber();
            case 'boolean':
                return new CormoTypesBoolean();
            case 'integer':
                return new CormoTypesInteger();
            case 'geopoint':
                return new CormoTypesGeoPoint();
            case 'date':
                return new CormoTypesDate();
            case 'object':
                return new CormoTypesObject();
            case 'recordid':
                return new CormoTypesRecordID();
            case 'text':
                return new CormoTypesText();
        }
        throw new Error(`unknown type: ${type}`);
    }
    else if (type === String) {
        return new CormoTypesString();
    }
    else if (type === Number) {
        return new CormoTypesNumber();
    }
    else if (type === Boolean) {
        return new CormoTypesBoolean();
    }
    else if (type === Date) {
        return new CormoTypesDate();
    }
    else if (type === Object) {
        return new CormoTypesObject();
    }
    if (typeof type === 'function') {
        return new type();
    }
    return type;
}
function _toCORMOType(type) {
    if (typeof type === 'string') {
        const type_string = type.toLowerCase();
        if (/^string\((\d+)\)$/.test(type_string)) {
            return new CormoTypesString(Number(RegExp.$1));
        }
        switch (type_string) {
            case 'string':
                return new CormoTypesString();
            case 'number':
                return new CormoTypesNumber();
            case 'boolean':
                return new CormoTypesBoolean();
            case 'integer':
                return new CormoTypesInteger();
            case 'geopoint':
                return new CormoTypesGeoPoint();
            case 'date':
                return new CormoTypesDate();
            case 'object':
                return new CormoTypesObject();
            case 'recordid':
                return new CormoTypesRecordID();
            case 'text':
                return new CormoTypesText();
        }
        throw new Error(`unknown type: ${type}`);
    }
    else if (type === String) {
        return new CormoTypesString();
    }
    else if (type === Number) {
        return new CormoTypesNumber();
    }
    else if (type === Boolean) {
        return new CormoTypesBoolean();
    }
    else if (type === Date) {
        return new CormoTypesDate();
    }
    else if (type === Object) {
        return new CormoTypesObject();
    }
    if (typeof type === 'function') {
        return new type();
    }
    return type;
}
function _toCORMOType ( type ) { if ( typeof type === 'string' ) { const type_string = type . toLowerCase ( ) ; if ( / ^string\((\d+)\)$ / . test ( type_string ) ) { return new CormoTypesString ( Number ( RegExp . $1 ) ) ; } switch ( type_string ) { case 'string' : return new CormoTypesString ( ) ; case 'number' : return new CormoTypesNumber ( ) ; case 'boolean' : return new CormoTypesBoolean ( ) ; case 'integer' : return new CormoTypesInteger ( ) ; case 'geopoint' : return new CormoTypesGeoPoint ( ) ; case 'date' : return new CormoTypesDate ( ) ; case 'object' : return new CormoTypesObject ( ) ; case 'recordid' : return new CormoTypesRecordID ( ) ; case 'text' : return new CormoTypesText ( ) ; } throw new Error ( ` ${ type } ` ) ; } else if ( type === String ) { return new CormoTypesString ( ) ; } else if ( type === Number ) { return new CormoTypesNumber ( ) ; } else if ( type === Boolean ) { return new CormoTypesBoolean ( ) ; } else if ( type === Date ) { return new CormoTypesDate ( ) ; } else if ( type === Object ) { return new CormoTypesObject ( ) ; } if ( typeof type === 'function' ) { return new type ( ) ; } return type ; }
Converts JavaScript built-in class to CORMO type
@private
Converts JavaScript built - in class to CORMO type