UNPKG

ubique

Version:

A mathematical and quantitative library for Javascript and Node.js

28 lines (27 loc) 542 B
/** * Array Dimensions */ module.exports = function($u) { /** * @method numel * @summary Number of elements in an array * @description Number of elements in an array * * @param {array|matrix} x array of elements * @return {number} * * @example * ubique.numel([3,5,6]); * // 3 * * ubique.numel([[3,2,7],[4,5,6]]); * // 6 */ $u.numel = function(x) { if (arguments.length === 0) { throw new Error('not enough input arguments'); } var size = $u.size(x); return size[0] * size[1]; } }