singuerinc / better-dni Goto Github PK
View Code? Open in Web Editor NEWThe fastest Spanish DNI (NIE / NIF) validation out there.
Home Page: https://better-dni.singuerinc.com/
License: MIT License
The fastest Spanish DNI (NIE / NIF) validation out there.
Home Page: https://better-dni.singuerinc.com/
License: MIT License
The NPM module you're publishing includes arrow functions (and maybe other ES6 features?).
We want to use this library, but need to support IE11 which doesn't support arrow functions (https://caniuse.com/#feat=arrow-functions).
This is the only library we're using which publishes a non-ES5-compatible NPM module. Any chance you could either switch to standard function declarations or produce a babel-transpiled JS bundle?
Alternatively, at least a note on the README that IE11 is not supported would be useful.
Workaround:
Include this library in our webpack config so that babel-loader picks it up.
I need to verify if the benchmark published in the readme is "reliable".
I need help running the benchmark in different machines/arch (Windows, Linux, Mac, etc) with different configurations.
Please, help me posting your "setup" and the results.
Before running the test, close all the "CPU intensive apps" so that the test doesn't get impacted by a low pc performance.
For example, my setup is:
MacBook Pro (Retina, 13-inch, Early 2015)
3,1 GHz Intel Core i7
16 GB 1867 MHz DDR3
macOS Mojave
node 10.11.0
By running this command:
yarn && yarn build && yarn benchmark
You will get something like:
better-dni#isValid x 9,773,025 ops/sec ±0.72% (91 runs sampled)
dni-js-validator#isValid x 2,979,152 ops/sec ±0.95% (91 runs sampled)
dni-js#isValid x 2,797,088 ops/sec ±2.04% (88 runs sampled)
@willowi/validate-nif#validateNif x 745,911 ops/sec ±2.90% (88 runs sampled)
Fastest is better-dni#isValid
Thanks!
Z7390424H
Y6379314B
Z8775301L
etc...
Not sure if it's needed, we use prettier.
It only validates if is nie/nif like
randomNIFWith('E'); // => '75804595E'
randomNIEWith('Z', 'G'); // => 'Z6157421G'
randomNIEWith('Y', 'K'); // => 'Y7631775K'
randomNIEWith('X', 'R'); // => 'X9329146R'
Add extra options to compile and minify
Should not be possible to call:
randomNIFWith('I');
randomNIFWith('O');
randomNIFWith('U');
Normalize, ctrlChar, randomNIFWith and randomNIEWith are not exported in Typescript definitions!
They should be added here!
Line 46 in be52be5
Local government NIF does not validate.
For example
isValid('P4622000J'); // should be true, but is false
We may get better code (faster?) from the transpiler. We also may get free d.ts file and es5 support
I got an error working with ionic, I was not able to use better-dni without changing the file /types/index.d.ts, like suggested here: greena13/react-hotkeys#99 (comment)
Here is the modified file, it would be nice if you update the repository:
/**
* Returns a "clean" dni string removing spaces, dashes, etc.
*/
declare function normalize(str: string): string;
/**
* Returns a random NIE with a specific letter
* A seed can be passed as a third parameter and
* it will always return the same value
*/
declare function randomNIEWith(xyz: string, char: string, seed: number):
string | null;
/**
* Returns a random NIF with a specific letter
* A seed can be passed as a second parameter and
* it will always return the same value
*/
declare function randomNIFWith(char: string, seed: number): string | null;
/**
* Returns the control letter in upper case
* for a NIF or NIE with or without control letter
*/
declare function ctrlChar(dni: string): string;
/**
* Returns a valid NIF string
*/
declare function randomNIF(): string;
/**
* Returns a valid NIE string
*/
declare function randomNIE(): string;
/**
* Returns true if the string is a NIE
*/
declare const isNIE: (nie: string) => boolean;
/**
* Returns true if the string is a NIF
*/
declare const isNIF: (nif: string) => boolean;
/**
* Returns true if the string is a valid DNI
*/
declare const isValid: (dni: string) => boolean;
export { randomNIF, randomNIE, isValid, isNIF, isNIE };
Thanks for your work!
Just a suggestion: How about adding a normalize
function that takes input and cleans it like:
normalize(' 12 34 56 7 8-z') //=> '12345678Z'
Add a benchmark for isNIE
/ isNIF
We are getting too many issues in Travis with yarn, let's see if this resolve them.
master
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here are some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
package.json
file.A package.json file at the root of your project is required to release on npm.
Please follow the npm guideline to create a valid package.json
file.
Good luck with your project ✨
Your semantic-release bot 📦🚀
better-dni doesn't support CIF validation.
Some task that need to be done:
Related with #106
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.