numbering-patterns

    1.0.0 • Public • Published

    Numbering Patterns

    Convert numbers to a specified numbering pattern and vice-versa.

    NPM JavaScript Style Guide

    Install

    npm install --save numbering-patterns

    Usage

    import {convert, parse, flags} from 'numbering-patterns'
     
    convert(3);                         // output: 'C'
    convert(3, flags.PATTERN_ROMAN);    // output: 'III'
    convert('B');                       // output: 2
    convert('V', flags.PATTERN_ROMAN);  // output: 5
     
    parse('A?B');   // output: 'AB'
    parse('IIII');  // output: 'III'

    Syntax

    convert(value, pattern = flags.PATTERN_ALPHA);

    Returns a string or an integer depending on what value is passed to it.

    • value: The string convert to an integer or the integer to convert to a numbering pattern string.
    • pattern: The name of the numbering pattern to use for the conversion (default = flags.PATTERN_ALPHA).

    parse(value, pattern = flags.PATTERN_ALPHA);

    Returns a string in the correct format of the specified numbering pattern.

    • value: The string to parse to a correctly formatted numbering pattern string.
    • pattern: The name of the numbering pattern to parse the string to (default = flags.PATTERN_ALPHA).

    Supported patterns

    The following numbering patterns are supported.

    Alphabetic numeral

    Flag name:

    flags.PATTERN_ALPHA
    

    Example:

    1, 2, 3, ..., 53, 54, 55, ...
    A, B, C, ..., AA, AB, AC, ...
    

    Roman numeral

    Flag name:

    flags.PATTERN_ROMAN
    

    Example:

    1,  2,   3,  4, 5,  6,   7,    8,  9, 10, ..., 50, ..., 100, ..., 500, ...
    I, II, III, IV, V, VI, VII, VIII, IX,  X, ...,  L, ...,   C, ...,   D, ...
    

    License

    MIT © LSVH

    Install

    npm i numbering-patterns

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    9.18 kB

    Total Files

    8

    Last publish

    Collaborators

    • fleuv