Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit 8ad21a1

Browse files
author
Steffan
committed
v2.0.1
1 parent a0ec018 commit 8ad21a1

File tree

6 files changed

+228
-219
lines changed

6 files changed

+228
-219
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The plugin for [Vue.js](http://vuejs.org) provides a declarative way to bind eve
66

77
- Supports event priorities and [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) based asynchronous events
88
- Supports latest Firefox, Chrome, Safari, Opera and IE9+
9-
- Supports Vue 2.0 & Vue 1.0
9+
- Supports Vue 2.0
1010
- Compact size 2KB
1111

1212
## Installation
@@ -17,9 +17,9 @@ $ npm install vue-event-manager
1717
```
1818

1919
### CDN
20-
Available on [jsdelivr](https://cdn.jsdelivr.net/npm/[email protected].0) or [unpkg](https://unpkg.com/[email protected].0).
20+
Available on [jsdelivr](https://cdn.jsdelivr.net/npm/[email protected].1) or [unpkg](https://unpkg.com/[email protected].1).
2121
```html
22-
<script src="https://cdn.jsdelivr.net/npm/[email protected].0"></script>
22+
<script src="https://cdn.jsdelivr.net/npm/[email protected].1"></script>
2323
```
2424

2525
## Example

dist/vue-event-manager.common.js

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-event-manager v2.0.0
2+
* vue-event-manager v2.0.1
33
* https://github.com/pagekit/vue-event-manager
44
* Released under the MIT License.
55
*/
@@ -26,45 +26,48 @@ function forEach(collection, callback) {
2626
});
2727
}
2828

29-
/**
30-
* Array.findIndex() polyfill.
31-
*/
32-
if (!Array.prototype.findIndex) {
29+
function array(array) {
30+
if ( array === void 0 ) array = [];
3331

34-
// eslint-disable-next-line
35-
Object.defineProperty(Array.prototype, 'findIndex', {
3632

37-
value: function value(predicate) {
33+
if (!array.findIndex) {
34+
array.findIndex = findIndex;
35+
}
3836

39-
if (this == null) {
40-
throw new TypeError('"this" is null or not defined');
41-
}
37+
return array;
38+
}
4239

43-
if (typeof predicate !== 'function') {
44-
throw new TypeError('predicate must be a function');
45-
}
40+
/**
41+
* Array.findIndex() polyfill.
42+
*/
43+
function findIndex(predicate) {
4644

47-
var o = Object(this);
48-
var len = o.length >>> 0;
49-
var thisArg = arguments[1];
45+
if (this == null) {
46+
throw new TypeError('"this" is null or not defined');
47+
}
5048

51-
var k = 0;
49+
if (typeof predicate !== 'function') {
50+
throw new TypeError('predicate must be a function');
51+
}
5252

53-
while (k < len) {
53+
var o = Object(this);
54+
var len = o.length >>> 0;
55+
var thisArg = arguments[1];
5456

55-
var kValue = o[k];
57+
var k = 0;
5658

57-
if (predicate.call(thisArg, kValue, k, o)) {
58-
return k;
59-
}
59+
while (k < len) {
6060

61-
k++;
62-
}
61+
var kValue = o[k];
6362

64-
return -1;
63+
if (predicate.call(thisArg, kValue, k, o)) {
64+
return k;
6565
}
6666

67-
});
67+
k++;
68+
}
69+
70+
return -1;
6871
}
6972

7073
/**
@@ -80,7 +83,7 @@ EventManager.prototype.on = function on (event, callback, priority) {
8083
if ( priority === void 0 ) priority = 0;
8184

8285

83-
var listeners = this.listeners[event] || [];
86+
var listeners = array(this.listeners[event]);
8487
var index = listeners.findIndex(function (listener) { return listener.priority < priority; });
8588

8689
if (~index) {

dist/vue-event-manager.esm.js

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-event-manager v2.0.0
2+
* vue-event-manager v2.0.1
33
* https://github.com/pagekit/vue-event-manager
44
* Released under the MIT License.
55
*/
@@ -24,45 +24,48 @@ function forEach(collection, callback) {
2424
});
2525
}
2626

27-
/**
28-
* Array.findIndex() polyfill.
29-
*/
30-
if (!Array.prototype.findIndex) {
27+
function array(array) {
28+
if ( array === void 0 ) array = [];
3129

32-
// eslint-disable-next-line
33-
Object.defineProperty(Array.prototype, 'findIndex', {
3430

35-
value: function value(predicate) {
31+
if (!array.findIndex) {
32+
array.findIndex = findIndex;
33+
}
3634

37-
if (this == null) {
38-
throw new TypeError('"this" is null or not defined');
39-
}
35+
return array;
36+
}
4037

41-
if (typeof predicate !== 'function') {
42-
throw new TypeError('predicate must be a function');
43-
}
38+
/**
39+
* Array.findIndex() polyfill.
40+
*/
41+
function findIndex(predicate) {
4442

45-
var o = Object(this);
46-
var len = o.length >>> 0;
47-
var thisArg = arguments[1];
43+
if (this == null) {
44+
throw new TypeError('"this" is null or not defined');
45+
}
4846

49-
var k = 0;
47+
if (typeof predicate !== 'function') {
48+
throw new TypeError('predicate must be a function');
49+
}
5050

51-
while (k < len) {
51+
var o = Object(this);
52+
var len = o.length >>> 0;
53+
var thisArg = arguments[1];
5254

53-
var kValue = o[k];
55+
var k = 0;
5456

55-
if (predicate.call(thisArg, kValue, k, o)) {
56-
return k;
57-
}
57+
while (k < len) {
5858

59-
k++;
60-
}
59+
var kValue = o[k];
6160

62-
return -1;
61+
if (predicate.call(thisArg, kValue, k, o)) {
62+
return k;
6363
}
6464

65-
});
65+
k++;
66+
}
67+
68+
return -1;
6669
}
6770

6871
/**
@@ -78,7 +81,7 @@ EventManager.prototype.on = function on (event, callback, priority) {
7881
if ( priority === void 0 ) priority = 0;
7982

8083

81-
var listeners = this.listeners[event] || [];
84+
var listeners = array(this.listeners[event]);
8285
var index = listeners.findIndex(function (listener) { return listener.priority < priority; });
8386

8487
if (~index) {

0 commit comments

Comments
 (0)