diff options
| author | Abdullah Ahmed <abdullah_ahmed@brown.edu> | 2019-08-13 11:02:45 -0400 |
|---|---|---|
| committer | Abdullah Ahmed <abdullah_ahmed@brown.edu> | 2019-08-13 11:02:45 -0400 |
| commit | 6c8b7a4e74068178b0f6ca9e491441bf982b4622 (patch) | |
| tree | cc52f43409819694359d5fcd07f6f01cbd39dea1 /src/Utils.ts | |
| parent | b38e808dc7790cc8698824329ae63b3af210996c (diff) | |
| parent | 9dd2a31b72e5e527e2dae3b68f856ab8da879e93 (diff) | |
Merge branch 'recommender_system' of https://github.com/browngraphicslab/Dash-Web into recommender_system
Diffstat (limited to 'src/Utils.ts')
| -rw-r--r-- | src/Utils.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/Utils.ts b/src/Utils.ts index 8df67df5d..959b89fe5 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -3,6 +3,7 @@ import v5 = require("uuid/v5"); import { Socket } from 'socket.io'; import { Message } from './server/Message'; import { RouteStore } from './server/RouteStore'; +import requestPromise = require('request-promise'); export class Utils { @@ -132,6 +133,8 @@ export function WithKeys(obj: any, keys: string[], addKeyFunc?: (dup: any) => vo return dup; } +export function numberRange(num: number) { return Array.from(Array(num)).map((v, i) => i); } + export function returnTrue() { return true; } export function returnFalse() { return false; } @@ -140,6 +143,8 @@ export function returnOne() { return 1; } export function returnZero() { return 0; } +export function returnEmptyString() { return ""; } + export function emptyFunction() { } export type Without<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>; @@ -171,4 +176,14 @@ export namespace JSONUtils { return results; } +} + +export function PostToServer(relativeRoute: string, body: any) { + let options = { + method: "POST", + uri: Utils.prepend(relativeRoute), + json: true, + body: body + }; + return requestPromise.post(options); }
\ No newline at end of file |
