@temporalio/common
Advanced tools
Comparing version 1.10.2 to 1.10.3
@@ -15,2 +15,7 @@ import { StringValue } from 'ms'; | ||
/** | ||
* Lossy conversion function from Timestamp to number due to possible overflow. | ||
* If ts is null or undefined, throws a TypeError, with error message including the name of the field. | ||
*/ | ||
export declare function requiredTsToMs(ts: Timestamp | null | undefined, fieldName: string): number; | ||
/** | ||
* Lossy conversion function from Timestamp to number due to possible overflow | ||
@@ -25,3 +30,4 @@ */ | ||
export declare function tsToDate(ts: Timestamp): Date; | ||
export declare function requiredTsToDate(ts: Timestamp | null | undefined, fieldName: string): Date; | ||
export declare function optionalTsToDate(ts: Timestamp | null | undefined): Date | undefined; | ||
export declare function optionalDateToTs(date: Date | null | undefined): Timestamp | undefined; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.optionalDateToTs = exports.optionalTsToDate = exports.tsToDate = exports.msToNumber = exports.msOptionalToNumber = exports.msOptionalToTs = exports.msToTs = exports.msNumberToTs = exports.tsToMs = exports.optionalTsToMs = void 0; | ||
exports.optionalDateToTs = exports.optionalTsToDate = exports.requiredTsToDate = exports.tsToDate = exports.msToNumber = exports.msOptionalToNumber = exports.msOptionalToTs = exports.msToTs = exports.msNumberToTs = exports.tsToMs = exports.requiredTsToMs = exports.optionalTsToMs = void 0; | ||
const long_1 = __importDefault(require("long")); // eslint-disable-line import/no-named-as-default | ||
@@ -23,2 +23,13 @@ const ms_1 = __importDefault(require("ms")); | ||
/** | ||
* Lossy conversion function from Timestamp to number due to possible overflow. | ||
* If ts is null or undefined, throws a TypeError, with error message including the name of the field. | ||
*/ | ||
function requiredTsToMs(ts, fieldName) { | ||
if (ts === undefined || ts === null) { | ||
throw new TypeError(`Expected ${fieldName} to be a timestamp, got ${ts}`); | ||
} | ||
return tsToMs(ts); | ||
} | ||
exports.requiredTsToMs = requiredTsToMs; | ||
/** | ||
* Lossy conversion function from Timestamp to number due to possible overflow | ||
@@ -78,2 +89,7 @@ */ | ||
exports.tsToDate = tsToDate; | ||
// ts-prune-ignore-next | ||
function requiredTsToDate(ts, fieldName) { | ||
return new Date(requiredTsToMs(ts, fieldName)); | ||
} | ||
exports.requiredTsToDate = requiredTsToDate; | ||
function optionalTsToDate(ts) { | ||
@@ -80,0 +96,0 @@ if (ts === undefined || ts === null) { |
{ | ||
"name": "@temporalio/common", | ||
"version": "1.10.2", | ||
"version": "1.10.3", | ||
"description": "Common library for code that's used across the Client, Worker, and/or Workflow", | ||
@@ -15,3 +15,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@temporalio/proto": "1.10.2", | ||
"@temporalio/proto": "1.10.3", | ||
"long": "^5.2.3", | ||
@@ -40,3 +40,3 @@ "ms": "^3.0.0-canary.1", | ||
], | ||
"gitHead": "a44bdfa780c1247fe7ed82b4b73c7b1577ee94af" | ||
"gitHead": "7832067434443145e1f0ddf07cb37b0b90158bfb" | ||
} |
@@ -32,2 +32,13 @@ import Long from 'long'; // eslint-disable-line import/no-named-as-default | ||
/** | ||
* Lossy conversion function from Timestamp to number due to possible overflow. | ||
* If ts is null or undefined, throws a TypeError, with error message including the name of the field. | ||
*/ | ||
export function requiredTsToMs(ts: Timestamp | null | undefined, fieldName: string): number { | ||
if (ts === undefined || ts === null) { | ||
throw new TypeError(`Expected ${fieldName} to be a timestamp, got ${ts}`); | ||
} | ||
return tsToMs(ts); | ||
} | ||
/** | ||
* Lossy conversion function from Timestamp to number due to possible overflow | ||
@@ -87,2 +98,7 @@ */ | ||
// ts-prune-ignore-next | ||
export function requiredTsToDate(ts: Timestamp | null | undefined, fieldName: string): Date { | ||
return new Date(requiredTsToMs(ts, fieldName)); | ||
} | ||
export function optionalTsToDate(ts: Timestamp | null | undefined): Date | undefined { | ||
@@ -89,0 +105,0 @@ if (ts === undefined || ts === null) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
405720
7895
+ Added@temporalio/proto@1.10.3(transitive)
- Removed@temporalio/proto@1.10.2(transitive)
Updated@temporalio/proto@1.10.3