@splitsoftware/splitio-commons 1.0.1-rc.2 → 1.0.1-rc.3
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/cjs/storages/pluggable/constants.js +1 -1
- package/cjs/sync/streaming/SSEClient/index.js +0 -1
- package/cjs/utils/MinEventEmitter.js +5 -5
- package/cjs/utils/env/isNode.js +4 -1
- package/esm/storages/pluggable/constants.js +1 -1
- package/esm/sync/streaming/SSEClient/index.js +0 -1
- package/esm/utils/MinEventEmitter.js +5 -5
- package/esm/utils/env/isNode.js +4 -1
- package/package.json +3 -4
- package/src/sdkFactory/types.ts +2 -2
- package/src/services/types.ts +16 -2
- package/src/storages/pluggable/constants.ts +1 -1
- package/src/sync/streaming/SSEClient/index.ts +5 -5
- package/src/types.ts +9 -8
- package/src/utils/MinEventEmitter.ts +10 -10
- package/src/utils/env/isNode.ts +4 -1
- package/types/sdkFactory/types.d.ts +2 -2
- package/types/services/types.d.ts +13 -0
- package/types/storages/pluggable/constants.d.ts +1 -1
- package/types/sync/streaming/SSEClient/index.d.ts +4 -3
- package/types/types.d.ts +9 -9
- package/types/utils/MinEventEmitter.d.ts +6 -6
- package/types/utils/env/isNode.d.ts +4 -0
|
@@ -34,7 +34,6 @@ var SSEClient = /** @class */ (function () {
|
|
|
34
34
|
* @throws 'EventSource API is not available. ' if EventSource is not available.
|
|
35
35
|
*/
|
|
36
36
|
function SSEClient(settings, useHeaders, getEventSource) {
|
|
37
|
-
// @ts-expect-error
|
|
38
37
|
this.eventSource = getEventSource && getEventSource();
|
|
39
38
|
// if eventSource is not available, throw an exception
|
|
40
39
|
if (!this.eventSource)
|
|
@@ -35,13 +35,13 @@ var EventEmitter = /** @class */ (function () {
|
|
|
35
35
|
EventEmitter.prototype.once = function (type, listener) {
|
|
36
36
|
return this.registerListener(type, listener, true);
|
|
37
37
|
};
|
|
38
|
-
//
|
|
39
|
-
EventEmitter.prototype.removeListener = function (type, listener) {
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
EventEmitter.prototype.removeListener = function ( /* type: string, listener: (...args: any[]) => void */) {
|
|
40
40
|
throw new Error('Method not implemented.');
|
|
41
41
|
};
|
|
42
|
-
// alias of removeListener
|
|
43
|
-
EventEmitter.prototype.off = function (type, listener) {
|
|
44
|
-
return this.removeListener(type, listener);
|
|
42
|
+
// @ts-ignore alias of removeListener
|
|
43
|
+
EventEmitter.prototype.off = function ( /* type: string, listener: (...args: any[]) => void */) {
|
|
44
|
+
return this.removeListener( /* type, listener */);
|
|
45
45
|
};
|
|
46
46
|
EventEmitter.prototype.emit = function (type) {
|
|
47
47
|
var args = [];
|
package/cjs/utils/env/isNode.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNode = void 0;
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* 'true' if running in Node.js, or 'false' otherwise.
|
|
6
|
+
* We check for version truthiness since most shims will have that as empty string.
|
|
7
|
+
*/
|
|
5
8
|
// eslint-disable-next-line no-undef
|
|
6
9
|
exports.isNode = typeof process !== 'undefined' && typeof process.version !== 'undefined' && !!process.version ? true : false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export var LOG_PREFIX = 'storage:pluggable:';
|
|
1
|
+
export var LOG_PREFIX = 'storage:pluggable: ';
|
|
@@ -32,7 +32,6 @@ var SSEClient = /** @class */ (function () {
|
|
|
32
32
|
* @throws 'EventSource API is not available. ' if EventSource is not available.
|
|
33
33
|
*/
|
|
34
34
|
function SSEClient(settings, useHeaders, getEventSource) {
|
|
35
|
-
// @ts-expect-error
|
|
36
35
|
this.eventSource = getEventSource && getEventSource();
|
|
37
36
|
// if eventSource is not available, throw an exception
|
|
38
37
|
if (!this.eventSource)
|
|
@@ -33,13 +33,13 @@ var EventEmitter = /** @class */ (function () {
|
|
|
33
33
|
EventEmitter.prototype.once = function (type, listener) {
|
|
34
34
|
return this.registerListener(type, listener, true);
|
|
35
35
|
};
|
|
36
|
-
//
|
|
37
|
-
EventEmitter.prototype.removeListener = function (type, listener) {
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
EventEmitter.prototype.removeListener = function ( /* type: string, listener: (...args: any[]) => void */) {
|
|
38
38
|
throw new Error('Method not implemented.');
|
|
39
39
|
};
|
|
40
|
-
// alias of removeListener
|
|
41
|
-
EventEmitter.prototype.off = function (type, listener) {
|
|
42
|
-
return this.removeListener(type, listener);
|
|
40
|
+
// @ts-ignore alias of removeListener
|
|
41
|
+
EventEmitter.prototype.off = function ( /* type: string, listener: (...args: any[]) => void */) {
|
|
42
|
+
return this.removeListener( /* type, listener */);
|
|
43
43
|
};
|
|
44
44
|
EventEmitter.prototype.emit = function (type) {
|
|
45
45
|
var args = [];
|
package/esm/utils/env/isNode.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 'true' if running in Node.js, or 'false' otherwise.
|
|
3
|
+
* We check for version truthiness since most shims will have that as empty string.
|
|
4
|
+
*/
|
|
2
5
|
// eslint-disable-next-line no-undef
|
|
3
6
|
export var isNode = typeof process !== 'undefined' && typeof process.version !== 'undefined' && !!process.version ? true : false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splitsoftware/splitio-commons",
|
|
3
|
-
"version": "1.0.1-rc.
|
|
3
|
+
"version": "1.0.1-rc.3",
|
|
4
4
|
"description": "Split Javascript SDK common components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -49,10 +49,9 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/google.analytics": "0.0.40",
|
|
52
|
-
"@types/ioredis": "^4.
|
|
52
|
+
"@types/ioredis": "^4.28.0",
|
|
53
53
|
"@types/jest": "^27.0.0",
|
|
54
54
|
"@types/lodash": "^4.14.162",
|
|
55
|
-
"@types/node": "^14.14.7",
|
|
56
55
|
"@types/object-assign": "^4.0.30",
|
|
57
56
|
"@typescript-eslint/eslint-plugin": "^4.2.0",
|
|
58
57
|
"@typescript-eslint/parser": "^4.2.0",
|
|
@@ -61,7 +60,7 @@
|
|
|
61
60
|
"eslint": "^7.32.0",
|
|
62
61
|
"eslint-plugin-compat": "3.7.0",
|
|
63
62
|
"fetch-mock": "^9.10.7",
|
|
64
|
-
"ioredis": "^4.
|
|
63
|
+
"ioredis": "^4.28.0",
|
|
65
64
|
"jest": "^27.2.3",
|
|
66
65
|
"jest-localstorage-mock": "^2.4.3",
|
|
67
66
|
"js-yaml": "^3.14.0",
|
package/src/sdkFactory/types.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ISignalListener } from '../listeners/types';
|
|
|
3
3
|
import { ILogger } from '../logger/types';
|
|
4
4
|
import { ISdkReadinessManager } from '../readiness/types';
|
|
5
5
|
import { ISdkClientFactoryParams } from '../sdkClient/types';
|
|
6
|
-
import { IFetch, ISplitApi } from '../services/types';
|
|
6
|
+
import { IFetch, ISplitApi, IEventSourceConstructor } from '../services/types';
|
|
7
7
|
import { IStorageAsync, IStorageSync, ISplitsCacheSync, ISplitsCacheAsync, IStorageFactoryParams } from '../storages/types';
|
|
8
8
|
import { ISyncManager, ISyncManagerFactoryParams } from '../sync/types';
|
|
9
9
|
import { IImpressionObserver } from '../trackers/impressionObserver/types';
|
|
@@ -16,7 +16,7 @@ import { SplitIO, ISettings, IEventEmitter } from '../types';
|
|
|
16
16
|
export interface IPlatform {
|
|
17
17
|
getOptions?: () => object
|
|
18
18
|
getFetch?: () => (IFetch | undefined)
|
|
19
|
-
getEventSource?: () => (
|
|
19
|
+
getEventSource?: () => (IEventSourceConstructor | undefined)
|
|
20
20
|
EventEmitter: new () => IEventEmitter
|
|
21
21
|
}
|
|
22
22
|
|
package/src/services/types.ts
CHANGED
|
@@ -50,8 +50,8 @@ export type IPostMetricsCounters = (body: string) => Promise<IResponse>
|
|
|
50
50
|
export type IPostMetricsTimes = (body: string) => Promise<IResponse>
|
|
51
51
|
|
|
52
52
|
export interface ISplitApi {
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
getSdkAPIHealthCheck: IHealthCheckAPI
|
|
54
|
+
getEventsAPIHealthCheck: IHealthCheckAPI
|
|
55
55
|
fetchAuth: IFetchAuth
|
|
56
56
|
fetchSplitChanges: IFetchSplitChanges
|
|
57
57
|
fetchSegmentChanges: IFetchSegmentChanges
|
|
@@ -62,3 +62,17 @@ export interface ISplitApi {
|
|
|
62
62
|
postMetricsCounters: IPostMetricsCounters
|
|
63
63
|
postMetricsTimes: IPostMetricsTimes
|
|
64
64
|
}
|
|
65
|
+
|
|
66
|
+
// Minimal version of EventSource API used by the SDK
|
|
67
|
+
interface EventSourceEventMap {
|
|
68
|
+
'error': Event
|
|
69
|
+
'message': MessageEvent
|
|
70
|
+
'open': Event
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface IEventSource {
|
|
74
|
+
addEventListener<K extends keyof EventSourceEventMap>(type: K, listener: (this: IEventSource, ev: EventSourceEventMap[K]) => any): void
|
|
75
|
+
close(): void
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type IEventSourceConstructor = new (url: string, eventSourceInitDict?: { headers?: object }) => IEventSource
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LOG_PREFIX = 'storage:pluggable:';
|
|
1
|
+
export const LOG_PREFIX = 'storage:pluggable: ';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IEventSourceConstructor } from '../../../services/types';
|
|
1
2
|
import { ISettings } from '../../../types';
|
|
2
3
|
import { IAuthTokenPushEnabled } from '../AuthClient/types';
|
|
3
4
|
import { ISSEClient, ISseEventHandler } from './types';
|
|
@@ -31,9 +32,9 @@ function buildSSEHeaders(settings: ISettings) {
|
|
|
31
32
|
*/
|
|
32
33
|
export default class SSEClient implements ISSEClient {
|
|
33
34
|
// Instance properties:
|
|
34
|
-
eventSource
|
|
35
|
+
eventSource?: IEventSourceConstructor;
|
|
35
36
|
streamingUrl: string;
|
|
36
|
-
connection?: InstanceType<
|
|
37
|
+
connection?: InstanceType<IEventSourceConstructor>;
|
|
37
38
|
handler?: ISseEventHandler;
|
|
38
39
|
useHeaders?: boolean;
|
|
39
40
|
headers: Record<string, string>;
|
|
@@ -46,8 +47,7 @@ export default class SSEClient implements ISSEClient {
|
|
|
46
47
|
* @param getEventSource Function to get the EventSource constructor.
|
|
47
48
|
* @throws 'EventSource API is not available. ' if EventSource is not available.
|
|
48
49
|
*/
|
|
49
|
-
constructor(settings: ISettings, useHeaders?: boolean, getEventSource?: () => (
|
|
50
|
-
// @ts-expect-error
|
|
50
|
+
constructor(settings: ISettings, useHeaders?: boolean, getEventSource?: () => (IEventSourceConstructor | undefined)) {
|
|
51
51
|
this.eventSource = getEventSource && getEventSource();
|
|
52
52
|
// if eventSource is not available, throw an exception
|
|
53
53
|
if (!this.eventSource) throw new Error('EventSource API is not available. ');
|
|
@@ -79,7 +79,7 @@ export default class SSEClient implements ISSEClient {
|
|
|
79
79
|
).join(',');
|
|
80
80
|
const url = `${this.streamingUrl}?channels=${channelsQueryParam}&accessToken=${authToken.token}&v=${VERSION}&heartbeats=true`; // same results using `&heartbeats=false`
|
|
81
81
|
|
|
82
|
-
this.connection = new this.eventSource(
|
|
82
|
+
this.connection = new this.eventSource!(
|
|
83
83
|
// For client-side SDKs, SplitSDKClientKey and SplitSDKClientKey metadata is passed as query params,
|
|
84
84
|
// because native EventSource implementations for browser doesn't support headers.
|
|
85
85
|
this.useHeaders ? url : url + `&SplitSDKVersion=${this.headers.SplitSDKVersion}&SplitSDKClientKey=${this.headers.SplitSDKClientKey}`,
|
package/src/types.ts
CHANGED
|
@@ -7,15 +7,16 @@ import { IStorageFactoryParams, IStorageSync, IStorageAsync, IStorageSyncFactory
|
|
|
7
7
|
import { ISyncManagerFactoryParams, ISyncManagerCS } from './sync/types';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* EventEmitter interface with the minimal methods used by the SDK
|
|
10
|
+
* Reduced version of NodeJS.EventEmitter interface with the minimal methods used by the SDK
|
|
11
|
+
* @see {@link https://nodejs.org/api/events.html}
|
|
11
12
|
*/
|
|
12
|
-
export interface IEventEmitter
|
|
13
|
-
addListener(event: string, listener: (...args: any[]) => void):
|
|
14
|
-
on(event: string, listener: (...args: any[]) => void):
|
|
15
|
-
once(event: string, listener: (...args: any[]) => void):
|
|
16
|
-
removeListener(event: string, listener: (...args: any[]) => void):
|
|
17
|
-
off(event: string, listener: (...args: any[]) => void):
|
|
18
|
-
removeAllListeners(event?: string):
|
|
13
|
+
export interface IEventEmitter {
|
|
14
|
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
15
|
+
on(event: string, listener: (...args: any[]) => void): this
|
|
16
|
+
once(event: string, listener: (...args: any[]) => void): this
|
|
17
|
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
|
18
|
+
off(event: string, listener: (...args: any[]) => void): this;
|
|
19
|
+
removeAllListeners(event?: string): this
|
|
19
20
|
emit(event: string, ...args: any[]): boolean
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -18,7 +18,7 @@ export default class EventEmitter implements IEventEmitter {
|
|
|
18
18
|
boolean // whether it is a one-time listener or not
|
|
19
19
|
]>> = {};
|
|
20
20
|
|
|
21
|
-
private registerListener(type: string, listener: (...args: any[]) => void, oneTime: boolean)
|
|
21
|
+
private registerListener(type: string, listener: (...args: any[]) => void, oneTime: boolean) {
|
|
22
22
|
checkListener(listener);
|
|
23
23
|
|
|
24
24
|
// To avoid recursion in the case that type === "newListener" before
|
|
@@ -33,27 +33,27 @@ export default class EventEmitter implements IEventEmitter {
|
|
|
33
33
|
return this;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
addListener(type: string, listener: (...args: any[]) => void)
|
|
36
|
+
addListener(type: string, listener: (...args: any[]) => void) {
|
|
37
37
|
return this.registerListener(type, listener, false);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
// alias of addListener
|
|
41
|
-
on(type: string, listener: (...args: any[]) => void)
|
|
41
|
+
on(type: string, listener: (...args: any[]) => void) {
|
|
42
42
|
return this.addListener(type, listener);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
once(type: string, listener: (...args: any[]) => void)
|
|
45
|
+
once(type: string, listener: (...args: any[]) => void) {
|
|
46
46
|
return this.registerListener(type, listener, true);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
//
|
|
50
|
-
removeListener(type: string, listener: (...args: any[]) => void)
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
removeListener(/* type: string, listener: (...args: any[]) => void */) {
|
|
51
51
|
throw new Error('Method not implemented.');
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
// alias of removeListener
|
|
55
|
-
off(type: string, listener: (...args: any[]) => void)
|
|
56
|
-
return this.removeListener(type, listener);
|
|
54
|
+
// @ts-ignore alias of removeListener
|
|
55
|
+
off(/* type: string, listener: (...args: any[]) => void */) {
|
|
56
|
+
return this.removeListener(/* type, listener */);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
emit(type: string, ...args: any[]): boolean {
|
|
@@ -68,7 +68,7 @@ export default class EventEmitter implements IEventEmitter {
|
|
|
68
68
|
return true;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
removeAllListeners(type?: string)
|
|
71
|
+
removeAllListeners(type?: string) {
|
|
72
72
|
if (!this.listeners[REMOVE_LISTENER_EVENT]) {
|
|
73
73
|
// if not listening for `removeListener`, no need to emit
|
|
74
74
|
if (type) {
|
package/src/utils/env/isNode.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 'true' if running in Node.js, or 'false' otherwise.
|
|
3
|
+
* We check for version truthiness since most shims will have that as empty string.
|
|
4
|
+
*/
|
|
2
5
|
// eslint-disable-next-line no-undef
|
|
3
6
|
export const isNode: boolean = typeof process !== 'undefined' && typeof process.version !== 'undefined' && !!process.version ? true : false;
|
|
@@ -3,7 +3,7 @@ import { ISignalListener } from '../listeners/types';
|
|
|
3
3
|
import { ILogger } from '../logger/types';
|
|
4
4
|
import { ISdkReadinessManager } from '../readiness/types';
|
|
5
5
|
import { ISdkClientFactoryParams } from '../sdkClient/types';
|
|
6
|
-
import { IFetch, ISplitApi } from '../services/types';
|
|
6
|
+
import { IFetch, ISplitApi, IEventSourceConstructor } from '../services/types';
|
|
7
7
|
import { IStorageAsync, IStorageSync, ISplitsCacheSync, ISplitsCacheAsync, IStorageFactoryParams } from '../storages/types';
|
|
8
8
|
import { ISyncManager, ISyncManagerFactoryParams } from '../sync/types';
|
|
9
9
|
import { IImpressionObserver } from '../trackers/impressionObserver/types';
|
|
@@ -15,7 +15,7 @@ import { SplitIO, ISettings, IEventEmitter } from '../types';
|
|
|
15
15
|
export interface IPlatform {
|
|
16
16
|
getOptions?: () => object;
|
|
17
17
|
getFetch?: () => (IFetch | undefined);
|
|
18
|
-
getEventSource?: () => (
|
|
18
|
+
getEventSource?: () => (IEventSourceConstructor | undefined);
|
|
19
19
|
EventEmitter: new () => IEventEmitter;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
@@ -34,3 +34,16 @@ export interface ISplitApi {
|
|
|
34
34
|
postMetricsCounters: IPostMetricsCounters;
|
|
35
35
|
postMetricsTimes: IPostMetricsTimes;
|
|
36
36
|
}
|
|
37
|
+
interface EventSourceEventMap {
|
|
38
|
+
'error': Event;
|
|
39
|
+
'message': MessageEvent;
|
|
40
|
+
'open': Event;
|
|
41
|
+
}
|
|
42
|
+
interface IEventSource {
|
|
43
|
+
addEventListener<K extends keyof EventSourceEventMap>(type: K, listener: (this: IEventSource, ev: EventSourceEventMap[K]) => any): void;
|
|
44
|
+
close(): void;
|
|
45
|
+
}
|
|
46
|
+
export declare type IEventSourceConstructor = new (url: string, eventSourceInitDict?: {
|
|
47
|
+
headers?: object;
|
|
48
|
+
}) => IEventSource;
|
|
49
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LOG_PREFIX = "storage:pluggable:";
|
|
1
|
+
export declare const LOG_PREFIX = "storage:pluggable: ";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IEventSourceConstructor } from '../../../services/types';
|
|
1
2
|
import { ISettings } from '../../../types';
|
|
2
3
|
import { IAuthTokenPushEnabled } from '../AuthClient/types';
|
|
3
4
|
import { ISSEClient, ISseEventHandler } from './types';
|
|
@@ -5,9 +6,9 @@ import { ISSEClient, ISseEventHandler } from './types';
|
|
|
5
6
|
* Handles streaming connections with EventSource API
|
|
6
7
|
*/
|
|
7
8
|
export default class SSEClient implements ISSEClient {
|
|
8
|
-
eventSource
|
|
9
|
+
eventSource?: IEventSourceConstructor;
|
|
9
10
|
streamingUrl: string;
|
|
10
|
-
connection?: InstanceType<
|
|
11
|
+
connection?: InstanceType<IEventSourceConstructor>;
|
|
11
12
|
handler?: ISseEventHandler;
|
|
12
13
|
useHeaders?: boolean;
|
|
13
14
|
headers: Record<string, string>;
|
|
@@ -19,7 +20,7 @@ export default class SSEClient implements ISSEClient {
|
|
|
19
20
|
* @param getEventSource Function to get the EventSource constructor.
|
|
20
21
|
* @throws 'EventSource API is not available. ' if EventSource is not available.
|
|
21
22
|
*/
|
|
22
|
-
constructor(settings: ISettings, useHeaders?: boolean, getEventSource?: () => (
|
|
23
|
+
constructor(settings: ISettings, useHeaders?: boolean, getEventSource?: () => (IEventSourceConstructor | undefined));
|
|
23
24
|
setEventHandler(handler: ISseEventHandler): void;
|
|
24
25
|
/**
|
|
25
26
|
* Open the connection with a given authToken
|
package/types/types.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { ISplitFiltersValidation } from './dtos/types';
|
|
3
2
|
import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
|
|
4
3
|
import { ILogger } from './logger/types';
|
|
5
4
|
import { IStorageFactoryParams, IStorageSync, IStorageAsync, IStorageSyncFactory, IStorageAsyncFactory } from './storages/types';
|
|
6
5
|
import { ISyncManagerFactoryParams, ISyncManagerCS } from './sync/types';
|
|
7
6
|
/**
|
|
8
|
-
* EventEmitter interface with the minimal methods used by the SDK
|
|
7
|
+
* Reduced version of NodeJS.EventEmitter interface with the minimal methods used by the SDK
|
|
8
|
+
* @see {@link https://nodejs.org/api/events.html}
|
|
9
9
|
*/
|
|
10
|
-
export interface IEventEmitter
|
|
11
|
-
addListener(event: string, listener: (...args: any[]) => void):
|
|
12
|
-
on(event: string, listener: (...args: any[]) => void):
|
|
13
|
-
once(event: string, listener: (...args: any[]) => void):
|
|
14
|
-
removeListener(event: string, listener: (...args: any[]) => void):
|
|
15
|
-
off(event: string, listener: (...args: any[]) => void):
|
|
16
|
-
removeAllListeners(event?: string):
|
|
10
|
+
export interface IEventEmitter {
|
|
11
|
+
addListener(event: string, listener: (...args: any[]) => void): this;
|
|
12
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
13
|
+
once(event: string, listener: (...args: any[]) => void): this;
|
|
14
|
+
removeListener(event: string, listener: (...args: any[]) => void): this;
|
|
15
|
+
off(event: string, listener: (...args: any[]) => void): this;
|
|
16
|
+
removeAllListeners(event?: string): this;
|
|
17
17
|
emit(event: string, ...args: any[]): boolean;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
@@ -2,11 +2,11 @@ import { IEventEmitter } from '../types';
|
|
|
2
2
|
export default class EventEmitter implements IEventEmitter {
|
|
3
3
|
private listeners;
|
|
4
4
|
private registerListener;
|
|
5
|
-
addListener(type: string, listener: (...args: any[]) => void):
|
|
6
|
-
on(type: string, listener: (...args: any[]) => void):
|
|
7
|
-
once(type: string, listener: (...args: any[]) => void):
|
|
8
|
-
removeListener(
|
|
9
|
-
off(
|
|
5
|
+
addListener(type: string, listener: (...args: any[]) => void): this;
|
|
6
|
+
on(type: string, listener: (...args: any[]) => void): this;
|
|
7
|
+
once(type: string, listener: (...args: any[]) => void): this;
|
|
8
|
+
removeListener(): void;
|
|
9
|
+
off(): void;
|
|
10
10
|
emit(type: string, ...args: any[]): boolean;
|
|
11
|
-
removeAllListeners(type?: string):
|
|
11
|
+
removeAllListeners(type?: string): this;
|
|
12
12
|
}
|