Skip to content

Commit

Permalink
Merge pull request #8 from juananmuxed/feature/typescript-version
Browse files Browse the repository at this point in the history
🐵 Feature/typescript version
  • Loading branch information
juananmuxed authored Jun 21, 2022
2 parents eb91206 + cc5329a commit 25c99d7
Show file tree
Hide file tree
Showing 21 changed files with 4,196 additions and 6,927 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Publish to NPM
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: "14.x"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies and build 🔧
run: npm install && npm run build
- name: Publish package on NPM 📦
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.TOKEN_NPM }}
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
# General
src
webpack.config.js
tsconfig.json
test
coverage
.github

### macOS ###
# General
Expand Down
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- New class to Generate DNIs
- New class to Generate CIFs
## [v2.0.0]

### Added

- Auto deploy in NPM

### Changed

- Set typescript and delete Webpack
- Change Jest in favor of Vitest
### Deleted

- Unnecessary support number functions for NIE

## [v1.2.0] - 26-02-2021

Expand All @@ -36,7 +49,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- First Release

[Unreleased]: https://github.com/juananmuxed/dni-utils/compare/v1.2.0...HEAD
[Unreleased]: https://github.com/juananmuxed/dni-utils/compare/v2.0.0...HEAD
[v2.0.0]: https://github.com/juananmuxed/dni-utils/releases/tag/v2.0.0
[v1.2.0]: https://github.com/juananmuxed/dni-utils/releases/tag/v1.2.0
[v1.1.0]: https://github.com/juananmuxed/dni-utils/releases/tag/v1.1.0
[v1.0.4]: https://github.com/juananmuxed/dni-utils/releases/tag/v1.0.4
Expand Down
61 changes: 23 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 🏷️ DNI Utils
__Utilities to work with the Spanish DNI__

[![npm (scoped)](https://img.shields.io/npm/v/@muxed/dni-utils.svg?label=NPM)](https://www.npmjs.com/package/@muxed/dni-utils) [![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@muxed/dni-utils?label=Minified%20size)](https://www.npmjs.com/package/@muxed/dni-utils) [![License](https://img.shields.io/github/license/juananmuxed/dni-utils?label=License)](LICENSE)
[![npm (scoped)](https://img.shields.io/npm/v/@muxed/dni-utils.svg?label=NPM)](https://www.npmjs.com/package/@muxed/dni-utils) [![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@muxed/dni-utils?label=Minified%20size)](https://www.npmjs.com/package/@muxed/dni-utils) [![License](https://img.shields.io/github/license/juananmuxed/dni-utils?label=License)](LICENSE) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/juananmuxed/dni-utils/Publish%20to%20NPM?label=Build&logo=npm)

[![Discord](https://img.shields.io/discord/324463341819133953?color=purple&label=Discord&logo=discord)](https://discord.gg/88rzwfU)

Expand All @@ -12,47 +12,32 @@ $ npm install @muxed/dni-utils

## 🎉 Usage

Import the instaled Package
```js
const dni = require('@muxed/dni-utils');
```
Create a class constructor (if you need check the Support number for NIE, the second parameter acepted)
```js
// Start the class with DNI
let validator = new dni.validator('22414222P');
// Start the class with NIE and SUPPORT NUMBER
let validator = new dni.validator('X2414222P','E24210042');
Import the functions you want
```ts
import {
isCif,
isNie,
isNif,
} from "./../src/modules/validator";

```

### Functions availables
Check validity (any NIE, NIF or CIF). Return `true` or `false`.
```js
validator.isValid();
```
Check validity (NIE, NIF or CIF) . Return `true` or `false`.
```js
validator.isNif();
validator.isNie();
validator.isCif();
```
Return an Object with society type and province. Format: `{ society: String, province: String }`
```js
validator.dataNif();
```
Return the type of DNI (`NIE`, `NIF` or `CIF`) or `INVALID`.
```js
validator.typeDNI();
```
Check Support Number (for NIE). Return `true` or `false`.
```js
validator.validSupportNumber();
```
Sanitize support number (NIE). Return formated Number `E00000001`.
```js
validator.sanitizeSupportNumber(); // Return the Support Number (NIE) in E00000001 format
```ts
const dni = '54148871V';
// Check validity (any NIE, NIF or CIF). Return `true` or `false`.
isValid(dni);
// Check validity (NIE, NIF or CIF) . Return `true` or `false`.
isNif(dni);
isNie(dni);
isCif(dni);
// Return an Object with society type and province. Format: `{ society: String, province: String }`
dataNif(dni);
// Return the type of DNI (`NIE`, `NIF` or `CIF`) or `INVALID`.
typeDNI(dni);
```

IMPORTANT: Obsolete CIFs isn't supported (return INVALID)
__IMPORTANT__: Obsolete CIFs isn't supported (return INVALID)

## 🟢 Testing
Install the Jest dependencies if not in global
Expand All @@ -61,7 +46,7 @@ $ npm install
```
Run the tests
```shell
$ npm test
$ npm run test
```

## 🍰 Contributing
Expand Down
Loading

0 comments on commit 25c99d7

Please sign in to comment.