First Commit of new way of building the Platform

This commit is contained in:
Luis Fernando Molina committed 2020-01-28 17:27:23 +01:00
1 parent e48cf0dae5
commit 40e60b42cc
4616 files changed
+713402

No files matched your search

+28
View 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
View 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
View 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
View 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
View 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
View File
@@ -0,0 +1,8 @@
'use strict';
let EventPubSub = require('./es5');
if(process.version[1]>5){
EventPubSub = require('./es6');
}
module.exports=EventPubSub;
+62
View File
@@ -0,0 +1,62 @@
{
"_args": [
[
"event-pubsub@4.3.0",
"C:\\Users\\Luis\\source\\repos\\AAMasters\\TaskServer"
]
],
"_from": "event-pubsub@4.3.0",
"_id": "event-pubsub@4.3.0",
"_inBundle": false,
"_integrity": "sha512-z7IyloorXvKbFx9Bpie2+vMJKKx1fH1EN5yiTfp8CiLOTptSYy1g8H4yDpGlEdshL1PBiFtBHepF2cNsqeEeFQ==",
"_location": "/event-pubsub",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "event-pubsub@4.3.0",
"name": "event-pubsub",
"escapedName": "event-pubsub",
"rawSpec": "4.3.0",
"saveSpec": null,
"fetchSpec": "4.3.0"
},
"_requiredBy": [
"/node-ipc"
],
"_resolved": "https://registry.npmjs.org/event-pubsub/-/event-pubsub-4.3.0.tgz",
"_spec": "4.3.0",
"_where": "C:\\Users\\Luis\\source\\repos\\AAMasters\\TaskServer",
"author": {
"name": "Brandon Nozaki Miller"
},
"bugs": {
"url": "https://github.com/RIAEvangelist/event-pubsub/issues"
},
"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!",
"directories": {
"example": "examples"
},
"engines": {
"node": ">=4.0.0"
},
"homepage": "https://github.com/RIAEvangelist/event-pubsub",
"keywords": [
"event",
"events",
"pubsub",
"node",
"browser"
],
"license": "Unlicense",
"main": "event-pubsub.js",
"name": "event-pubsub",
"repository": {
"type": "git",
"url": "git+https://github.com/RIAEvangelist/event-pubsub.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "4.3.0"
}