launchdarkly-js-sdk-common 5.0.0-alpha.4 → 5.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/context.js +5 -3
- package/test-types.ts +2 -0
- package/typings.d.ts +5 -0
package/package.json
CHANGED
package/src/context.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* @param {string} kind
|
|
4
4
|
* @returns true if the kind is valid.
|
|
5
5
|
*/
|
|
6
|
+
const { commonBasicLogger } = require('./loggers');
|
|
7
|
+
|
|
6
8
|
function validKind(kind) {
|
|
7
9
|
return typeof kind === 'string' && kind !== 'kind' && kind.match(/^(\w|\.|-)+$/);
|
|
8
10
|
}
|
|
@@ -89,7 +91,7 @@ function getCanonicalKey(context) {
|
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
|
|
92
|
-
function getContextKeys(context, logger) {
|
|
94
|
+
function getContextKeys(context, logger = commonBasicLogger()) {
|
|
93
95
|
if (!context) {
|
|
94
96
|
return undefined;
|
|
95
97
|
}
|
|
@@ -111,10 +113,10 @@ function getContextKeys(context, logger) {
|
|
|
111
113
|
});
|
|
112
114
|
break;
|
|
113
115
|
case null:
|
|
114
|
-
logger
|
|
116
|
+
logger.warn(`null is not a valid context kind: ${context}`);
|
|
115
117
|
break;
|
|
116
118
|
case '':
|
|
117
|
-
logger
|
|
119
|
+
logger.warn(`'' is not a valid context kind: ${context}`);
|
|
118
120
|
break;
|
|
119
121
|
default:
|
|
120
122
|
keys[kind] = `${key}`;
|
package/test-types.ts
CHANGED
package/typings.d.ts
CHANGED
|
@@ -984,6 +984,11 @@ declare module 'launchdarkly-js-sdk-common' {
|
|
|
984
984
|
*/
|
|
985
985
|
export type LDLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
|
|
986
986
|
|
|
987
|
+
export function getContextKeys(
|
|
988
|
+
context: LDContext,
|
|
989
|
+
logger?: LDLogger,
|
|
990
|
+
): {[attribute: string]: string} | undefined;
|
|
991
|
+
|
|
987
992
|
/**
|
|
988
993
|
* Callback interface for collecting information about the SDK at runtime.
|
|
989
994
|
*
|