Skip to content

Commit f1e53b9

Browse files
authored
Merge pull request #104 from launchdarkly/3.4.0
prepare 2.4.0 release
2 parents b3c96d1 + 922a70a commit f1e53b9

File tree

5 files changed

+34
-25
lines changed

5 files changed

+34
-25
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# Change log
22

3-
All notable changes to the LaunchDarkly client-side JavaScript SDK will be documented in this file.
3+
All notable changes to the LaunchDarkly client-side JavaScript SDK will be documented in this file.
44
This project adheres to [Semantic Versioning](http://semver.org).
55

6+
## [2.4.0] - 2018-07-12
7+
### Added:
8+
- Named exports for the `initialize` method and `version` number exports.
9+
10+
### Deprecated:
11+
- Default exports, use named exports instead.
12+
613
## [2.3.1] - 2018-06-29
714
### Fixed:
815
- If a polling request has failed due to an invalid environment key, calling `variation` now returns the default value; previously, it sometimes caused a null reference error.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ldclient-js",
3-
"version": "2.3.1",
3+
"version": "2.4.0",
44
"description": "LaunchDarkly SDK for JavaScript",
55
"author": "LaunchDarkly <[email protected]>",
66
"license": "Apache-2.0",

src/__tests__/LDClient-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import sinon from 'sinon';
22
import semverCompare from 'semver-compare';
33
import EventSource, { sources } from 'eventsourcemock';
44

5-
import LDClient from '../index';
5+
import * as LDClient from '../index';
66
import * as messages from '../messages';
77
import { btoa } from '../utils';
88

src/index.d.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
* Documentation: http://docs.launchdarkly.com/docs/js-sdk-reference
99
*/
1010
declare module 'ldclient-js' {
11-
const LaunchDarkly : {
12-
initialize: (envKey: string, user: LDUser, options?: LDOptions) => LDClient
13-
version: string
11+
export const initialize: (envKey: string, user: LDUser, options?: LDOptions) => LDClient;
12+
export const version: string;
13+
14+
const LaunchDarkly: {
15+
initialize: (envKey: string, user: LDUser, options?: LDOptions) => LDClient;
16+
version: string;
1417
};
1518

1619
export default LaunchDarkly;
@@ -31,17 +34,17 @@ declare module 'ldclient-js' {
3134
* A map of feature flags from their keys to their values.
3235
*/
3336
export type LDFlagSet = {
34-
[key: string]: LDFlagValue,
37+
[key: string]: LDFlagValue;
3538
};
3639

3740
/**
3841
* A map of feature flag keys to objects holding changes in their values.
3942
*/
4043
export type LDFlagChangeset = {
4144
[key: string]: {
42-
current: LDFlagValue,
43-
previous: LDFlagValue,
44-
},
45+
current: LDFlagValue;
46+
previous: LDFlagValue;
47+
};
4548
};
4649

4750
/**
@@ -50,10 +53,10 @@ declare module 'ldclient-js' {
5053
* See LDClient#on and LDClient#off.
5154
*/
5255
type LDEventSignature = (
53-
key: LDEventName,
54-
callback: (current?: LDFlagValue | LDFlagChangeset, previous?: LDFlagValue) => void,
55-
context?: any
56-
) => void;
56+
key: LDEventName,
57+
callback: (current?: LDFlagValue | LDFlagChangeset, previous?: LDFlagValue) => void,
58+
context?: any
59+
) => void;
5760

5861
/**
5962
* LaunchDarkly initialization options.
@@ -68,13 +71,11 @@ declare module 'ldclient-js' {
6871
*/
6972
bootstrap?: 'localStorage' | LDFlagSet;
7073

71-
7274
/**
7375
* The signed user key for Secure Mode.
7476
*/
7577
hash?: string;
7678

77-
7879
/**
7980
* The base url for the LaunchDarkly server.
8081
*
@@ -84,7 +85,6 @@ declare module 'ldclient-js' {
8485
*/
8586
baseUrl?: string;
8687

87-
8888
/**
8989
* The url for the LaunchDarkly events server.
9090
*
@@ -94,7 +94,6 @@ declare module 'ldclient-js' {
9494
*/
9595
eventsUrl?: string;
9696

97-
9897
/**
9998
* The url for the LaunchDarkly stream server.
10099
*
@@ -192,7 +191,7 @@ declare module 'ldclient-js' {
192191
* Any additional attributes associated with the user.
193192
*/
194193
custom?: {
195-
[key: string]: string | boolean | number | Array<string | boolean | number>,
194+
[key: string]: string | boolean | number | Array<string | boolean | number>;
196195
};
197196
}
198197
/**
@@ -201,7 +200,6 @@ declare module 'ldclient-js' {
201200
* @see http://docs.launchdarkly.com/docs/js-sdk-reference
202201
*/
203202
export interface LDClient {
204-
205203
/**
206204
* @returns a Promise containing the initialization state of the client
207205
*/
@@ -226,7 +224,7 @@ declare module 'ldclient-js' {
226224

227225
/**
228226
* Flushes pending events asynchronously.
229-
*
227+
*
230228
* @param onDone
231229
* A callback to invoke after the events were flushed.
232230
*/
@@ -296,5 +294,4 @@ declare module 'ldclient-js' {
296294
*/
297295
allFlags: () => LDFlagSet;
298296
}
299-
300297
}

src/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const changeEvent = 'change';
1414
const goalsEvent = 'goalsReady';
1515
const locationWatcherInterval = 300;
1616

17-
function initialize(env, user, options = {}) {
17+
export function initialize(env, user, options = {}) {
1818
const baseUrl = options.baseUrl || 'https://app.launchdarkly.com';
1919
const eventsUrl = options.eventsUrl || 'https://events.launchdarkly.com';
2020
const streamUrl = options.streamUrl || 'https://clientstream.launchdarkly.com';
@@ -548,6 +548,11 @@ function initialize(env, user, options = {}) {
548548
return client;
549549
}
550550

551-
const version = VERSION;
551+
export const version = VERSION;
552552

553-
export default { initialize, version };
553+
function deprecatedInitialize(env, user, options = {}) {
554+
console && console.warn && console.warn(messages.deprecated('default export', 'named LDClient export'));
555+
return initialize(env, user, options);
556+
}
557+
558+
export default { initialize: deprecatedInitialize, version };

0 commit comments

Comments
 (0)