Skip to content

Commit

Permalink
v1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasZottis committed Sep 25, 2024
1 parent ef55b23 commit ec8d304
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 30 deletions.
5 changes: 3 additions & 2 deletions dev-toolz.library/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "dev-toolz.library",
"version": "1.0.4",
"version": "1.0.5",
"description": "Biblioteca de funcionalidades gerais usadas no dia a dia de um desenvolvedor",
"main": "index.js",
"types": "dist/index.d.js",
"scripts": {
"build": "npx tsc --build"
"build": "tsc -declaration"
},
"author": "Lucas Zottis",
"license": "ISC",
Expand Down
10 changes: 5 additions & 5 deletions dev-toolz.library/src/cnpj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { IValidator } from "./interfaces/validator";
import { IValue } from "./interfaces/value";

export class Cnpj implements IValue, IValidator, IValueGenerator {
value: string;
message: string;
value!: string;
message!: string;

private _isPattern(value: string): boolean {
return value === "000000000000"
Expand All @@ -28,7 +28,7 @@ export class Cnpj implements IValue, IValidator, IValueGenerator {
}

private _generateCalculatingDigits(): string {
let randomDigits: IValueGenerator = new Random(0, 9, true);
let randomDigits = new Random(0, 9, true);
let digits!: string;

do {
Expand Down Expand Up @@ -101,9 +101,9 @@ export class Cnpj implements IValue, IValidator, IValueGenerator {
isValid(): boolean;
isValid(value: string): boolean;
isValid(value?: string): boolean {
this.value = value;
this.value = value ?? "";

if (value.isEmpty()) {
if (value?.isEmpty()) {
this.message = "CNPJ está vazio.";
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions dev-toolz.library/src/cpf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Random } from "./random";
import "./extensions/stringExtensions";

export class Cpf implements IValue, IValueGenerator, IValidator {
message: string;
value: string;
message!: string;
value!: string;

private _isPattern(value: string): boolean {
return value.isEqual("000000000")
Expand Down Expand Up @@ -82,9 +82,9 @@ export class Cpf implements IValue, IValueGenerator, IValidator {
isValid(): boolean;
isValid(value: string): boolean;
isValid(value?: string): boolean {
this.value = value;
this.value = value ?? "";

if (value.isEmpty()) {
if (value?.isEmpty()) {
this.message = "CPF está vazio.";
return false;
}
Expand Down
13 changes: 8 additions & 5 deletions dev-toolz.library/src/extensions/numberExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ Number.prototype.lessThan = function (value: Number): boolean {
return this < value;
}

Number.prototype.between = function (lowestValue: Number, highestValue: Number, inclusive: boolean): boolean {
Number.prototype.between = function (lowestValue: number, highestValue: number, inclusive: boolean): boolean {
let value = this as number;
if (inclusive)
return this >= lowestValue && this <= highestValue;
return value >= lowestValue && value <= highestValue;
else
return this > lowestValue && this < highestValue;
return value > lowestValue && value < highestValue;
}

Number.prototype.toBoolean = function (value: Number): boolean {
return Math.abs(this).isNotEqual(0);
Number.prototype.toBoolean = function (): boolean {
let value = this as number;

return Math.abs(value).isNotEqual(0);
}
14 changes: 6 additions & 8 deletions dev-toolz.library/src/extensions/stringExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ String.prototype.isEqual = function (value: string): boolean {
}

String.prototype.isEmpty = function (): boolean {
let value: string = this.toString();

return value === undefined && value === null && value.trim() === "";
}
let value: string = this.toString().trim();
return value === "";
};

String.prototype.isNotEmpty = function (): boolean {
let value: string = this.toString();

return value !== undefined && value !== null && value.trim() !== "";
}
let value: string = this.toString().trim();
return value !== "";
};

String.prototype.isNumber = function (): boolean {
return isNaN(Number(this));
Expand Down
4 changes: 4 additions & 0 deletions dev-toolz.library/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './cpf';
export * from './cnpj';
export * from './random';
export * from './crypt';
17 changes: 11 additions & 6 deletions dev-toolz.library/tsconfig.JSON
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"target": "es2020",
"lib": ["es2020"],
"declaration": true,
"outDir": "./dist"
"rootDir": "./src",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true,
},
"include": ["src/**/*"]
}
// "include": [
// "src/**/*.ts"
// ]
}

0 comments on commit ec8d304

Please sign in to comment.