Skip to content

Commit

Permalink
Merge pull request #38 from vodyani/beta_8.x
Browse files Browse the repository at this point in the history
Beta 8.x
  • Loading branch information
ChoGathK authored Sep 7, 2022
2 parents 38e7160 + 828fcf1 commit 76dc3c1
Show file tree
Hide file tree
Showing 27 changed files with 430 additions and 528 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## [8.5.1](https://github.com/vodyani/utils/compare/v8.5.0...v8.5.1) (2022-08-31)


### Bug Fixes

* remove invalid dependency declarations ([d1e04e1](https://github.com/vodyani/utils/commit/d1e04e14cf57ae61c799f69ca2e089159f7173df))

# [8.5.0](https://github.com/vodyani/utils/compare/v8.4.4...v8.5.0) (2022-08-31)


### Features

* adding common tools package ([02a641d](https://github.com/vodyani/utils/commit/02a641d9cf10f9330c159cd6a49aed66cfd0bd48))

# [8.5.0-beta.1](https://github.com/vodyani/utils/compare/v8.4.4...v8.5.0-beta.1) (2022-08-31)


Expand Down
2 changes: 2 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ npm install @vodyani/utils
|:-:|
|[ChoGathK](https://github.com/chogathK)|

![Alt](https://repobeats.axiom.co/api/embed/1e23cf3a598d3f75555c9bccab6664de44857ab3.svg "Repobeats analytics image")

## License

Vodyani utils is [MIT licensed](LICENSE).
65 changes: 8 additions & 57 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@vodyani/utils",
"license": "MIT",
"version": "8.5.0-beta.1",
"version": "8.5.1",
"author": "ChoGathK",
"description": "🏃🏻‍♀️ utils provides common utility functions used in server-side development.",
"homepage": "https://github.com/vodyani/utils#readme",
Expand Down Expand Up @@ -60,26 +60,17 @@
]
},
"dependencies": {
"dayjs": "^1.11.0",
"deepmerge-ts": "4.2.1",
"lodash": "4.17.21",
"module-alias": "^2.2.2",
"uuid": "^8.3.2"
},
"peerDependencies": {
"@types/module-alias": "2.0.1",
"@types/uuid": "^8.3.4"
"lodash": "4.17.21"
},
"devDependencies": {
"@commitlint/cli": "16.3.0",
"@commitlint/config-conventional": "16.2.4",
"@nestjs/testing": "8.4.7",
"@types/jest": "27.5.2",
"@types/lodash": "4.14.182",
"@types/module-alias": "2.0.1",
"@types/node": "16.11.56",
"@types/supertest": "2.0.12",
"@types/uuid": "^8.3.4",
"@vodyani/eslint-config": "^1.1.0",
"husky": "7.0.4",
"jest": "27.5.1",
Expand Down
31 changes: 31 additions & 0 deletions src/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export interface ConvertOptions {
/**
* When the received value does not correspond to expectations, this value is returned.
*
* @default null
*/
default?: any;
/**
* The conversion is carried out if the outcome of the conditional validation function execution is true.
*
* @empale (num: number) => num > 0
*/
condition?: (...args: any[]) => boolean;
/**
* The process that carries out the transition.
*
* @empale (data: any) => Number(data)
*/
transformer?: Function;
}

export class PriorityElement<T = any> {
/**
* Priority Indicates the weight of the queue.
*/
public weight: number;
/**
* The actual content.
*/
public value: T;
}
3 changes: 0 additions & 3 deletions src/common/declare/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/common/declare/module-alias.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/common/declare/time.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/common/declare/uuid.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/common/index.ts

This file was deleted.

49 changes: 0 additions & 49 deletions src/common/interface.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/common/type.ts

This file was deleted.

30 changes: 30 additions & 0 deletions src/method/circular.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Create a recurring scheduled task.
*
* @param callback A callback function that needs to be called periodically.
* @param interval number The cycle time, default 1000 (The time unit is milliseconds).
* @param args any[] The callback argument.
*
* @publicApi
*/
export function circular(callback: Function, interval: number, ...args: any[]) {
let timer: NodeJS.Timeout = null;

const close = () => {
if (timer) clearTimeout(timer);
};

const regularly = () => {
close();
timer = setTimeout(regularlyHandler, interval);
};

const regularlyHandler = () => {
callback(...args);
regularly();
};

regularly();

return { close };
}
Loading

0 comments on commit 76dc3c1

Please sign in to comment.