diff options
author | laurawilsonri <laura_wilson@brown.edu> | 2019-04-15 20:20:46 -0400 |
---|---|---|
committer | laurawilsonri <laura_wilson@brown.edu> | 2019-04-15 20:20:46 -0400 |
commit | b7a766aa5d53686e032b34d7213ad543108f12c3 (patch) | |
tree | d71854e091fa24997a30856d9ac9c937a6cd45d2 /src/Utils.ts | |
parent | 8b1026d357dd40fc4a00010739d99ffc9db08641 (diff) | |
parent | ff6ba4107aa33e021803399180b0d2844fc19d84 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into richTextEditor
Diffstat (limited to 'src/Utils.ts')
-rw-r--r-- | src/Utils.ts | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/Utils.ts b/src/Utils.ts index c629bc263..dec6245ef 100644 --- a/src/Utils.ts +++ b/src/Utils.ts @@ -1,7 +1,7 @@ import v4 = require('uuid/v4'); import v5 = require("uuid/v5"); import { Socket } from 'socket.io'; -import { Message, Types } from './server/Message'; +import { Message, Types, Transferable } from './server/Message'; import { Document } from './fields/Document'; export class Utils { @@ -48,7 +48,7 @@ export class Utils { if (this.logFilter !== undefined && this.logFilter !== message.type) { return; } - let idString = (message._id || message.id || "").padStart(36, ' '); + let idString = (message.id || "").padStart(36, ' '); prefix = prefix.padEnd(16, ' '); console.log(`${prefix}: ${idString}, ${receiving ? 'receiving' : 'sending'} ${messageName} with data ${JSON.stringify(message)}`); } @@ -87,10 +87,25 @@ export class Utils { } } +export function OmitKeys(obj: any, keys: any, addKeyFunc?: (dup: any) => void) { + var dup: any = {}; + for (var key in obj) { + if (keys.indexOf(key) === -1) { + dup[key] = obj[key]; + } + } + addKeyFunc && addKeyFunc(dup); + return dup; +} + export function returnTrue() { return true; } export function returnFalse() { return false; } +export function returnOne() { return 1; } + +export function returnZero() { return 0; } + export function emptyFunction() { } export function emptyDocFunction(doc: Document) { } |