-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathSetUtils.ts
More file actions
30 lines (25 loc) · 810 Bytes
/
SetUtils.ts
File metadata and controls
30 lines (25 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { inject, injectable } from 'inversify';
import { ServiceIdentifiers } from '../container/ServiceIdentifiers';
import { IArrayUtils } from '../interfaces/utils/IArrayUtils';
import { ISetUtils } from '../interfaces/utils/ISetUtils';
@injectable()
export class SetUtils implements ISetUtils {
/**
* @type {IArrayUtils}
*/
private readonly arrayUtils: IArrayUtils;
/**
* @param {IArrayUtils} arrayUtils
*/
public constructor(@inject(ServiceIdentifiers.IArrayUtils) arrayUtils: IArrayUtils) {
this.arrayUtils = arrayUtils;
}
/**
* @param {Set<T>} set
* @returns {T | undefined}
*/
public getLastElement<T>(set: Set<T>): T | undefined {
const array = [...set];
return this.arrayUtils.getLastElement(array);
}
}