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.
33 lines
495 B
33 lines
495 B
5 years ago
|
'use strict';
|
||
|
|
||
|
/*!
|
||
|
* Module requirements.
|
||
|
*/
|
||
|
|
||
|
const SchemaNumber = require('../number');
|
||
|
|
||
|
/*!
|
||
|
* @ignore
|
||
|
*/
|
||
|
|
||
|
exports.castToNumber = castToNumber;
|
||
|
exports.castArraysOfNumbers = castArraysOfNumbers;
|
||
|
|
||
|
/*!
|
||
|
* @ignore
|
||
|
*/
|
||
|
|
||
|
function castToNumber(val) {
|
||
|
return SchemaNumber.cast()(val);
|
||
|
}
|
||
|
|
||
|
function castArraysOfNumbers(arr, self) {
|
||
|
arr.forEach(function(v, i) {
|
||
|
if (Array.isArray(v)) {
|
||
|
castArraysOfNumbers(v, self);
|
||
|
} else {
|
||
|
arr[i] = castToNumber.call(self, v);
|
||
|
}
|
||
|
});
|
||
|
}
|