fontoxpath
Version:
A minimalistic XPath 3.1 engine in JavaScript
14 lines (13 loc) • 331 B
JavaScript
import tryCastToType from './casting/tryCastToType';
/**
* @param {!./AtomicValue<*>} value
* @param {string} type
* @return {!./AtomicValue<*>}
*/
export default function castToType (value, type) {
const result = tryCastToType(value, type);
if (result.successful) {
return result.value;
}
throw result.error;
}