aboutsummaryrefslogtreecommitdiff
path: root/test/support
diff options
context:
space:
mode:
authorEric Cheng <[email protected]>2022-05-25 12:59:06 -0400
committerGitHub <[email protected]>2022-05-25 16:59:06 +0000
commitc95826f348bf317d3cff240a7ebbae4bd80956f6 (patch)
tree39004bab49760f632f61a6b83212194873048f25 /test/support
parent4e38a7083ab02567c019b3078b63801fe73a4333 (diff)
downloadfaker-c95826f348bf317d3cff240a7ebbae4bd80956f6.tar.xz
faker-c95826f348bf317d3cff240a7ebbae4bd80956f6.zip
fix: Luhn generation algorithms and tests (#980)
Co-authored-by: ST-DDT <[email protected]>
Diffstat (limited to 'test/support')
-rw-r--r--test/support/luhnCheck.ts18
1 files changed, 0 insertions, 18 deletions
diff --git a/test/support/luhnCheck.ts b/test/support/luhnCheck.ts
deleted file mode 100644
index fb4e0bb0..00000000
--- a/test/support/luhnCheck.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-export function luhnCheck(number: string): boolean {
- number = number.replace(/\D/g, '');
- let split: string[] | number[] = number.split('');
- split = split.map((num) => parseInt(num));
- const check = split.pop();
- split.reverse();
- split = split.map((num, index) => {
- if (index % 2 === 0) {
- num *= 2;
- if (num > 9) {
- num -= 9;
- }
- }
- return num;
- });
- const sum = split.reduce((prev, curr) => prev + curr);
- return sum % 10 === check;
-}