Members
expressAsyncWrapper
- Description:
- Wraps a function to catch any errors thrown and handle them using a provided function.
- Source:
Wraps a function to catch any errors thrown and handle them using a provided function.
Example
const express = require('express');
let router = express.Router();
router.route("/new-endpoint").get(mdx.Utils.Utils.expressAsyncWrapper(async(req,res,next)=>{}));
Methods
(async, static) deleteFiles(filePaths) → {Promise.<Object>}
- Description:
- Used to delete files
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
let filePaths = ["/path/to/file1","/path/to/file2"];
let result = await mdx.Utils.Utils.deleteFiles(filePaths);
Parameters:
Name | Type | Description |
---|---|---|
filePaths |
Array.<string> |
Returns:
A success message is returned once files are deleted
- Type
- Promise.<Object>
(static) getPlaceHierarchy(place) → {string}
- Description:
- Extracts place hierarchy from input place
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
// returns city/intersection
let result = mdx.Utils.Utils.getPlaceHierarchy(city=abc/intersection=xyz);
Parameters:
Name | Type | Description |
---|---|---|
place |
string |
Returns:
- Type
- string
(static) setDifference(set1, set2) → {Set}
- Description:
- Calculates set difference.
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
let result = mdx.Utils.Utils.setDifference(new Set([1,2,3]),new Set([2,3,4]));
Parameters:
Name | Type | Description |
---|---|---|
set1 |
Set | |
set2 |
Set |
Returns:
Returns a set which is a set difference of the input sets
- Type
- Set
(static) setIntersection(set1, set2) → {Set}
- Description:
- Calculates set intersection.
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
let result = mdx.Utils.Utils.setIntersection(new Set([1,2,3]),new Set([2,3,4]));
Parameters:
Name | Type | Description |
---|---|---|
set1 |
Set | |
set2 |
Set |
Returns:
Returns a set which is a set intersection of the input sets
- Type
- Set
(async, static) sleep(ms) → {Promise.<void>}
- Description:
- Asynchronously waits for a specified amount of time.
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
await mdx.Utils.Utils.sleep(2000);
Parameters:
Name | Type | Description |
---|---|---|
ms |
number | The number of milliseconds to wait. ms must be an integer. |
Returns:
A promise that resolves after the specified time has elapsed.
- Type
- Promise.<void>
(static) tsCompare(timestamp1, comparison, timestamp2) → {boolean}
- Description:
- Compares two timestamps.
- Source:
Example
const mdx = require("@nvidia-mdx/web-api-core");
let fromTimestamp = "2023-01-12T11:20:10.000Z";
let toTimestamp = "2023-01-12T14:20:10.000Z";
let result = mdx.Utils.Utils.tsCompare(fromTimestamp,"<",toTimestamp);
Parameters:
Name | Type | Description |
---|---|---|
timestamp1 |
string | |
comparison |
'>' | '>=' | '<' | '<=' | '==' | |
timestamp2 |
string |
Returns:
Returns whether the comparison is true or false
- Type
- boolean