fp-luhn

    1.1.0 • Public • Published

    License PRs Welcome

    fp-luhn

    Functional Implementation of the Luhn Algorithm. No variable declaration, No mutation. A simple, lightweight implementation using composition. Used for testing a credit cards checksum value. Most credit cards and many government identification numbers use the algorithm as a simple method of distinguishing valid numbers from mistyped or otherwise incorrect numbers.

    Why another LUHN library

    The goal was to write a LUHN Algorithm using a functional programming paradigm. A series of composable lambas that are processed right to left. Not a single if / else statement. All branching is handled by ternary functions with implicit returns.

    Install

    Yarn:

    yarn add fp-luhn

    NPM:

    npm i fp-luhn

    Hindley–Milner

    // luhn :: Numeric String -> Boolean

    Usage

    Accepts a numeric string. Eg: '4111111111111111'

    import luhn from 'fp-luhn'
    
    luhn('4916737743057301') // true
    
    

    Install

    npm i fp-luhn

    DownloadsWeekly Downloads

    0

    Version

    1.1.0

    License

    Apache-2.0

    Unpacked Size

    6.85 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar