Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

result-tsk

Package Overview
Dependencies
Maintainers
0
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

result-tsk - npm Package Compare versions

Comparing version 2.1.5 to 2.1.6

6

CHANGELOG.md

@@ -113,1 +113,7 @@ # Changelog

- Feature to execute promise and control the error was added to able the perform to use of pure functions
## [2.1.6] — 2024-06-27
### Update
- Packages was updated and the functions now can be call in a chained way

16

lib/generic/Result.d.ts
import { Metadata } from "../Result.interface";
import { IResult } from "./Result.interface";
import { ResultExecution } from "../Types";
import { ResultDto } from "../ResultDto";
import { ResultExecution } from "../Types";
export declare class Result<T> implements IResult<T> {

@@ -12,17 +12,17 @@ #private;

error: string;
setMetadata(metadata: Metadata): void;
addMetadata(key: string, value: string | number): void;
setMetadata(metadata: Metadata): IResult<T>;
addMetadata(key: string, value: string | number): IResult<T>;
getMetadata(): Metadata;
hasMetadata(): boolean;
setStatusCode(statusCode: number | string, success: boolean): void;
setMessage(message: string, statusCode: number | string): void;
setError(error: string, statusCode: number | string): void;
setStatusCode(statusCode: number | string, success: boolean): IResult<T>;
setMessage(message: string, statusCode: number | string): IResult<T>;
setError(error: string, statusCode: number | string): IResult<T>;
hasError(): boolean;
hasMessage(): boolean;
hasData(): boolean;
setData(data: string | T, statusCode: number | string, message?: string): void;
toResultDto(): ResultDto;
setData(data: string | T, statusCode: number | string, message?: string): IResult<T>;
execute<RO>(promise: Promise<ResultExecution<RO>>): Promise<IResult<T> & {
value: RO;
}>;
toResultDto(): ResultDto;
}

@@ -6,4 +6,4 @@ import { IBaseResult } from "../Result.interface";

data: T | string;
setData(data: T | string, statusCode: number | string): void;
setData(data: T | string, statusCode: number | string, message: string): void;
setData(data: T | string, statusCode: number | string): IResult<T>;
setData(data: T | string, statusCode: number | string, message: string): IResult<T>;
hasData(): boolean;

@@ -10,0 +10,0 @@ toResultDto(): ResultDto;

@@ -32,2 +32,3 @@ "use strict";

__classPrivateFieldSet(this, _Result_metadata, metadata, "f");
return this;
}

@@ -38,2 +39,3 @@ addMetadata(key, value) {

__classPrivateFieldGet(this, _Result_metadata, "f")[key] = value;
return this;
}

@@ -49,2 +51,3 @@ getMetadata() {

this.success = success;
return this;
}

@@ -55,2 +58,3 @@ setMessage(message, statusCode) {

this.success = true;
return this;
}

@@ -61,2 +65,3 @@ setError(error, statusCode) {

this.success = false;
return this;
}

@@ -79,12 +84,7 @@ hasError() {

}
return this;
}
toResultDto() {
const result = new ResultDto_1.ResultDto();
result.error = this.error;
result.message = this.message;
result.data = this.data;
return result;
}
execute(promise) {
return __awaiter(this, void 0, void 0, function* () {
let value = undefined;
const execution = yield promise;

@@ -94,7 +94,17 @@ if (execution.error) {

}
return Object.assign(Object.assign({}, this), { value: execution === null || execution === void 0 ? void 0 : execution.value });
else {
value = execution.value;
}
return Object.assign(Object.assign({}, this), { value });
});
}
toResultDto() {
const result = new ResultDto_1.ResultDto();
result.error = this.error;
result.message = this.message;
result.data = this.data;
return result;
}
}
exports.Result = Result;
_Result_metadata = new WeakMap();

@@ -10,15 +10,15 @@ import { ResultExecution } from "./Types";

error: string;
setMetadata(metadata: Metadata): void;
addMetadata(key: string, value: string | number): void;
setMetadata(metadata: Metadata): IResult;
addMetadata(key: string, value: string | number): IResult;
getMetadata(): Metadata;
hasMetadata(): boolean;
setStatusCode(statusCode: number | string, success: boolean): void;
setMessage(message: string, statusCode: number | string): void;
setError(error: string, statusCode: number | string): void;
setStatusCode(statusCode: number | string, success: boolean): IResult;
setMessage(message: string, statusCode: number | string): IResult;
setError(error: string, statusCode: number | string): IResult;
hasError(): boolean;
hasMessage(): boolean;
toResultDto(): ResultDto;
execute<RO>(promise: Promise<ResultExecution<RO>>): Promise<IResult & {
value: RO;
}>;
toResultDto(): ResultDto;
}

@@ -9,10 +9,10 @@ import { ResultExecution } from "./Types";

error: string;
setStatusCode(statusCode: number | string, success: boolean): void;
setMessage(message: string, statusCode: number | string): void;
setError(error: string, statusCode: number | string): void;
setStatusCode(statusCode: number | string, success: boolean): IResult;
setMessage(message: string, statusCode: number | string): IResult;
setError(error: string, statusCode: number | string): IResult;
hasError(): boolean;
hasMessage(): boolean;
toResultDto(): ResultDto;
setMetadata(headers: Metadata): void;
addMetadata(key: string, value: string | number): void;
setMetadata(headers: Metadata): IResult;
addMetadata(key: string, value: string | number): IResult;
getMetadata(): Metadata;

@@ -19,0 +19,0 @@ hasMetadata(): boolean;

@@ -32,2 +32,3 @@ "use strict";

__classPrivateFieldSet(this, _Result_metadata, metadata, "f");
return this;
}

@@ -38,5 +39,7 @@ addMetadata(key, value) {

__classPrivateFieldGet(this, _Result_metadata, "f")[key] = value;
return this;
}
getMetadata() {
return __classPrivateFieldGet(this, _Result_metadata, "f");
return this;
}

@@ -49,2 +52,3 @@ hasMetadata() {

this.success = success;
return this;
}

@@ -55,2 +59,3 @@ setMessage(message, statusCode) {

this.success = true;
return this;
}

@@ -61,2 +66,3 @@ setError(error, statusCode) {

this.success = false;
return this;
}

@@ -69,10 +75,5 @@ hasError() {

}
toResultDto() {
const result = new ResultDto_1.ResultDto();
result.error = this.error;
result.message = this.message;
return result;
}
execute(promise) {
return __awaiter(this, void 0, void 0, function* () {
let value = undefined;
const execution = yield promise;

@@ -82,7 +83,16 @@ if (execution.error) {

}
return Object.assign(Object.assign({}, this), { value: execution === null || execution === void 0 ? void 0 : execution.value });
else {
value = execution.value;
}
return Object.assign(Object.assign({}, this), { value });
});
}
toResultDto() {
const result = new ResultDto_1.ResultDto();
result.error = this.error;
result.message = this.message;
return result;
}
}
exports.Result = Result;
_Result_metadata = new WeakMap();
{
"name": "result-tsk",
"version": "2.1.5",
"version": "2.1.6",
"description": "result tool to use with or without NodeTskeleton template project",

@@ -34,6 +34,6 @@ "repository": {

"devDependencies": {
"@types/node": "^18.19.3",
"typescript": "^5.3.3"
"@types/node": "^20.14.9",
"typescript": "^5.5.2"
},
"dependencies": {}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc