@lokalise/node-core 9.0.0 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -196,7 +196,7 @@ It's up to the caller of the function to handle the received error or throw an e
196
196
 
197
197
  Read [this article](https://antman-does-software.com/stop-catching-errors-in-typescript-use-the-either-type-to-make-your-code-predictable) for more information on how `Either` works and its benefits.
198
198
 
199
- Additionally, `DefineEither` is also provided. It is a variation of the aforementioned `Either`, which may or may not have `error` set, but always has `result`.
199
+ Additionally, `DefiniteEither` is also provided. It is a variation of the aforementioned `Either`, which may or may not have `error` set, but always has `result`.
200
200
 
201
201
  ### waitAndRetry
202
202
 
@@ -21,4 +21,8 @@ export type DefiniteEither<T, U> = {
21
21
  error?: T;
22
22
  result: U;
23
23
  };
24
+ export declare const isFailure: <T, U>(e: Either<T, U>) => e is Left<T>;
25
+ export declare const isSuccess: <T, U>(e: Either<T, U>) => e is Right<U>;
26
+ export declare const failure: <T>(error: T) => Left<T>;
27
+ export declare const success: <U>(result: U) => Right<U>;
24
28
  export {};
@@ -1,3 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.success = exports.failure = exports.isSuccess = exports.isFailure = void 0;
4
+ const isFailure = (e) => {
5
+ return e.error !== undefined;
6
+ };
7
+ exports.isFailure = isFailure;
8
+ const isSuccess = (e) => {
9
+ return e.result !== undefined;
10
+ };
11
+ exports.isSuccess = isSuccess;
12
+ const failure = (error) => ({ error });
13
+ exports.failure = failure;
14
+ const success = (result) => ({ result });
15
+ exports.success = success;
3
16
  //# sourceMappingURL=either.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"either.js","sourceRoot":"","sources":["../../../src/errors/either.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"either.js","sourceRoot":"","sources":["../../../src/errors/either.ts"],"names":[],"mappings":";;;AA2BO,MAAM,SAAS,GAAG,CAAO,CAAe,EAAgB,EAAE;IAC/D,OAAO,CAAC,CAAC,KAAK,KAAK,SAAS,CAAA;AAC9B,CAAC,CAAA;AAFY,QAAA,SAAS,aAErB;AAEM,MAAM,SAAS,GAAG,CAAO,CAAe,EAAiB,EAAE;IAChE,OAAO,CAAC,CAAC,MAAM,KAAK,SAAS,CAAA;AAC/B,CAAC,CAAA;AAFY,QAAA,SAAS,aAErB;AAEM,MAAM,OAAO,GAAG,CAAI,KAAQ,EAAW,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAA/C,QAAA,OAAO,WAAwC;AAErD,MAAM,OAAO,GAAG,CAAI,MAAS,EAAY,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;AAAlD,QAAA,OAAO,WAA2C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lokalise/node-core",
3
- "version": "9.0.0",
3
+ "version": "9.1.0",
4
4
  "author": {
5
5
  "name": "Lokalise",
6
6
  "url": "https://lokalise.com/"