Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit dfb3b60

Browse files
eduardoemerykjin
authored andcommitted
fix: remove const enums (#132)
1 parent c2764ae commit dfb3b60

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

packages/opencensus-core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"@types/continuation-local-storage": "^3.2.1",
4242
"@types/mocha": "^2.2.48",
4343
"@types/node": "^9.4.7",
44+
"@types/once": "^1.4.0",
4445
"@types/semver": "^5.5.0",
4546
"@types/shimmer": "^1.0.1",
4647
"@types/uuid": "^3.4.3",

packages/opencensus-core/scripts/compile.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* Copyright 2018, OpenCensus Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
import * as path from 'path';
218
import { forkP } from './utils';
319
import * as ts from 'typescript';
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright 2018, OpenCensus Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { ChildProcess, ForkOptions, fork } from 'child_process';
18+
import * as once from 'once';
19+
20+
function promisifyChildProcess(childProcess: ChildProcess): Promise<void> {
21+
return new Promise((resolve, reject) => {
22+
const exit = (err?: Error) => once(() => err ? reject(err) : resolve())();
23+
childProcess.on('error', exit);
24+
childProcess.on('close', (code) => {
25+
if (code === 0) {
26+
exit();
27+
} else {
28+
exit(new Error(`Process ${childProcess.pid} exited with code ${code}.`));
29+
}
30+
});
31+
});
32+
}
33+
34+
export function forkP(moduleName: string, args?: string[], options?: ForkOptions): Promise<void> {
35+
const stringifiedCommand = `\`${moduleName}${args ? (' ' + args.join(' ')) : ''}\``;
36+
console.log(`> Running: ${stringifiedCommand}`);
37+
return promisifyChildProcess(fork(moduleName, args, Object.assign({
38+
stdio: 'inherit'
39+
}, options)));
40+
}

packages/opencensus-core/src/stats/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export interface Measure {
4444
* Describes the unit used for the Measure. Should follows the format described
4545
* by http://unitsofmeasure.org/ucum.html.
4646
*/
47-
export const enum MeasureUnit {
47+
export enum MeasureUnit {
4848
UNIT = '1', // for general counts
4949
BYTE = 'by', // bytes
5050
KBYTE = 'kb', // Kbytes
@@ -54,7 +54,7 @@ export const enum MeasureUnit {
5454
}
5555

5656
/** Describes the types of a Measure. It can be Int64 or a Double type. */
57-
export const enum MeasureType {
57+
export enum MeasureType {
5858
INT64 = 'INT64',
5959
DOUBLE = 'DOUBLE'
6060
}
@@ -119,7 +119,7 @@ export interface View {
119119
* Informs the type of the aggregation. It can be: count, sum, lastValue or
120120
* distribution.
121121
*/
122-
export const enum AggregationType {
122+
export enum AggregationType {
123123
COUNT = 0,
124124
SUM = 1,
125125
LAST_VALUE = 2,

0 commit comments

Comments
 (0)