Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d53fe44766 | |||
| 993c4e07bc | |||
| 8329bb902f | |||
| 7acda53d57 |
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@push.rocks/smartguard",
|
||||
"version": "2.0.4",
|
||||
"version": "3.0.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@push.rocks/smartguard",
|
||||
"version": "2.0.4",
|
||||
"version": "3.0.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@push.rocks/smartpromise": "^3.0.2",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@push.rocks/smartguard",
|
||||
"version": "2.0.4",
|
||||
"version": "3.0.1",
|
||||
"private": false,
|
||||
"description": "A TypeScript library for creating and managing validation guards, aiding in data validation and security checks.",
|
||||
"main": "dist_ts/index.js",
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartguard',
|
||||
version: '2.0.4',
|
||||
version: '3.0.1',
|
||||
description: 'A TypeScript library for creating and managing validation guards, aiding in data validation and security checks.'
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export class Guard<T> {
|
||||
* executes the guard against a data argument;
|
||||
* @param dataArg
|
||||
*/
|
||||
public async executeGuardWithData(dataArg: T) {
|
||||
public async exec(dataArg: T) {
|
||||
const result = await this.guardFunction(dataArg);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -19,11 +19,11 @@ export class GuardSet<T> extends Guard<T> {
|
||||
* executes all guards in all guardSets against a data argument
|
||||
* @param dataArg
|
||||
*/
|
||||
public async executeAllGuardsWithData(dataArg: T) {
|
||||
public async execAllWithData(dataArg: T) {
|
||||
const resultPromises: Array<Promise<boolean>> = [];
|
||||
|
||||
for (const guard of this.guards) {
|
||||
const guardResultPromise = guard.executeGuardWithData(dataArg);
|
||||
const guardResultPromise = guard.exec(dataArg);
|
||||
resultPromises.push(guardResultPromise);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export class GuardSet<T> extends Guard<T> {
|
||||
* @param dataArg
|
||||
*/
|
||||
public async allGuardsPass(dataArg: T): Promise<boolean> {
|
||||
const results = await this.executeAllGuardsWithData(dataArg);
|
||||
const results = await this.execAllWithData(dataArg);
|
||||
return results.every(result => result);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export class GuardSet<T> extends Guard<T> {
|
||||
* @param dataArg
|
||||
*/
|
||||
public async anyGuardsPass(dataArg: T): Promise<boolean> {
|
||||
const results = await this.executeAllGuardsWithData(dataArg);
|
||||
const results = await this.execAllWithData(dataArg);
|
||||
return results.some(result => result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// @push.rocks scope
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
|
||||
// pushrocks scope
|
||||
export { smartpromise };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user