Skip to content

vageez/fp-luhn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •