-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c5699d
commit 7fd7344
Showing
19 changed files
with
28,736 additions
and
2,060 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
dist | ||
coverage | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// eslint-disable-next-line no-undef | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint"], | ||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import { validateNif } from "@willowi/validate-nif"; | ||
import { getControlDigit, isValid as dniJsIsValid } from "dni-js"; | ||
import { isValid as dniJsValidatorIsValid } from "dni-js-validator"; | ||
import * as nanobench from "nanobench"; | ||
import { ctrlChar } from "./src/ctrlChar"; | ||
import { isNIE } from "./src/isNIE"; | ||
import { isNIF } from "./src/isNIF"; | ||
import { isValid } from "./src/isValid"; | ||
import { randomNIE } from "./src/randomNIE"; | ||
import { randomNIEWith } from "./src/randomNIEWith"; | ||
import { randomNIF } from "./src/randomNIF"; | ||
import { randomNIFWith } from "./src/randomNIFWith"; | ||
|
||
nanobench("isValid 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
isValid("12345678Z"); | ||
} | ||
|
||
b.end(); | ||
}); | ||
|
||
nanobench("dni-js-validator isValid 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
dniJsValidatorIsValid("12345678Z"); | ||
} | ||
|
||
b.end(); | ||
}); | ||
|
||
nanobench("dni-js-validator isValid 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
dniJsIsValid("12345678Z"); | ||
} | ||
|
||
b.end(); | ||
}); | ||
|
||
nanobench( | ||
"@willowi/validate-nif validateNif 10.000.000 times", | ||
function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
validateNif("12345678Z"); | ||
} | ||
|
||
b.end(); | ||
} | ||
); | ||
|
||
nanobench("ctrlChar 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
ctrlChar("X0729124R"); | ||
} | ||
|
||
b.end(); | ||
}); | ||
|
||
nanobench("getControlDigit 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
getControlDigit("X0729124R"); | ||
} | ||
|
||
b.end(); | ||
}); | ||
|
||
nanobench.skip("randomNIE 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
randomNIE(); | ||
} | ||
|
||
b.end(); | ||
}); | ||
|
||
nanobench.skip("randomNIF 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
randomNIF(); | ||
} | ||
|
||
b.end(); | ||
}); | ||
|
||
nanobench("isNIE 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
isNIE("Z9407822E"); | ||
} | ||
|
||
b.end(); | ||
}); | ||
|
||
nanobench("isNIF 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
isNIF("42406984K"); | ||
} | ||
|
||
b.end(); | ||
}); | ||
|
||
nanobench("randomNIEWith 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
randomNIEWith("Z", "E"); | ||
} | ||
|
||
b.end(); | ||
}); | ||
|
||
nanobench("randomNIFWith 10.000.000 times", function (b: any) { | ||
b.start(); | ||
|
||
for (let i = 0; i < 10_000_000; i++) { | ||
randomNIFWith("E"); | ||
} | ||
|
||
b.end(); | ||
}); |
Oops, something went wrong.