Skip to content

Commit

Permalink
1.0.17 version!
Browse files Browse the repository at this point in the history
  • Loading branch information
wotanCode committed Nov 13, 2024
1 parent 6d4b85b commit ee194eb
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: [pedroelhumano]
github: [wotanCode]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Folders
/node_modules
/dist-browser
/dist-node
/dist
/coverage

# Files
package-lock.json

# OS Files
.DS_Store
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ eslint.config.mjs
package-lock.json
.prettierrc

# OS Files
.DS_Store

# Include
!dist
178 changes: 91 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,95 +25,99 @@ const { format, calculateDv, isValidRut, isFormat } = require('rutility');
import { format, calculateDv, isValidRut, isFormat } from 'rutility';
```
## Formatting Functions
`format.dot(rut: string): string`
Formats a RUT by adding dots.
```javascript
console.log(format.dot('12345678')); // '12.345.678'
console.log(format.dot('12345678-K')); // '12.345.678-K'
```
`format.dash(rut: string): string`
Formats a RUT by adding a dash.
```javascript
console.log(format.dash('123456780')); // '12345678-0'
console.log(format.dash('12.345.6780')); // '12.345.678-0'
console.log(format.dash('12')); // '1-2'
```
`format.dotDash(rut: string): string`
Formats a RUT by adding dots and a dash.
```javascript
console.log(format.dotDash('123456780')); // '12.345.678-0'
console.log(format.dotDash('12345678-K')); // '12.345.678-K'
```
`format.notDot(rut: string): string`
Removes dots from a RUT.
```javascript
console.log(format.notDot('12.345.678-0')); // '12345678-0'
console.log(format.notDot('12.345.678')); // '12345678'
```
`format.notDash(rut: string): string`
Removes the dash and check digit from a RUT.
```javascript
console.log(format.notDash('12.345.678-0')); // '12.345.678'
console.log(format.notDash('12345678-0')); // '12345678'
```
`format.notDotDash(rut: string): string`
Removes dots and the dash from a RUT.
```javascript
console.log(format.notDotDash('12.345.678-9')); // '12345678'
console.log(format.notDotDash('12.345.678')); // '12345678'
```
## Validation Functions
`calculateDv(rut: string | number): string`
Calculates the check digit of a Chilean RUT.
```javascript
console.log(calculateDv('12.345.678')); // '5'
console.log(calculateDv('12345678')); // '5'
console.log(calculateDv(12345678)); // '5'
```
`isValidRut(rut: string): boolean`
Validates if a Chilean RUT is valid.
```javascript
console.log(isValidRut('12.345.678-5')); // true
console.log(isValidRut('12345678-5')); // true
```
### Formatting Functions
<table border="1">
<thead>
<tr>
<th>Function</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>format.dot(rut: string): string</code></td>
<td>Formats a RUT by adding dots.</td>
<td><code>console.log(format.dot('12345678')); // '12.345.678'</code></td>
</tr>
<tr>
<td><code>format.dash(rut: string): string</code></td>
<td>Formats a RUT by adding a dash.</td>
<td><code>console.log(format.dash('123456780')); // '12345678-0'</code></td>
</tr>
<tr>
<td><code>format.dotDash(rut: string): string</code></td>
<td>Formats a RUT by adding dots and a dash.</td>
<td><code>console.log(format.dotDash('123456780')); // '12.345.678-0'</code></td>
</tr>
<tr>
<td><code>format.notDot(rut: string): string</code></td>
<td>Removes dots from a RUT.</td>
<td><code>console.log(format.notDot('12.345.678-0')); // '12345678-0'</code></td>
</tr>
<tr>
<td><code>format.notDash(rut: string): string</code></td>
<td>Removes the dash and check digit from a RUT.</td>
<td><code>console.log(format.notDash('12.345.678-0')); // '12.345.678'</code></td>
</tr>
<tr>
<td><code>format.notDotDash(rut: string): string</code></td>
<td>Removes dots and the dash from a RUT.</td>
<td><code>console.log(format.notDotDash('12.345.678-9')); // '12345678'</code></td>
</tr>
</tbody>
</table>
### Validation Functions
<table border="1">
<thead>
<tr>
<th>Function</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>calculateDv(rut: string | number): string</code></td>
<td>Calculates the check digit of a Chilean RUT.</td>
<td><code>console.log(calculateDv('12.345.678')); // '5'</code></td>
</tr>
<tr>
<td><code>isValidRut(rut: string): boolean</code></td>
<td>Validates if a Chilean RUT is valid.</td>
<td><code>console.log(isValidRut('12.345.678-5')); // true</code></td>
</tr>
</tbody>
</table>
### Format Validations
`isFormat.dot(rut: string): boolean`
Checks if a RUT has the correct format with dots.
``` javascript
console.log(isFormat.dot('12.345.678')); // true
```
isFormat.dash(rut: string): boolean
Checks if a RUT has the correct format with a dash.
``` javascript
console.log(isFormat.dash('12345678-9')); // true
```
`isFormat.dotDash(rut: string): boolean`
Checks if a RUT has the correct format with dots and a dash.
```javascript
console.log(isFormat.dotDash('12.345.678-9')); // true
```
<table border="1">
<thead>
<tr>
<th>Function</th>
<th>Description</th>
<th>Example</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>isFormat.dot(rut: string): boolean</code></td>
<td>Checks if a RUT has the correct format with dots.</td>
<td><code>console.log(isFormat.dot('12.345.678')); // true</code></td>
</tr>
<tr>
<td><code>isFormat.dash(rut: string): boolean</code></td>
<td>Checks if a RUT has the correct format with a dash.</td>
<td><code>console.log(isFormat.dash('12345678-9')); // true</code></td>
</tr>
<tr>
<td><code>isFormat.dotDash(rut: string): boolean</code></td>
<td>Checks if a RUT has the correct format with dots and a dash.</td>
<td><code>console.log(isFormat.dotDash('12.345.678-9')); // true</code></td>
</tr>
</tbody>
</table>
## Contributing
If you wish to contribute to this project, please open an issue or submit a pull request.
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 1.0.17 Better documentation
- Add `public-npm` script in `package.json`.
- Update `.gitignore` and `npmignore`.
- Update `FUNDING.yml`.
- Update `README.md`.

### 1.0.16 Fix build compilation

### 1.0.15 Update Repository and readme
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rutility",
"version": "1.0.16",
"version": "1.0.17",
"main": "dist/index.js",
"browser": "dist/index.js",
"module": "dist/index.js",
Expand All @@ -10,9 +10,12 @@
"test:coverage": "npx jest --coverage --collectCoverageFrom='src/**/*.ts'",
"test:lint": "eslint --fix",
"test": "npm run test:unit & npm run test:coverage & npm run test:lint & npm run prettier-format",
"build": "tsc --project tsconfig.json"
"build": "npm run test && tsc --project tsconfig.json",
"public-npm": "npm run build && npm publish --access public"
},
"files": ["dist"],
"files": [
"dist"
],
"exports": {
".": {
"import": "./dist/index.js",
Expand Down Expand Up @@ -55,4 +58,4 @@
"typescript-eslint": "^7.17.0",
"undici-types": "^6.19.4"
}
}
}

0 comments on commit ee194eb

Please sign in to comment.