forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenum.ts
More file actions
22 lines (16 loc) · 618 Bytes
/
enum.ts
File metadata and controls
22 lines (16 loc) · 618 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
// tslint:disable:no-any
export function getNamesAndValues<T>(e: any): { name: string; value: T }[] {
return getNames(e).map((n) => ({ name: n, value: e[n] }));
}
export function getNames(e: any) {
return getObjValues(e).filter((v) => typeof v === 'string') as string[];
}
export function getValues<T>(e: any) {
return (getObjValues(e).filter((v) => typeof v === 'number') as any) as T[];
}
function getObjValues(e: any): (number | string)[] {
return Object.keys(e).map((k) => e[k]);
}