convert
Create a coercing TypeObject.
type.convert(Type)
Given a type, returns a TypeObject that will coerce values to that type.
import { Reflect, type } from "can/everything";
let date = new Date();
let val = Reflect.convert(date, type.convert(Date));
console.log(val); // date
val = Reflect.convert("12/14/1933", type.convert(Date));
console.log(val); // Date{12/14/1933}
Parameters
- Type
{function}
:A constructor function that values will be checked against.