@aleodoni-common/result
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,1 +0,17 @@ | ||
export * from './result/Result'; | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./result/Result"), exports); |
@@ -1,3 +0,6 @@ | ||
export class Result { | ||
constructor(isSuccess, error, value) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.right = exports.left = exports.Right = exports.Left = exports.Result = void 0; | ||
var Result = /** @class */ (function () { | ||
function Result(isSuccess, error, value) { | ||
if (isSuccess && error) { | ||
@@ -15,3 +18,3 @@ throw new Error("InvalidOperation: A result cannot be successful and contain an error"); | ||
} | ||
getValue() { | ||
Result.prototype.getValue = function () { | ||
if (!this.isSuccess) { | ||
@@ -22,14 +25,15 @@ console.log(this.error); | ||
return this._value; | ||
} | ||
errorValue() { | ||
}; | ||
Result.prototype.errorValue = function () { | ||
return this.error; | ||
} | ||
static ok(value) { | ||
}; | ||
Result.ok = function (value) { | ||
return new Result(true, undefined, value); | ||
} | ||
static fail(error) { | ||
}; | ||
Result.fail = function (error) { | ||
return new Result(false, error); | ||
} | ||
static combine(results) { | ||
for (let result of results) { | ||
}; | ||
Result.combine = function (results) { | ||
for (var _i = 0, results_1 = results; _i < results_1.length; _i++) { | ||
var result = results_1[_i]; | ||
if (result.isFailure) | ||
@@ -39,31 +43,39 @@ return result; | ||
return Result.ok(); | ||
} | ||
} | ||
export class Left { | ||
constructor(value) { | ||
}; | ||
return Result; | ||
}()); | ||
exports.Result = Result; | ||
var Left = /** @class */ (function () { | ||
function Left(value) { | ||
this.value = value; | ||
} | ||
isLeft() { | ||
Left.prototype.isLeft = function () { | ||
return true; | ||
} | ||
isRight() { | ||
}; | ||
Left.prototype.isRight = function () { | ||
return false; | ||
} | ||
} | ||
export class Right { | ||
constructor(value) { | ||
}; | ||
return Left; | ||
}()); | ||
exports.Left = Left; | ||
var Right = /** @class */ (function () { | ||
function Right(value) { | ||
this.value = value; | ||
} | ||
isLeft() { | ||
Right.prototype.isLeft = function () { | ||
return false; | ||
} | ||
isRight() { | ||
}; | ||
Right.prototype.isRight = function () { | ||
return true; | ||
} | ||
} | ||
export const left = (l) => { | ||
}; | ||
return Right; | ||
}()); | ||
exports.Right = Right; | ||
var left = function (l) { | ||
return new Left(l); | ||
}; | ||
export const right = (a) => { | ||
exports.left = left; | ||
var right = function (a) { | ||
return new Right(a); | ||
}; | ||
exports.right = right; |
{ | ||
"name": "@aleodoni-common/result", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "./build/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./build/index.d.ts", |
4536
123