Добавлен штамп времени для любых объектов
This commit is contained in:
parent
26ed9b92f9
commit
326b97931c
2 changed files with 11 additions and 0 deletions
3
libs/event-emitter/src/models/timestamped.ts
Normal file
3
libs/event-emitter/src/models/timestamped.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export type Timestamped = {
|
||||||
|
_timestamp: number;
|
||||||
|
};
|
||||||
8
libs/event-emitter/src/utils/timestamp-now-fill.ts
Normal file
8
libs/event-emitter/src/utils/timestamp-now-fill.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { Timestamped } from '../models/timestamped';
|
||||||
|
|
||||||
|
export function TimestampNowFill<T>(obj: T): T & Timestamped {
|
||||||
|
const now = new Date().getDate();
|
||||||
|
const res: any = obj;
|
||||||
|
res._timestamp = now;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue