UNPKG

luhn-generator

Version:

A generator of numbers that passes the validation of Luhn algorithm or Luhn formula, also known as the 'modulus 10' or 'mod 10' algorithm

18 lines (16 loc) 328 B
import stringWidth from 'string-width'; /** * Calculates width of each cell contents. * * @param {string[]} cells * @returns {number[]} */ export default (cells) => { return cells.map((value) => { return Math.max( ...value.split('\n').map((line) => { return stringWidth(line); }) ); }); };