You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

coerce.js 265B

1234567891011121314
  1. "use strict";
  2. var isValue = require("../value/is");
  3. module.exports = function (value) {
  4. if (!isValue(value)) return null;
  5. try {
  6. value = +value; // Ensure implicit coercion
  7. } catch (error) {
  8. return null;
  9. }
  10. if (isNaN(value)) return null;
  11. return value;
  12. };