Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Commit

Permalink
Add isDivisibleByTen (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
henriqueleite42 committed May 14, 2021
1 parent 22aa1d0 commit 0a94843
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 9 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ All the details about contributing to the project are [described here](https://g

### Numbers

| Method | How To Use |
| -------- | ----------- |
| `isEven` | `isEven(2)` |
| `isOdd` | `isOdd(1)` |
| Method | How To Use |
| ------------------ | ---------------------- |
| `isDivisibleByTen` | `isDivisibleByTen(10)` |
| `isEven` | `isEven(2)` |
| `isOdd` | `isOdd(1)` |

### Dates

Expand Down Expand Up @@ -321,6 +322,18 @@ if (isUUIDv4("24bd85a1-4eb7-4f63-829e-75c08ac2b6c0")) {

### Numbers

#### isDivisibleByTen

Check if a number is divisible by 10.

```ts
import { isDivisibleByTen } from "@techmmunity/easy-check";

if (isDivisibleByTen(10)) {
// ...
}
```

#### isEven

Check if a number is even (divisible by 2).
Expand Down
8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ module.exports = {
clearMocks: true,
coverageThreshold: {
global: {
branches: 97.5,
functions: 97.5,
lines: 97.5,
statements: 97.5,
branches: 97.6,
functions: 97.6,
lines: 97.6,
statements: 97.6,
},
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@techmmunity/easy-check",
"version": "3.0.1",
"version": "3.1.1",
"main": "index.js",
"types": "index.d.ts",
"license": "Apache-2.0",
Expand Down
8 changes: 8 additions & 0 deletions src/checks/number/is-divisible-by-ten.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { makeFunction } from "helpers/make-function";

/**
* Check if is an number divisible by 10
*/
export const isDivisibleByTen = makeFunction<number>({
func: (nbr: number) => nbr % 10 === 0,
});
47 changes: 47 additions & 0 deletions src/tests/number/is-divisible-by-ten.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { isDivisibleByTen } from "checks/number/is-divisible-by-ten";

/**
*
* True
*
*/

describe("isDivisibleByTen (return True)", () => {
it("10", () => {
const result = isDivisibleByTen(10);
expect(result).toBe(true);
});

it("20", () => {
const result = isDivisibleByTen(20);
expect(result).toBe(true);
});

it("30", () => {
const result = isDivisibleByTen(30);
expect(result).toBe(true);
});
});

/**
*
* False
*
*/

describe("isDivisibleByTen (return False)", () => {
it("15", () => {
const result = isDivisibleByTen(15);
expect(result).toBe(false);
});

it("23", () => {
const result = isDivisibleByTen(23);
expect(result).toBe(false);
});

it("27", () => {
const result = isDivisibleByTen(27);
expect(result).toBe(false);
});
});

0 comments on commit 0a94843

Please sign in to comment.