UNPKG

mathball

Version:

A JavaScript library for Competitive Programming

13 lines (11 loc) 488 B
'use strict'; /* * Integer Array Validation */ module.exports = function (arg, func) { var flag = 0; if (arg && arg.constructor == Array) arg.forEach(function (item) { if (typeof item != 'number' || item + 1 == item || item != item || !Number.isInteger(item) || item < 1) flag = 1; }); if (!arg || arg.constructor != Array || flag) throw new TypeError('Invalid argument received: ' + JSON.stringify(arg) + '\n\'' + func + '()\' only accept an array of positive integers!\n'); };