Skip to content

Commit e9489c1

Browse files
committed
misc utils/constants
1 parent 458cf04 commit e9489c1

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

lib/constants.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { reverseKeyValues } from './utils';
2+
3+
export const ConnectionResult = {
4+
SUCCESS: 0,
5+
SERVICE_MISSING: 1,
6+
SERVICE_VERSION_UPDATE_REQUIRED: 2,
7+
SERVICE_DISABLED: 3,
8+
SIGN_IN_REQUIRED: 4,
9+
INVALID_ACCOUNT: 5,
10+
RESOLUTION_REQUIRED: 6,
11+
NETWORK_ERROR: 7,
12+
INTERNAL_ERROR: 8,
13+
SERVICE_INVALID: 9,
14+
DEVELOPER_ERROR: 10,
15+
LICENSE_CHECK_FAILED: 11,
16+
CANCELED: 13,
17+
TIMEOUT: 14,
18+
INTERRUPTED: 15,
19+
API_UNAVAILABLE: 16,
20+
SIGN_IN_FAILED: 17,
21+
SERVICE_UPDATING: 18,
22+
SERVICE_MISSING_PERMISSION: 19,
23+
RESTRICTED_PROFILE: 20,
24+
};
25+
26+
27+
export const ConnectionResultReverse = reverseKeyValues(ConnectionResult);

lib/utils/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Makes an objects keys it's values
3+
* @param object
4+
* @returns {{}}
5+
*/
6+
export function reverseKeyValues(object) {
7+
const output = {};
8+
for (const key in object) {
9+
output[object[key]] = key;
10+
}
11+
return output;
12+
}

0 commit comments

Comments
 (0)