Notoriously Pedantic Magistrate

    to-digit-grouped
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.1 • Public • Published

    To Digit Grouped

    build status npm package

    Use thousand separator (or custom text) to group digits in a string.

    import toDigitGrouped from 'to-digit-grouped';
     
    toDigitGrouped('1234567890.1234567890');
    // "1 234 567 890.1234567890"
     
    toDigitGrouped('value: 1234567890.1234567890 unit');
    // "value: 1 234 567 890.1234567890 unit"
     
    toDigitGrouped('1234 and 5678');
    // 1 234 and 4578
     
    toDigitGrouped('1234 and 5678', { multiple: true });
    // 1 234 and 4 578
     
    toDigitGrouped('1234567890.1234567890');
    // "1 234 567 890.1234567890"
     
    toDigitGrouped('1234567890.1234567890', { groupFraction: true });
    // "1 234 567 890.123 456 789 0"
     
    toDigitGrouped('1234567890.1234567890', { groupSeparator: ',' });
    // "1,234,567,890.1234567890"
     
    toDigitGrouped('1234567890.1234567890', { groupSize: 4 });
    // "12 3456 7890.1234567890"
     
    toDigitGrouped('1234567890,1234567890', { decimalSeparator: ',' });
    // "1 234 567 890,1234567890"
     
    toDigitGrouped('0123456789abcdef', {
      digitCharacters: '0123456789abcdef',
      groupSize: 2,
    });
    // "01 23 45 67 89 ab cd ef"

    Install

    npm i to-digit-grouped

    DownloadsWeekly Downloads

    6

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    28.1 kB

    Total Files

    13

    Last publish

    Collaborators

    • xjpicism