vis-util 5.0.6 → 5.0.7
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/declarations/deep-object-assign.d.ts +1 -1
- package/declarations/deep-object-assign.d.ts.map +1 -1
- package/declarations/random/alea.d.ts +1 -1
- package/declarations/random/alea.d.ts.map +1 -1
- package/declarations/shared/configurator-types.d.ts +9 -9
- package/declarations/shared/configurator-types.d.ts.map +1 -1
- package/esnext/esm/vis-util.js +2 -2
- package/esnext/esm/vis-util.min.js +2 -2
- package/esnext/umd/vis-util.js +2 -2
- package/esnext/umd/vis-util.min.js +2 -2
- package/package.json +13 -13
- package/peer/esm/vis-util.js +108 -175
- package/peer/esm/vis-util.js.map +1 -1
- package/peer/esm/vis-util.min.js +4 -4
- package/peer/esm/vis-util.min.js.map +1 -1
- package/peer/umd/vis-util.js +108 -175
- package/peer/umd/vis-util.js.map +1 -1
- package/peer/umd/vis-util.min.js +4 -4
- package/peer/umd/vis-util.min.js.map +1 -1
- package/standalone/esm/vis-util.js +108 -175
- package/standalone/esm/vis-util.js.map +1 -1
- package/standalone/esm/vis-util.min.js +4 -4
- package/standalone/esm/vis-util.min.js.map +1 -1
- package/standalone/umd/vis-util.js +108 -175
- package/standalone/umd/vis-util.js.map +1 -1
- package/standalone/umd/vis-util.min.js +4 -4
- package/standalone/umd/vis-util.min.js.map +1 -1
|
@@ -6,7 +6,7 @@ export declare const DELETE: unique symbol;
|
|
|
6
6
|
* Turns `undefined` into `undefined | typeof DELETE` and makes everything
|
|
7
7
|
* partial. Intended to be used with `deepObjectAssign`.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type Assignable<T> = T extends undefined ? (T extends Function ? T : T extends object ? {
|
|
10
10
|
[Key in keyof T]?: Assignable<T[Key]> | undefined;
|
|
11
11
|
} : T) | typeof DELETE : T extends Function ? T | undefined : T extends object ? {
|
|
12
12
|
[Key in keyof T]?: Assignable<T[Key]> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-object-assign.d.ts","sourceRoot":"","sources":["../src/deep-object-assign.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,MAAM,eAAmB,CAAC;AAEvC;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"deep-object-assign.d.ts","sourceRoot":"","sources":["../src/deep-object-assign.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,MAAM,eAAmB,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAEvC,CAAC,CAAC,SAAS,QAAQ,GACf,CAAC,GACD,CAAC,SAAS,MAAM,GAChB;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS;CAAE,GACrD,CAAC,CAAC,GACN,OAAO,MAAM,GACjB,CAAC,SAAS,QAAQ,GAClB,CAAC,GAAG,SAAS,GACb,CAAC,SAAS,MAAM,GAChB;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS;CAAE,GACrD,CAAC,GAAG,SAAS,CAAC;AAElB;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,IAAI,EAAE,CAAC,EACP,GAAG,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAC1B,CAAC,CAEH;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -34,5 +34,5 @@ export declare function Alea(...seed: Mashable[]): RNG;
|
|
|
34
34
|
/**
|
|
35
35
|
* Values of these types can be used as a seed.
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export type Mashable = number | string | boolean | object | bigint;
|
|
38
38
|
//# sourceMappingURL=alea.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alea.d.ts","sourceRoot":"","sources":["../../src/random/alea.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,gDAAgD;IAChD,IAAI,MAAM,CAAC;IACX,mDAAmD;IACnD,OAAO,IAAI,MAAM,CAAC;IAClB,0BAA0B;IAC1B,MAAM,IAAI,MAAM,CAAC;IAEjB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,GAAG,CAE7C;AA+DD;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"alea.d.ts","sourceRoot":"","sources":["../../src/random/alea.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,gDAAgD;IAChD,IAAI,MAAM,CAAC;IACX,mDAAmD;IACnD,OAAO,IAAI,MAAM,CAAC;IAClB,0BAA0B;IAC1B,MAAM,IAAI,MAAM,CAAC;IAEjB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,GAAG,CAE7C;AA+DD;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC"}
|
|
@@ -9,7 +9,7 @@ interface OptionsType {
|
|
|
9
9
|
readonly string?: "string" | readonly string[];
|
|
10
10
|
readonly undefined?: "undefined";
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export type OptionsConfig = {
|
|
13
13
|
readonly __type__: {
|
|
14
14
|
readonly object: "object";
|
|
15
15
|
} & OptionsType;
|
|
@@ -19,12 +19,12 @@ export declare type OptionsConfig = {
|
|
|
19
19
|
/**
|
|
20
20
|
* The value supplied will be used as the initial value.
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
type CheckboxInput = boolean;
|
|
23
23
|
/**
|
|
24
24
|
* The passed text will be used as the initial value. Any text will be accepted
|
|
25
25
|
* afterwards.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
type TextInput = string;
|
|
28
28
|
/**
|
|
29
29
|
* The passed values will be used as the limits and the initial position of a
|
|
30
30
|
* slider.
|
|
@@ -39,13 +39,13 @@ declare type TextInput = string;
|
|
|
39
39
|
* ]
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
type NumberInput = readonly [number, number, number, number];
|
|
43
43
|
/**
|
|
44
44
|
* Translations for people with poor understanding of TypeScript: the first
|
|
45
45
|
* value always has to be a string but never `"color"`, the rest can be any
|
|
46
46
|
* combination of strings, numbers and booleans.
|
|
47
47
|
*/
|
|
48
|
-
|
|
48
|
+
type DropdownInput = readonly [
|
|
49
49
|
Exclude<string, "color">,
|
|
50
50
|
...(string | number | boolean)[]
|
|
51
51
|
];
|
|
@@ -53,11 +53,11 @@ declare type DropdownInput = readonly [
|
|
|
53
53
|
* The first value says this will be a color picker not a dropdown menu. The
|
|
54
54
|
* next value is the initial color.
|
|
55
55
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export
|
|
56
|
+
type ColorInput = readonly ["coor", string];
|
|
57
|
+
type ConfiguratorInput = CheckboxInput | ColorInput | DropdownInput | NumberInput | TextInput;
|
|
58
|
+
export type ConfiguratorConfig = {
|
|
59
59
|
readonly [Key in string]: ConfiguratorConfig | ConfiguratorInput;
|
|
60
60
|
};
|
|
61
|
-
export
|
|
61
|
+
export type ConfiguratorHideOption = (parentPath: readonly string[], optionName: string, options: any) => boolean;
|
|
62
62
|
export {};
|
|
63
63
|
//# sourceMappingURL=configurator-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurator-types.d.ts","sourceRoot":"","sources":["../../src/shared/configurator-types.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,MAAM,EAAE,CAAC;IAC/C,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC;CAClC;AACD,
|
|
1
|
+
{"version":3,"file":"configurator-types.d.ts","sourceRoot":"","sources":["../../src/shared/configurator-types.ts"],"names":[],"mappings":"AAAA,UAAU,WAAW;IACnB,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,GAAG,SAAS,MAAM,EAAE,CAAC;IAC/C,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC;CAClC;AACD,MAAM,MAAM,aAAa,GAAG;IAE1B,QAAQ,CAAC,QAAQ,EAAE;QACjB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;KAC3B,GAAG,WAAW,CAAC;CACjB,GAAG;IACF,QAAQ,EAAE,GAAG,IAAI,MAAM,GAAG,aAAa,GAAG,WAAW;CACtD,CAAC;AAEF;;GAEG;AACH,KAAK,aAAa,GAAG,OAAO,CAAC;AAC7B;;;GAGG;AACH,KAAK,SAAS,GAAG,MAAM,CAAC;AACxB;;;;;;;;;;;;;GAaG;AACH,KAAK,WAAW,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC7D;;;;GAIG;AACH,KAAK,aAAa,GAAG,SAAS;IAC5B,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;IACxB,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,EAAE;CACjC,CAAC;AACF;;;GAGG;AACH,KAAK,UAAU,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5C,KAAK,iBAAiB,GAClB,aAAa,GACb,UAAU,GACV,aAAa,GACb,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,GAAG,IAAI,MAAM,GAAG,kBAAkB,GAAG,iBAAiB;CACjE,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,CACnC,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,GAAG,KACT,OAAO,CAAC"}
|
package/esnext/esm/vis-util.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* utilitie collection for visjs
|
|
6
6
|
*
|
|
7
|
-
* @version 5.0.
|
|
8
|
-
* @date 2023-11-
|
|
7
|
+
* @version 5.0.7
|
|
8
|
+
* @date 2023-11-20T09:06:51.067Z
|
|
9
9
|
*
|
|
10
10
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
|
11
11
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* utilitie collection for visjs
|
|
6
6
|
*
|
|
7
|
-
* @version 5.0.
|
|
8
|
-
* @date 2023-11-
|
|
7
|
+
* @version 5.0.7
|
|
8
|
+
* @date 2023-11-20T09:06:51.067Z
|
|
9
9
|
*
|
|
10
10
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
|
11
11
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
package/esnext/umd/vis-util.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* utilitie collection for visjs
|
|
6
6
|
*
|
|
7
|
-
* @version 5.0.
|
|
8
|
-
* @date 2023-11-
|
|
7
|
+
* @version 5.0.7
|
|
8
|
+
* @date 2023-11-20T09:06:51.067Z
|
|
9
9
|
*
|
|
10
10
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
|
11
11
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* utilitie collection for visjs
|
|
6
6
|
*
|
|
7
|
-
* @version 5.0.
|
|
8
|
-
* @date 2023-11-
|
|
7
|
+
* @version 5.0.7
|
|
8
|
+
* @date 2023-11-20T09:06:51.067Z
|
|
9
9
|
*
|
|
10
10
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
|
11
11
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vis-util",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.7",
|
|
4
4
|
"description": "utilitie collection for visjs",
|
|
5
5
|
"browser": "peer/umd/vis-util.min.js",
|
|
6
6
|
"jsnext": "esnext/esm/vis-util.js",
|
|
@@ -93,34 +93,34 @@
|
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
95
|
"@egjs/hammerjs": "^2.0.0",
|
|
96
|
-
"component-emitter": "^1.3.0"
|
|
96
|
+
"component-emitter": "^1.3.0 || ^2.0.0"
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
99
|
"@egjs/hammerjs": "2.0.17",
|
|
100
|
-
"@types/chai": "4.3.
|
|
100
|
+
"@types/chai": "4.3.10",
|
|
101
101
|
"@types/jsdom-global": "^3.0.4",
|
|
102
|
-
"@types/mocha": "10.0.
|
|
103
|
-
"@types/node": "20.
|
|
104
|
-
"@types/sinon": "
|
|
102
|
+
"@types/mocha": "10.0.4",
|
|
103
|
+
"@types/node": "20.9.2",
|
|
104
|
+
"@types/sinon": "17.0.1",
|
|
105
105
|
"assert": "2.1.0",
|
|
106
106
|
"check-dts": "0.7.2",
|
|
107
|
-
"component-emitter": "
|
|
107
|
+
"component-emitter": "2.0.0",
|
|
108
108
|
"cross-env": "^7.0.3",
|
|
109
|
-
"eslint": "8.
|
|
109
|
+
"eslint": "8.54.0",
|
|
110
110
|
"git-authors-cli": "1.0.47",
|
|
111
111
|
"husky": "8.0.3",
|
|
112
112
|
"jsdom": "22.1.0",
|
|
113
113
|
"jsdom-global": "3.0.2",
|
|
114
|
-
"lint-staged": "15.0
|
|
114
|
+
"lint-staged": "15.1.0",
|
|
115
115
|
"mocha": "10.2.0",
|
|
116
116
|
"npm-run-all": "4.1.5",
|
|
117
117
|
"nyc": "15.1.0",
|
|
118
118
|
"rimraf": "5.0.5",
|
|
119
119
|
"sazerac": "2.0.0",
|
|
120
|
-
"semantic-release": "22.0.
|
|
121
|
-
"sinon": "17.0.
|
|
120
|
+
"semantic-release": "22.0.8",
|
|
121
|
+
"sinon": "17.0.1",
|
|
122
122
|
"snap-shot-it": "7.9.10",
|
|
123
|
-
"typedoc": "0.25.
|
|
124
|
-
"vis-dev-utils": "4.0.
|
|
123
|
+
"typedoc": "0.25.3",
|
|
124
|
+
"vis-dev-utils": "4.0.45"
|
|
125
125
|
}
|
|
126
126
|
}
|
package/peer/esm/vis-util.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* utilitie collection for visjs
|
|
6
6
|
*
|
|
7
|
-
* @version 5.0.
|
|
8
|
-
* @date 2023-11-
|
|
7
|
+
* @version 5.0.7
|
|
8
|
+
* @date 2023-11-20T09:06:51.067Z
|
|
9
9
|
*
|
|
10
10
|
* @copyright (c) 2011-2017 Almende B.V, http://almende.com
|
|
11
11
|
* @copyright (c) 2017-2019 visjs contributors, https://github.com/visjs
|
|
@@ -3837,179 +3837,112 @@ var _spliceInstanceProperty = /*@__PURE__*/getDefaultExportFromCjs(splice);
|
|
|
3837
3837
|
var componentEmitter = {exports: {}};
|
|
3838
3838
|
|
|
3839
3839
|
(function (module) {
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
}
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
function
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
}
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
Emitter.prototype.
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
if (cb === fn || cb.fn === fn) {
|
|
3947
|
-
callbacks.splice(i, 1);
|
|
3948
|
-
break;
|
|
3949
|
-
}
|
|
3950
|
-
}
|
|
3951
|
-
|
|
3952
|
-
// Remove event specific arrays for event types that no
|
|
3953
|
-
// one is subscribed for to avoid memory leak.
|
|
3954
|
-
if (callbacks.length === 0) {
|
|
3955
|
-
delete this._callbacks['$' + event];
|
|
3956
|
-
}
|
|
3957
|
-
|
|
3958
|
-
return this;
|
|
3959
|
-
};
|
|
3960
|
-
|
|
3961
|
-
/**
|
|
3962
|
-
* Emit `event` with the given args.
|
|
3963
|
-
*
|
|
3964
|
-
* @param {String} event
|
|
3965
|
-
* @param {Mixed} ...
|
|
3966
|
-
* @return {Emitter}
|
|
3967
|
-
*/
|
|
3968
|
-
|
|
3969
|
-
Emitter.prototype.emit = function(event){
|
|
3970
|
-
this._callbacks = this._callbacks || {};
|
|
3971
|
-
|
|
3972
|
-
var args = new Array(arguments.length - 1)
|
|
3973
|
-
, callbacks = this._callbacks['$' + event];
|
|
3974
|
-
|
|
3975
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
3976
|
-
args[i - 1] = arguments[i];
|
|
3977
|
-
}
|
|
3978
|
-
|
|
3979
|
-
if (callbacks) {
|
|
3980
|
-
callbacks = callbacks.slice(0);
|
|
3981
|
-
for (var i = 0, len = callbacks.length; i < len; ++i) {
|
|
3982
|
-
callbacks[i].apply(this, args);
|
|
3983
|
-
}
|
|
3984
|
-
}
|
|
3985
|
-
|
|
3986
|
-
return this;
|
|
3987
|
-
};
|
|
3988
|
-
|
|
3989
|
-
/**
|
|
3990
|
-
* Return array of callbacks for `event`.
|
|
3991
|
-
*
|
|
3992
|
-
* @param {String} event
|
|
3993
|
-
* @return {Array}
|
|
3994
|
-
* @api public
|
|
3995
|
-
*/
|
|
3996
|
-
|
|
3997
|
-
Emitter.prototype.listeners = function(event){
|
|
3998
|
-
this._callbacks = this._callbacks || {};
|
|
3999
|
-
return this._callbacks['$' + event] || [];
|
|
4000
|
-
};
|
|
4001
|
-
|
|
4002
|
-
/**
|
|
4003
|
-
* Check if this emitter has `event` handlers.
|
|
4004
|
-
*
|
|
4005
|
-
* @param {String} event
|
|
4006
|
-
* @return {Boolean}
|
|
4007
|
-
* @api public
|
|
4008
|
-
*/
|
|
4009
|
-
|
|
4010
|
-
Emitter.prototype.hasListeners = function(event){
|
|
4011
|
-
return !! this.listeners(event).length;
|
|
4012
|
-
};
|
|
3840
|
+
function Emitter(object) {
|
|
3841
|
+
if (object) {
|
|
3842
|
+
return mixin(object);
|
|
3843
|
+
}
|
|
3844
|
+
|
|
3845
|
+
this._callbacks = new Map();
|
|
3846
|
+
}
|
|
3847
|
+
|
|
3848
|
+
function mixin(object) {
|
|
3849
|
+
Object.assign(object, Emitter.prototype);
|
|
3850
|
+
object._callbacks = new Map();
|
|
3851
|
+
return object;
|
|
3852
|
+
}
|
|
3853
|
+
|
|
3854
|
+
Emitter.prototype.on = function (event, listener) {
|
|
3855
|
+
const callbacks = this._callbacks.get(event) ?? [];
|
|
3856
|
+
callbacks.push(listener);
|
|
3857
|
+
this._callbacks.set(event, callbacks);
|
|
3858
|
+
return this;
|
|
3859
|
+
};
|
|
3860
|
+
|
|
3861
|
+
Emitter.prototype.once = function (event, listener) {
|
|
3862
|
+
const on = (...arguments_) => {
|
|
3863
|
+
this.off(event, on);
|
|
3864
|
+
listener.apply(this, arguments_);
|
|
3865
|
+
};
|
|
3866
|
+
|
|
3867
|
+
on.fn = listener;
|
|
3868
|
+
this.on(event, on);
|
|
3869
|
+
return this;
|
|
3870
|
+
};
|
|
3871
|
+
|
|
3872
|
+
Emitter.prototype.off = function (event, listener) {
|
|
3873
|
+
if (event === undefined && listener === undefined) {
|
|
3874
|
+
this._callbacks.clear();
|
|
3875
|
+
return this;
|
|
3876
|
+
}
|
|
3877
|
+
|
|
3878
|
+
if (listener === undefined) {
|
|
3879
|
+
this._callbacks.delete(event);
|
|
3880
|
+
return this;
|
|
3881
|
+
}
|
|
3882
|
+
|
|
3883
|
+
const callbacks = this._callbacks.get(event);
|
|
3884
|
+
if (callbacks) {
|
|
3885
|
+
for (const [index, callback] of callbacks.entries()) {
|
|
3886
|
+
if (callback === listener || callback.fn === listener) {
|
|
3887
|
+
callbacks.splice(index, 1);
|
|
3888
|
+
break;
|
|
3889
|
+
}
|
|
3890
|
+
}
|
|
3891
|
+
|
|
3892
|
+
if (callbacks.length === 0) {
|
|
3893
|
+
this._callbacks.delete(event);
|
|
3894
|
+
} else {
|
|
3895
|
+
this._callbacks.set(event, callbacks);
|
|
3896
|
+
}
|
|
3897
|
+
}
|
|
3898
|
+
|
|
3899
|
+
return this;
|
|
3900
|
+
};
|
|
3901
|
+
|
|
3902
|
+
Emitter.prototype.emit = function (event, ...arguments_) {
|
|
3903
|
+
const callbacks = this._callbacks.get(event);
|
|
3904
|
+
if (callbacks) {
|
|
3905
|
+
// Create a copy of the callbacks array to avoid issues if it's modified during iteration
|
|
3906
|
+
const callbacksCopy = [...callbacks];
|
|
3907
|
+
|
|
3908
|
+
for (const callback of callbacksCopy) {
|
|
3909
|
+
callback.apply(this, arguments_);
|
|
3910
|
+
}
|
|
3911
|
+
}
|
|
3912
|
+
|
|
3913
|
+
return this;
|
|
3914
|
+
};
|
|
3915
|
+
|
|
3916
|
+
Emitter.prototype.listeners = function (event) {
|
|
3917
|
+
return this._callbacks.get(event) ?? [];
|
|
3918
|
+
};
|
|
3919
|
+
|
|
3920
|
+
Emitter.prototype.listenerCount = function (event) {
|
|
3921
|
+
if (event) {
|
|
3922
|
+
return this.listeners(event).length;
|
|
3923
|
+
}
|
|
3924
|
+
|
|
3925
|
+
let totalCount = 0;
|
|
3926
|
+
for (const callbacks of this._callbacks.values()) {
|
|
3927
|
+
totalCount += callbacks.length;
|
|
3928
|
+
}
|
|
3929
|
+
|
|
3930
|
+
return totalCount;
|
|
3931
|
+
};
|
|
3932
|
+
|
|
3933
|
+
Emitter.prototype.hasListeners = function (event) {
|
|
3934
|
+
return this.listenerCount(event) > 0;
|
|
3935
|
+
};
|
|
3936
|
+
|
|
3937
|
+
// Aliases
|
|
3938
|
+
Emitter.prototype.addEventListener = Emitter.prototype.on;
|
|
3939
|
+
Emitter.prototype.removeListener = Emitter.prototype.off;
|
|
3940
|
+
Emitter.prototype.removeEventListener = Emitter.prototype.off;
|
|
3941
|
+
Emitter.prototype.removeAllListeners = Emitter.prototype.off;
|
|
3942
|
+
|
|
3943
|
+
{
|
|
3944
|
+
module.exports = Emitter;
|
|
3945
|
+
}
|
|
4013
3946
|
} (componentEmitter));
|
|
4014
3947
|
|
|
4015
3948
|
var componentEmitterExports = componentEmitter.exports;
|