blog/source/files/magicbroad/assets/index.79b5287a.js.map

1 line
65 KiB
Text
Raw Normal View History

2022-06-09 01:09:09 +00:00
{"version":3,"file":"index.79b5287a.js","sources":["../../node_modules/js-event-bus/src/index.js","../../src/helpers/mesh/datachannel/index.ts","../../src/helpers/mesh/webrtc/index.ts","../../node_modules/@solid-primitives/utils/dist/index.js","../../src/helpers/mesh/index.ts","../../src/helpers/mesh/supabase/z85.ts","../../src/helpers/mesh/supabase/index.ts"],"sourcesContent":["(function(caller, bus) {\n if (typeof exports === 'object' && typeof module === 'object') {\n module.exports = bus();\n module.exports.default = module.exports;\n } else if (typeof exports === 'object') {\n exports.EventBus = bus();\n } else {\n caller.EventBus = bus();\n }\n})(this, function() {\n var EventBus = function() {\n this.listeners = {};\n\n this.registerListener = function(event, callback, number) {\n var type = event.constructor.name;\n number = this.validateNumber(number || 'any');\n\n if (type !== 'Array') {\n event = [event];\n }\n\n event.forEach(function(e) {\n if (e.constructor.name !== 'String') {\n throw new Error(\n 'Only `String` and array of `String` are accepted for the event names!'\n );\n }\n\n that.listeners[e] = that.listeners[e] || [];\n that.listeners[e].push({\n callback: callback,\n number: number,\n });\n });\n };\n\n // valiodate that the number is a vild number for the number of executions\n this.validateNumber = function(n) {\n var type = n.constructor.name;\n\n if (type === 'Number') {\n return n;\n } else if (type === 'String' && n.toLowerCase() === 'any') {\n return 'any';\n }\n\n throw new Error(\n 'Only `Number` and `any` are accepted in the number of possible executions!'\n );\n };\n\n // return wether or not this event needs to be removed\n this.toBeRemoved = function(info) {\n var number = info.number;\n info.execution = info.execution || 0;\n info.execution++;\n\n if (number === 'any' || info.execution < number) {\n return false;\n }\n\n return true;\n };\n\n var that = this;\n return {\n /**\n * Attach a callback to an event\n * @param {string} eventName - name of the event.\n * @param {function} callback - callback executed when this event is triggered\n */\n on: function(eventName, callback) {\n that.registerListener.bind(that)(eventName, callback, 'any');\n },\n\n /**\n * Attach a callback to an event. This callback will not be executed more than once if the event is trigger mutiple times\n * @param {string} eventName - name of the event.\n * @param {function} callback - callback executed when this event is triggered\n */\n once: function(eventName, callback) {\n that.registerListener.bind(that)(eventName, callback, 1);\n },\n\n /**\n * Attach a callback to an event. This callback will be executed will not be executed more than the number if the event is trigger mutiple times\n * @param {number} number - max number of executions\n * @param {string} eventName - name of the event.\n * @param {function} callback - callback executed when this event is triggered\n */\n exactly: function(number, eventName, callback) {\n that.registerListener.bind(that)(eventName, callback, number);\n },\n\n /**\n * Kill an event with all it's callbacks\n * @param {string} eventName - name of the event.\n */\n die: function(eventName) {\n delete that.listeners[eventName];\n },\n\n /**\n * Kill an event with all it's callbacks\n * @param {string} eventName - name of the event.\n */\n off: function(eventName) {\n this.die(eventName);\n },\n\n /**\n * Remove the callback for the given event\n * @param {string} eventName - name of the event.\n * @param {callback} callback - the callback to remove (undefined to remove all of them)