Archived
1
0

First commit

This commit is contained in:
Sean Edmunds
2021-12-13 17:00:40 -06:00
commit 0584430b5c
36617 changed files with 4676695 additions and 0 deletions

15
node_modules/microevent.ts/lib/Event.d.ts generated vendored Normal file
View File

@@ -0,0 +1,15 @@
import EventInterface from './EventInterface';
declare class Event<EventPayload> implements EventInterface<EventPayload> {
constructor();
addHandler<T>(handler: EventInterface.HandlerInterface<EventPayload, T>, context?: T): Event<EventPayload>;
removeHandler<T>(handler: EventInterface.HandlerInterface<EventPayload, T>, context?: T): Event<EventPayload>;
isHandlerAttached<T>(handler: EventInterface.HandlerInterface<EventPayload, T>, context?: T): boolean;
dispatch: (payload: EventPayload) => void;
hasHandlers: boolean;
private _updateHasHandlers;
private _getHandlerIndex;
private _createDispatcher;
private _handlers;
private _contexts;
}
export default Event;

76
node_modules/microevent.ts/lib/Event.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var factories = [];
factories[0] = function () {
return function dispatcher0() { };
};
factories[1] = function (callback, context) {
if (typeof (context) === 'undefined')
return callback;
return function dispatcher1(payload) {
callback(payload, context);
};
};
function getFactory(handlerCount) {
if (!factories[handlerCount])
factories[handlerCount] = compileFactory(handlerCount);
return factories[handlerCount];
}
function compileFactory(handlerCount) {
var src = 'return function dispatcher' + handlerCount + '(payload) {\n';
var argsHandlers = [], argsContexts = [];
for (var i = 0; i < handlerCount; i++) {
argsHandlers.push('cb' + i);
argsContexts.push('ctx' + i);
src += ' cb' + i + '(payload, ctx' + i + ');\n';
}
src += '};';
return new (Function.bind.apply(Function, [void 0].concat(argsHandlers.concat(argsContexts), [src])))();
}
var Event = /** @class */ (function () {
function Event() {
this.hasHandlers = false;
this._handlers = [];
this._contexts = [];
this._createDispatcher();
}
Event.prototype.addHandler = function (handler, context) {
if (!this.isHandlerAttached(handler, context)) {
this._handlers.push(handler);
this._contexts.push(context);
this._createDispatcher();
this._updateHasHandlers();
}
return this;
};
Event.prototype.removeHandler = function (handler, context) {
var idx = this._getHandlerIndex(handler, context);
if (typeof (idx) !== 'undefined') {
this._handlers.splice(idx, 1);
this._contexts.splice(idx, 1);
this._createDispatcher();
this._updateHasHandlers();
}
return this;
};
Event.prototype.isHandlerAttached = function (handler, context) {
return typeof (this._getHandlerIndex(handler, context)) !== 'undefined';
};
Event.prototype._updateHasHandlers = function () {
this.hasHandlers = !!this._handlers.length;
};
Event.prototype._getHandlerIndex = function (handler, context) {
var handlerCount = this._handlers.length;
var idx;
for (idx = 0; idx < handlerCount; idx++) {
if (this._handlers[idx] === handler && this._contexts[idx] === context)
break;
}
return idx < handlerCount ? idx : undefined;
};
Event.prototype._createDispatcher = function () {
this.dispatch = getFactory(this._handlers.length).apply(this, this._handlers.concat(this._contexts));
};
return Event;
}());
exports.default = Event;

10
node_modules/microevent.ts/lib/EventInterface.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
interface EventInterface<EventPayload> {
addHandler<T>(handler: EventInterface.HandlerInterface<EventPayload, T>, context?: T): EventInterface<EventPayload>;
removeHandler<T>(handler: EventInterface.HandlerInterface<EventPayload, T>, context?: T): EventInterface<EventPayload>;
}
declare module EventInterface {
interface HandlerInterface<EventPayload, T> {
(payload: EventPayload, context: T): void;
}
}
export default EventInterface;

2
node_modules/microevent.ts/lib/EventInterface.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

2
node_modules/microevent.ts/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { default as Event } from './Event';
export { default as EventInterface } from './EventInterface';

4
node_modules/microevent.ts/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Event_1 = require("./Event");
exports.Event = Event_1.default;