wallet-core/node_modules/es5-ext/object/ensure-natural-number.js

11 lines
300 B
JavaScript
Raw Normal View History

2017-08-14 05:01:11 +02:00
"use strict";
2018-09-20 02:56:13 +02:00
var isNatural = require("../number/is-natural")
, toShortString = require("../to-short-string-representation");
2017-08-14 05:01:11 +02:00
module.exports = function (arg) {
var num = Number(arg);
2018-09-20 02:56:13 +02:00
if (!isNatural(num)) throw new TypeError(toShortString(arg) + " is not a natural number");
2017-08-14 05:01:11 +02:00
return num;
};