first commit
This commit is contained in:
1
app_vue/node_modules/event-pubsub/.npmignore
generated
vendored
Normal file
1
app_vue/node_modules/event-pubsub/.npmignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
examples/
|
24
app_vue/node_modules/event-pubsub/LICENSE
generated
vendored
Normal file
24
app_vue/node_modules/event-pubsub/LICENSE
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org>
|
299
app_vue/node_modules/event-pubsub/README.md
generated
vendored
Normal file
299
app_vue/node_modules/event-pubsub/README.md
generated
vendored
Normal file
@ -0,0 +1,299 @@
|
||||
# Event PubSub
|
||||
|
||||
npm info :
|
||||
  
|
||||
|
||||
GitHub info :
|
||||
  
|
||||
|
||||
***Super light and fast*** Extensible PubSub events and EventEmitters for Node and the browser with support for ES6 by default, and ES5 versions for older verions of node and older IE/Safari versions.
|
||||
|
||||
For older versions of node and io.js the latest versions of `event-pubsub` may work with the --harmony flag. Officially though, we support node v4 and newer with es5 and es6
|
||||
|
||||
Easy for any developer level. No frills, just high speed events following the publisher subscriber pattern!
|
||||
|
||||
[Pretty GitHub.io site](http://riaevangelist.github.io/event-pubsub/)
|
||||
|
||||
[See NPM stats for event-pubsub](http://npm-stat.com/charts.html?package=event-pubsub&author=&from=&to=)
|
||||
|
||||
**EXAMPLE FILES**
|
||||
|
||||
1. [Node Event PubSub Examples](https://github.com/RIAEvangelist/event-pubsub/tree/master/examples/node)
|
||||
2. [Browser Event PubSub Examples](https://github.com/RIAEvangelist/event-pubsub/tree/master/examples/browser)
|
||||
|
||||
**Node Install**
|
||||
`npm i --save event-pubsub`
|
||||
By default the correct version (ES5/ES6) will be included. You can force the es5/6 version by requiring `event-pubsub/es5` or `event-pubsub/es6`.
|
||||
|
||||
**Browser Install**
|
||||
*see browser examples above or below*
|
||||
|
||||
```html
|
||||
|
||||
<script src='path/to/event-pubsub-browser.js'></script>
|
||||
<!-- OR ES5 for older browser support
|
||||
<script src='path/to/event-pubsub-browser-es5.js'></script>
|
||||
-->
|
||||
|
||||
```
|
||||
|
||||
# Methods
|
||||
|
||||
|Method|Arguments|Description|
|
||||
|------|---------|-----------|
|
||||
|subscribe|type (string), handler(function), once (bool/optional)|will bind the `handler` function to the the `type` event. Just like `addEventListener` in the browser. If once is set to true the hander will be removed after being called once.|
|
||||
|on|same as above|same as above|
|
||||
|once|type (string), handler(function)| will bind the `handler` function to the the `type` event and unbind it after ***one*** execution. Just like `addEventListener` in the browser withe the `once` option set|
|
||||
|unSubscribe|type (string), handler(function or *)|will ***un***bind the `handler` function from the the `type` event. If the `handler` is `*`, all handlers for the event type will be removed. Just like `removeEventListener` in the browser, but also can remove all event handlers for the type.|
|
||||
|off|same as above|same as above|
|
||||
|publish|type (string), ...data arguments|will call all `handler` functions bound to the event `type` and pass all `...data arguments` to those handlers|
|
||||
|emit|same as above|same as above|
|
||||
|trigger|same as above|same as above|
|
||||
|
||||
While `publish`, `subscribe`, and `unSubscribe` are the proper method names for the publisher/subscriber model, we have included `on`, `off`, and `emit` as well because these are the most common event method names, and shorter. We have also kept the `trigger` method as an alias for `publish` and `emit` for backwards compatability with earlier versions of `event-pubsub`.
|
||||
|
||||
# The ` * ` type
|
||||
|
||||
The ` * ` type is a special event type that will be triggered by ***any publish or emit*** the handlers for these should expect the first argument to be the type and all arguments after to be data arguments.
|
||||
|
||||
|
||||
## Basic Examples
|
||||
|
||||
***NOTE - the only difference between node and browser code is how the `events` variable is created***
|
||||
* node ` const events = new Events `
|
||||
* browser `const events = new window.EventPubSub;`
|
||||
|
||||
#### Node
|
||||
|
||||
```javascript
|
||||
|
||||
// ES5/ES6 now automatically chosen based on node version
|
||||
const Events = new require('event-pubsub');
|
||||
const events=new Events;
|
||||
|
||||
events.on(
|
||||
'hello',
|
||||
function(data){
|
||||
console.log('hello event recieved ', data);
|
||||
events.emit(
|
||||
'world',
|
||||
{
|
||||
type:'myObject',
|
||||
data:{
|
||||
x:'YAY, Objects!'
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
events.on(
|
||||
'world',
|
||||
function(data){
|
||||
console.log('World event got',data);
|
||||
events.off('*','*');
|
||||
console.log('Removed all events');
|
||||
}
|
||||
);
|
||||
|
||||
events.emit(
|
||||
'hello',
|
||||
'world'
|
||||
);
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
#### Basic Chaining
|
||||
|
||||
```javascript
|
||||
|
||||
events.on(
|
||||
'hello',
|
||||
someFunction
|
||||
).on(
|
||||
'goodbye',
|
||||
anotherFunction
|
||||
).emit(
|
||||
'hello',
|
||||
'world'
|
||||
);
|
||||
|
||||
events.emit(
|
||||
'goodbye',
|
||||
'complexity'
|
||||
).off(
|
||||
'hello',
|
||||
'*'
|
||||
);
|
||||
|
||||
```
|
||||
|
||||
#### Browser
|
||||
##### HTML
|
||||
|
||||
```html
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>PubSub Example</title>
|
||||
<script src='../../event-pubsub-browser.js'></script>
|
||||
<!-- OR ES5 for older browser support
|
||||
<script src='../../event-pubsub-browser-es5.js'></script>
|
||||
-->
|
||||
<script src='yourAmazingCode.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
...
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
##### Inside Your Amazing Code
|
||||
|
||||
|
||||
```javascript
|
||||
|
||||
var events = new window.EventPubSub();
|
||||
|
||||
events.on(
|
||||
'hello',
|
||||
function(data){
|
||||
console.log('hello event recieved ', data);
|
||||
events.emit(
|
||||
'world',
|
||||
{
|
||||
type:'myObject',
|
||||
data:{
|
||||
x:'YAY, Objects!'
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
events.emit(
|
||||
'hello',
|
||||
'world'
|
||||
);
|
||||
|
||||
events.emit(
|
||||
'hello',
|
||||
'again','and again'
|
||||
);
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Basic Event Emitter and/or Extending Event PubSub
|
||||
|
||||
```javascript
|
||||
|
||||
// ES5/ES6 now automatically chosen based on node version
|
||||
const Events = require('event-pubsub');
|
||||
// manually include es6
|
||||
// const Events = require('event-pubsub/es6');
|
||||
|
||||
class Book extends Events{
|
||||
constructor(){
|
||||
super();
|
||||
//now Book has .on, .off, and .emit
|
||||
|
||||
this.words=[];
|
||||
}
|
||||
|
||||
add(...words){
|
||||
this.words.push(...words);
|
||||
this.emit(
|
||||
'added',
|
||||
...words
|
||||
);
|
||||
}
|
||||
|
||||
read(){
|
||||
this.emit(
|
||||
'reading'
|
||||
);
|
||||
console.log(this.words.join(' '));
|
||||
}
|
||||
}
|
||||
|
||||
const book=new Book;
|
||||
|
||||
book.on(
|
||||
'added',
|
||||
function(...words){
|
||||
console.log('words added : ',words);
|
||||
this.read();
|
||||
}
|
||||
);
|
||||
|
||||
book.add(
|
||||
'once','upon','a','time','in','a','cubicle'
|
||||
);
|
||||
|
||||
|
||||
```
|
||||
|
||||
##### ES5 extention example
|
||||
|
||||
```javascript
|
||||
|
||||
// manually include es5
|
||||
const Events = require('event-pubsub/es5.js');
|
||||
|
||||
function Book(){
|
||||
//extend happens below
|
||||
Object.assign(this,new Events);
|
||||
//now Book has .on, .off, and .emit
|
||||
|
||||
this.words=[];
|
||||
this.add=add;
|
||||
this.erase=erase;
|
||||
this.read=read;
|
||||
|
||||
function add(){
|
||||
arguments.slice=Array.prototype.slice;
|
||||
|
||||
this.words=this.words.concat(
|
||||
arguments.slice()
|
||||
);
|
||||
this.emit(
|
||||
'added',
|
||||
arguments.slice()
|
||||
);
|
||||
}
|
||||
|
||||
function read(){
|
||||
this.emit(
|
||||
'reading'
|
||||
);
|
||||
console.log(this.words.join(' '));
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
const book=new Book;
|
||||
|
||||
book.on(
|
||||
'added',
|
||||
function(...words){
|
||||
console.log('words added : ',words);
|
||||
this.read();
|
||||
}
|
||||
);
|
||||
|
||||
book.add(
|
||||
'once','upon','a','time','in','a','cubicle'
|
||||
);
|
||||
|
||||
|
||||
```
|
28
app_vue/node_modules/event-pubsub/bower.json
generated
vendored
Normal file
28
app_vue/node_modules/event-pubsub/bower.json
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "event-pubsub",
|
||||
"description": "Super light and fast Extensible PubSub events and EventEmitters for Node and the browser with support for ES6 by default, and ES5 versions for older verions of node and older IE/Safari versions. Easy for any developer level. No frills, just high speed pubsub events!",
|
||||
"main": "event-pubsub.js",
|
||||
"authors": [
|
||||
"Brandon Nozaki Miller"
|
||||
],
|
||||
"license": "DBAD",
|
||||
"keywords": [
|
||||
"event",
|
||||
"events",
|
||||
"pubsub",
|
||||
"node",
|
||||
"browser"
|
||||
],
|
||||
"homepage": "https://github.com/RIAEvangelist/event-pubsub",
|
||||
"moduleType": [
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
143
app_vue/node_modules/event-pubsub/es5.js
generated
vendored
Normal file
143
app_vue/node_modules/event-pubsub/es5.js
generated
vendored
Normal file
@ -0,0 +1,143 @@
|
||||
'use strict';
|
||||
|
||||
function EventPubSub() {
|
||||
this._events_={};
|
||||
this.publish=this.trigger=this.emit=emit;
|
||||
this.subscribe=this.on=on;
|
||||
this.once=once;
|
||||
this.unSubscribe=this.off=off;
|
||||
this.emit$=emit$;
|
||||
|
||||
function on(type,handler,once){
|
||||
if(!handler){
|
||||
throw new ReferenceError('handler not defined.');
|
||||
}
|
||||
|
||||
if(!this._events_[type]){
|
||||
this._events_[type]=[];
|
||||
}
|
||||
|
||||
if(once){
|
||||
handler._once_ = once;
|
||||
}
|
||||
this._events_[type].push(handler);
|
||||
return this;
|
||||
}
|
||||
|
||||
function once(type,handler){
|
||||
return this.on(type, handler, true);
|
||||
}
|
||||
|
||||
function off(type,handler){
|
||||
if(!this._events_[type]){
|
||||
return this;
|
||||
}
|
||||
|
||||
if(!handler){
|
||||
throw new ReferenceError('handler not defined. if you wish to remove all handlers from the event please pass "*" as the handler');
|
||||
}
|
||||
|
||||
if(handler=='*'){
|
||||
delete this._events_[type];
|
||||
return this;
|
||||
}
|
||||
|
||||
var handlers=this._events_[type];
|
||||
|
||||
while(handlers.includes(handler)){
|
||||
handlers.splice(
|
||||
handlers.indexOf(handler),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
if(handlers.length<1){
|
||||
delete this._events_[type];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function emit(type){
|
||||
this.emit$.apply(this, arguments);
|
||||
if(!this._events_[type]){
|
||||
return this;
|
||||
}
|
||||
arguments.splice=Array.prototype.splice;
|
||||
arguments.splice(0,1);
|
||||
|
||||
var handlers=this._events_[type];
|
||||
var onceHandled=[];
|
||||
|
||||
for(var i in handlers){
|
||||
var handler=handlers[i];
|
||||
handler.apply(this, arguments);
|
||||
if(handler._once_){
|
||||
onceHandled.push(handler);
|
||||
}
|
||||
}
|
||||
|
||||
for(var i in onceHandled){
|
||||
this.off(
|
||||
type,
|
||||
onceHandled[i]
|
||||
);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function emit$(type, args){
|
||||
if(!this._events_['*']){
|
||||
return this;
|
||||
}
|
||||
|
||||
var catchAll=this._events_['*'];
|
||||
|
||||
args.shift=Array.prototype.shift;
|
||||
args.shift(type);
|
||||
|
||||
for(var handler of catchAll){
|
||||
handler.apply(this, args);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!Array.prototype.includes) {
|
||||
Array.prototype.includes = function(searchElement /*, fromIndex*/) {
|
||||
'use strict';
|
||||
if (this == null) {
|
||||
throw new TypeError('Array.prototype.includes called on null or undefined');
|
||||
}
|
||||
|
||||
var O = Object(this);
|
||||
var len = parseInt(O.length, 10) || 0;
|
||||
if (len === 0) {
|
||||
return false;
|
||||
}
|
||||
var n = parseInt(arguments[1], 10) || 0;
|
||||
var k;
|
||||
if (n >= 0) {
|
||||
k = n;
|
||||
} else {
|
||||
k = len + n;
|
||||
if (k < 0) {k = 0;}
|
||||
}
|
||||
var currentElement;
|
||||
while (k < len) {
|
||||
currentElement = O[k];
|
||||
if (searchElement === currentElement ||
|
||||
(searchElement !== searchElement && currentElement !== currentElement)) { // NaN !== NaN
|
||||
return true;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports=EventPubSub;
|
99
app_vue/node_modules/event-pubsub/es6.js
generated
vendored
Normal file
99
app_vue/node_modules/event-pubsub/es6.js
generated
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
'use strict';
|
||||
|
||||
class EventPubSub {
|
||||
constructor( scope ) {
|
||||
this._events_ = {};
|
||||
this.publish = this.trigger = this.emit;
|
||||
this.subscribe = this.on;
|
||||
this.unSubscribe = this.off;
|
||||
}
|
||||
|
||||
on( type, handler, once ) {
|
||||
if ( !handler ) {
|
||||
throw new ReferenceError( 'handler not defined.' );
|
||||
}
|
||||
|
||||
if ( !this._events_[ type ] ) {
|
||||
this._events_[ type ] = [];
|
||||
}
|
||||
|
||||
if(once){
|
||||
handler._once_ = once;
|
||||
}
|
||||
|
||||
this._events_[ type ].push( handler );
|
||||
return this;
|
||||
}
|
||||
|
||||
once( type, handler ) {
|
||||
return this.on( type, handler, true );
|
||||
}
|
||||
|
||||
off( type, handler ) {
|
||||
if ( !this._events_[ type ] ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if ( !handler ) {
|
||||
throw new ReferenceError( 'handler not defined. if you wish to remove all handlers from the event please pass "*" as the handler' );
|
||||
}
|
||||
|
||||
if ( handler == '*' ) {
|
||||
delete this._events_[ type ];
|
||||
return this;
|
||||
}
|
||||
|
||||
const handlers = this._events_[ type ];
|
||||
|
||||
while ( handlers.includes( handler ) ) {
|
||||
handlers.splice(
|
||||
handlers.indexOf( handler ),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
if ( handlers.length < 1 ) {
|
||||
delete this._events_[ type ];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
emit( type, ...args ) {
|
||||
if ( !this._events_[ type ] ) {
|
||||
return this.emit$( type, ...args );
|
||||
}
|
||||
|
||||
const handlers = this._events_[ type ];
|
||||
const onceHandled=[];
|
||||
|
||||
for ( let handler of handlers ) {
|
||||
handler.apply( this, args );
|
||||
if(handler._once_){
|
||||
onceHandled.push(handler);
|
||||
}
|
||||
}
|
||||
|
||||
for(let handler of onceHandled){
|
||||
this.off(type,handler);
|
||||
}
|
||||
|
||||
return this.emit$( type, ...args );
|
||||
}
|
||||
|
||||
emit$( type, ...args ) {
|
||||
if ( !this._events_[ '*' ] ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
const catchAll = this._events_[ '*' ];
|
||||
|
||||
for ( let handler of catchAll ) {
|
||||
handler.call( this, type, ...args );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = EventPubSub;
|
141
app_vue/node_modules/event-pubsub/event-pubsub-browser-es5.js
generated
vendored
Normal file
141
app_vue/node_modules/event-pubsub/event-pubsub-browser-es5.js
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
'use strict';
|
||||
|
||||
window.EventPubSub=function EventPubSub() {
|
||||
this._events_={};
|
||||
this.publish=this.trigger=this.emit=emit;
|
||||
this.subscribe=this.on=on;
|
||||
this.once=once;
|
||||
this.unSubscribe=this.off=off;
|
||||
this.emit$=emit$;
|
||||
|
||||
function on(type,handler,once){
|
||||
if(!handler){
|
||||
throw new ReferenceError('handler not defined.');
|
||||
}
|
||||
|
||||
if(!this._events_[type]){
|
||||
this._events_[type]=[];
|
||||
}
|
||||
|
||||
if(once){
|
||||
handler._once_ = once;
|
||||
}
|
||||
this._events_[type].push(handler);
|
||||
return this;
|
||||
}
|
||||
|
||||
function once(type,handler){
|
||||
return this.on(type, handler, true);
|
||||
}
|
||||
|
||||
function off(type,handler){
|
||||
if(!this._events_[type]){
|
||||
return this;
|
||||
}
|
||||
|
||||
if(!handler){
|
||||
throw new ReferenceError('handler not defined. if you wish to remove all handlers from the event please pass "*" as the handler');
|
||||
}
|
||||
|
||||
if(handler=='*'){
|
||||
delete this._events_[type];
|
||||
return this;
|
||||
}
|
||||
|
||||
var handlers=this._events_[type];
|
||||
|
||||
while(handlers.includes(handler)){
|
||||
handlers.splice(
|
||||
handlers.indexOf(handler),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
if(handlers.length<1){
|
||||
delete this._events_[type];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function emit(type){
|
||||
this.emit$.apply(this, arguments);
|
||||
if(!this._events_[type]){
|
||||
return this;
|
||||
}
|
||||
arguments.splice=Array.prototype.splice;
|
||||
arguments.splice(0,1);
|
||||
|
||||
var handlers=this._events_[type];
|
||||
var onceHandled=[];
|
||||
|
||||
for(var i in handlers){
|
||||
var handler=handlers[i];
|
||||
handler.apply(this, arguments);
|
||||
if(handler._once_){
|
||||
onceHandled.push(handler);
|
||||
}
|
||||
}
|
||||
|
||||
for(var i in onceHandled){
|
||||
this.off(
|
||||
type,
|
||||
onceHandled[i]
|
||||
);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
function emit$(type, args){
|
||||
if(!this._events_['*']){
|
||||
return this;
|
||||
}
|
||||
|
||||
var catchAll=this._events_['*'];
|
||||
|
||||
args.shift=Array.prototype.shift;
|
||||
args.shift(type);
|
||||
|
||||
for(var handler of catchAll){
|
||||
handler.apply(this, args);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!Array.prototype.includes) {
|
||||
Array.prototype.includes = function(searchElement /*, fromIndex*/) {
|
||||
'use strict';
|
||||
if (this == null) {
|
||||
throw new TypeError('Array.prototype.includes called on null or undefined');
|
||||
}
|
||||
|
||||
var O = Object(this);
|
||||
var len = parseInt(O.length, 10) || 0;
|
||||
if (len === 0) {
|
||||
return false;
|
||||
}
|
||||
var n = parseInt(arguments[1], 10) || 0;
|
||||
var k;
|
||||
if (n >= 0) {
|
||||
k = n;
|
||||
} else {
|
||||
k = len + n;
|
||||
if (k < 0) {k = 0;}
|
||||
}
|
||||
var currentElement;
|
||||
while (k < len) {
|
||||
currentElement = O[k];
|
||||
if (searchElement === currentElement ||
|
||||
(searchElement !== searchElement && currentElement !== currentElement)) { // NaN !== NaN
|
||||
return true;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
130
app_vue/node_modules/event-pubsub/event-pubsub-browser.js
generated
vendored
Normal file
130
app_vue/node_modules/event-pubsub/event-pubsub-browser.js
generated
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
'use strict';
|
||||
|
||||
window.EventPubSub=class EventPubSub {
|
||||
constructor( scope ) {
|
||||
this._events_ = {};
|
||||
this.publish = this.trigger = this.emit;
|
||||
this.subscribe = this.on;
|
||||
this.unSubscribe = this.off;
|
||||
}
|
||||
|
||||
on( type, handler, once ) {
|
||||
if ( !handler ) {
|
||||
throw new ReferenceError( 'handler not defined.' );
|
||||
}
|
||||
|
||||
if ( !this._events_[ type ] ) {
|
||||
this._events_[ type ] = [];
|
||||
}
|
||||
|
||||
if(once){
|
||||
handler._once_ = once;
|
||||
}
|
||||
|
||||
this._events_[ type ].push( handler );
|
||||
return this;
|
||||
}
|
||||
|
||||
once( type, handler ) {
|
||||
return this.on( type, handler, true );
|
||||
}
|
||||
|
||||
off( type, handler ) {
|
||||
if ( !this._events_[ type ] ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if ( !handler ) {
|
||||
throw new ReferenceError( 'handler not defined. if you wish to remove all handlers from the event please pass "*" as the handler' );
|
||||
}
|
||||
|
||||
if ( handler == '*' ) {
|
||||
delete this._events_[ type ];
|
||||
return this;
|
||||
}
|
||||
|
||||
const handlers = this._events_[ type ];
|
||||
|
||||
while ( handlers.includes( handler ) ) {
|
||||
handlers.splice(
|
||||
handlers.indexOf( handler ),
|
||||
1
|
||||
);
|
||||
}
|
||||
|
||||
if ( handlers.length < 1 ) {
|
||||
delete this._events_[ type ];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
emit( type, ...args ) {
|
||||
if ( !this._events_[ type ] ) {
|
||||
return this.emit$( type, ...args );
|
||||
}
|
||||
|
||||
const handlers = this._events_[ type ];
|
||||
const onceHandled=[];
|
||||
|
||||
for ( let handler of handlers ) {
|
||||
handler.apply( this, args );
|
||||
if(handler._once_){
|
||||
onceHandled.push(handler);
|
||||
}
|
||||
}
|
||||
|
||||
for(let handler of onceHandled){
|
||||
this.off(type,handler);
|
||||
}
|
||||
|
||||
return this.emit$( type, ...args );
|
||||
}
|
||||
|
||||
emit$( type, ...args ) {
|
||||
if ( !this._events_[ '*' ] ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
const catchAll = this._events_[ '*' ];
|
||||
|
||||
for ( let handler of catchAll ) {
|
||||
handler.call( this, type, ...args );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Array.prototype.includes) {
|
||||
Array.prototype.includes = function(searchElement /*, fromIndex*/) {
|
||||
'use strict';
|
||||
if (this == null) {
|
||||
throw new TypeError('Array.prototype.includes called on null or undefined');
|
||||
}
|
||||
|
||||
var O = Object(this);
|
||||
var len = parseInt(O.length, 10) || 0;
|
||||
if (len === 0) {
|
||||
return false;
|
||||
}
|
||||
var n = parseInt(arguments[1], 10) || 0;
|
||||
var k;
|
||||
if (n >= 0) {
|
||||
k = n;
|
||||
} else {
|
||||
k = len + n;
|
||||
if (k < 0) {k = 0;}
|
||||
}
|
||||
var currentElement;
|
||||
while (k < len) {
|
||||
currentElement = O[k];
|
||||
if (searchElement === currentElement ||
|
||||
(searchElement !== searchElement && currentElement !== currentElement)) { // NaN !== NaN
|
||||
return true;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
8
app_vue/node_modules/event-pubsub/event-pubsub.js
generated
vendored
Normal file
8
app_vue/node_modules/event-pubsub/event-pubsub.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
let EventPubSub = require('./es5');
|
||||
if(process.version[1]>5){
|
||||
EventPubSub = require('./es6');
|
||||
}
|
||||
|
||||
module.exports=EventPubSub;
|
32
app_vue/node_modules/event-pubsub/package.json
generated
vendored
Normal file
32
app_vue/node_modules/event-pubsub/package.json
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "event-pubsub",
|
||||
"version": "4.3.0",
|
||||
"description": "Super light and fast Extensible PubSub events and EventEmitters for Node and the browser with support for ES6 by default, and ES5 versions for older verions of node and older IE/Safari versions. Easy for any developer level. No frills, just high speed pubsub events!",
|
||||
"main": "event-pubsub.js",
|
||||
"directories": {
|
||||
"example": "examples"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/RIAEvangelist/event-pubsub.git"
|
||||
},
|
||||
"keywords": [
|
||||
"event",
|
||||
"events",
|
||||
"pubsub",
|
||||
"node",
|
||||
"browser"
|
||||
],
|
||||
"author": "Brandon Nozaki Miller",
|
||||
"license": "Unlicense",
|
||||
"bugs": {
|
||||
"url": "https://github.com/RIAEvangelist/event-pubsub/issues"
|
||||
},
|
||||
"homepage": "https://github.com/RIAEvangelist/event-pubsub"
|
||||
}
|
Reference in New Issue
Block a user