Giter VIP home page Giter VIP logo

better-dni's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar fenik17 avatar semantic-release-bot avatar singuerinc avatar sturgelose avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

better-dni's Issues

NPM module includes arrow functions

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.

Run benchmark

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!

Add lint

Not sure if it's needed, we use prettier.

random with fixed params

  • randomNIFWith
  • randomNIEWith
randomNIFWith('E'); // => '75804595E'

randomNIEWith('Z', 'G'); // => 'Z6157421G'
randomNIEWith('Y', 'K'); // => 'Y7631775K'
randomNIEWith('X', 'R'); // => 'X9329146R'

Compile with Typescript

We may get better code (faster?) from the transpiler. We also may get free d.ts file and es5 support

Typescript definitions error

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!

Add normalize/clean method

Just a suggestion: How about adding a normalize function that takes input and cleans it like:

normalize('   12 34 56 7 8-z') //=> '12345678Z'

The automated release is failing 🚨

🚨 The automated release from the 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.


Missing 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 📦🚀

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.