socket.io-mock
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.SocketMock=t()}(this,function(){"use strict";function e(e,t){return t={exports:{}},e(t,t.exports),t.exports}function t(e){if(e=String(e),!(e.length>1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return n*y;case"days":case"day":case"d":return n*h;case"hours":case"hour":case"hrs":case"hr":case"h":return n*d;case"minutes":case"minute":case"mins":case"min":case"m":return n*p;case"seconds":case"second":case"secs":case"sec":case"s":return n*f;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function n(e){return e>=h?Math.round(e/h)+"d":e>=d?Math.round(e/d)+"h":e>=p?Math.round(e/p)+"m":e>=f?Math.round(e/f)+"s":e+"ms"}function o(e){return r(e,h,"day")||r(e,d,"hour")||r(e,p,"minute")||r(e,f,"second")||e+" ms"}function r(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}var s=e(function(e){function t(e){if(e)return n(e)}function n(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o,r=0;r<n.length;r++)if(o=n[r],o===t||o.fn===t){n.splice(r,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n){n=n.slice(0);for(var o=0,r=n.length;o<r;++o)n[o].apply(this,t)}return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}),i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),u=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},l=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},f=1e3,p=60*f,d=60*p,h=24*d,y=365.25*h,m=function(e,r){r=r||{};var s="undefined"==typeof e?"undefined":i(e);if("string"===s&&e.length>0)return t(e);if("number"===s&&isNaN(e)===!1)return r.long?o(e):n(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))},g=e(function(e,t){function n(e){var n,o=0;for(n in e)o=(o<<5)-o+e.charCodeAt(n),o|=0;return t.colors[Math.abs(o)%t.colors.length]}function o(e){function o(){if(o.enabled){var e=o,n=+new Date,r=n-(a||n);e.diff=r,e.prev=a,e.curr=n,a=n;for(var s=new Array(arguments.length),i=0;i<s.length;i++)s[i]=arguments[i];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var c=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(n,o){if("%%"===n)return n;c++;var r=t.formatters[o];if("function"==typeof r){var i=s[c];n=r.call(e,i),s.splice(c,1),c--}return n}),t.formatArgs.call(e,s);var u=o.log||t.log||console.log.bind(console);u.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=n(e),"function"==typeof t.init&&t.init(o),o}function r(e){t.save(e);for(var n=(e||"").split(/[\s,]+/),o=n.length,r=0;r<o;r++)n[r]&&(e=n[r].replace(/\*/g,".*?"),"-"===e[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))}function s(){t.enable("")}function i(e){var n,o;for(n=0,o=t.skips.length;n<o;n++)if(t.skips[n].test(e))return!1;for(n=0,o=t.names.length;n<o;n++)if(t.names[n].test(e))return!0;return!1}function c(e){return e instanceof Error?e.stack||e.message:e}t=e.exports=o.debug=o.default=o,t.coerce=c,t.disable=s,t.enable=r,t.enabled=i,t.humanize=m,t.names=[],t.skips=[],t.formatters={};var a}),b=e(function(e,t){function n(){return"undefined"!=typeof window&&"undefined"!=typeof window.process&&"renderer"===window.process.type||("undefined"!=typeof document&&"WebkitAppearance"in document.documentElement.style||"undefined"!=typeof window&&window.console&&(console.firebug||console.exception&&console.table)||navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function o(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),n){var o="color: "+this.color;e.splice(1,0,o,"color: inherit");var r=0,s=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(s=r))}),e.splice(s,0,o)}}function r(){return"object"===("undefined"==typeof console?"undefined":i(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function c(){try{return t.storage.debug}catch(e){}if("undefined"!=typeof process&&"env"in process)return process.env.DEBUG}function a(){try{return window.localStorage}catch(e){}}t=e.exports=g,t.log=r,t.formatArgs=o,t.save=s,t.load=c,t.useColors=n,t.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:a(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(c()),window&&(window.debug=t)}),v=b("socket.io-mock:client"),k=s.prototype.emit,w=function(e){function t(e){c(this,t);var n=l(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n._socketMock=e,n}return u(t,e),a(t,[{key:"emit",value:function(e,t,n){var o=n||function(){};v("SocketClient","emit",e),o(this._socketMock.emitEvent(e,t))}},{key:"fireEvent",value:function(e,t){v("Event %s on client side is dispatched with payload %s",e,JSON.stringify(t)),k.call(this,e,t)}}]),t}(s),_=b("socket.io-mock:server"),E=s.prototype.emit,O=function(e){return JSON.parse(JSON.stringify(e))},x=function(e){function t(){c(this,t);var e=l(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.broadcast={to:function(t){return{emit:function(n,o){e.generalCallbacks[n]&&e.generalCallbacks[n](O(o),t)}}}},e.joinedRooms=e.rooms=[],e.socketClient=new w(e),e.generalCallbacks={},e.broadcast={to:e.broadcast.to.bind(e)},e}return u(t,e),a(t,[{key:"emitEvent",value:function(e,t){_("Event %s on server side is dispatched with payload %s",e,JSON.stringify(t)),E.call(this,e,O(t))}},{key:"onEmit",value:function(e,t){this.generalCallbacks[e]=t}},{key:"emit",value:function(e,t){this.socketClient.fireEvent(e,t)}},{key:"join",value:function(e){_("Joining room %s",e),this.joinedRooms.push(e)}},{key:"leave",value:function(e){var t=this.joinedRooms.indexOf(e);this.joinedRooms.splice(t,1)}},{key:"monitor",value:function(e){return _("Monitor: %s",e),e}}]),t}(s);return x}); | ||
"use strict";function createCommonjsModule(e,t){return t={exports:{}},e(t,t.exports),t.exports}function parse(e){if(e=String(e),!(e.length>1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),o=(t[2]||"ms").toLowerCase();switch(o){case"years":case"year":case"yrs":case"yr":case"y":return n*y;case"days":case"day":case"d":return n*d;case"hours":case"hour":case"hrs":case"hr":case"h":return n*h;case"minutes":case"minute":case"mins":case"min":case"m":return n*m;case"seconds":case"second":case"secs":case"sec":case"s":return n*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function fmtShort(e){return e>=d?Math.round(e/d)+"d":e>=h?Math.round(e/h)+"h":e>=m?Math.round(e/m)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function fmtLong(e){return plural(e,d,"day")||plural(e,h,"hour")||plural(e,m,"minute")||plural(e,s,"second")||e+" ms"}function plural(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}var index=createCommonjsModule(function(e){function t(e){if(e)return n(e)}function n(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}e.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var o,r=0;r<n.length;r++)if(o=n[r],o===t||o.fn===t){n.splice(r,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n){n=n.slice(0);for(var o=0,r=n.length;o<r;++o)n[o].apply(this,t)}return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},s=1e3,m=60*s,h=60*m,d=24*h,y=365.25*d,index$1=function(e,t){t=t||{};var n="undefined"==typeof e?"undefined":_typeof(e);if("string"===n&&e.length>0)return parse(e);if("number"===n&&isNaN(e)===!1)return t.long?fmtLong(e):fmtShort(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))},debug$1=createCommonjsModule(function(e,t){function n(e){var n,o=0;for(n in e)o=(o<<5)-o+e.charCodeAt(n),o|=0;return t.colors[Math.abs(o)%t.colors.length]}function o(e){function o(){if(o.enabled){var e=o,n=+new Date,r=n-(c||n);e.diff=r,e.prev=c,e.curr=n,c=n;for(var s=new Array(arguments.length),i=0;i<s.length;i++)s[i]=arguments[i];s[0]=t.coerce(s[0]),"string"!=typeof s[0]&&s.unshift("%O");var a=0;s[0]=s[0].replace(/%([a-zA-Z%])/g,function(n,o){if("%%"===n)return n;a++;var r=t.formatters[o];if("function"==typeof r){var i=s[a];n=r.call(e,i),s.splice(a,1),a--}return n}),t.formatArgs.call(e,s);var l=o.log||t.log||console.log.bind(console);l.apply(e,s)}}return o.namespace=e,o.enabled=t.enabled(e),o.useColors=t.useColors(),o.color=n(e),"function"==typeof t.init&&t.init(o),o}function r(e){t.save(e);for(var n=(e||"").split(/[\s,]+/),o=n.length,r=0;r<o;r++)n[r]&&(e=n[r].replace(/\*/g,".*?"),"-"===e[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))}function s(){t.enable("")}function i(e){var n,o;for(n=0,o=t.skips.length;n<o;n++)if(t.skips[n].test(e))return!1;for(n=0,o=t.names.length;n<o;n++)if(t.names[n].test(e))return!0;return!1}function a(e){return e instanceof Error?e.stack||e.message:e}t=e.exports=o.debug=o.default=o,t.coerce=a,t.disable=s,t.enable=r,t.enabled=i,t.humanize=index$1,t.names=[],t.skips=[],t.formatters={};var c}),browser$1=createCommonjsModule(function(e,t){function n(){return"undefined"!=typeof window&&"undefined"!=typeof window.process&&"renderer"===window.process.type||("undefined"!=typeof document&&"WebkitAppearance"in document.documentElement.style||"undefined"!=typeof window&&window.console&&(console.firebug||console.exception&&console.table)||navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function o(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),n){var o="color: "+this.color;e.splice(1,0,o,"color: inherit");var r=0,s=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(r++,"%c"===e&&(s=r))}),e.splice(s,0,o)}}function r(){return"object"===("undefined"==typeof console?"undefined":_typeof(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}}function i(){try{return t.storage.debug}catch(e){}if("undefined"!=typeof process&&"env"in process)return process.env.DEBUG}function a(){try{return window.localStorage}catch(e){}}t=e.exports=debug$1,t.log=r,t.formatArgs=o,t.save=s,t.load=i,t.useColors=n,t.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:a(),t.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i()),window&&(window.debug=t)}),debug$3=browser$1("socket.io-mock:client"),emitFn$1=index.prototype.emit,SocketClient=function(e){function t(e){classCallCheck(this,t);var n=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return n._socketMock=e,n}return inherits(t,e),createClass(t,[{key:"emit",value:function(e,t,n){var o=n||function(){};debug$3("SocketClient","emit",e),o(this._socketMock.emitEvent(e,t))}},{key:"fireEvent",value:function(e,t){debug$3("Event %s on client side is dispatched with payload %s",e,JSON.stringify(t)),emitFn$1.call(this,e,t)}}]),t}(index),debug=browser$1("socket.io-mock:server"),emitFn=index.prototype.emit,createPayload=function(e){return JSON.parse(JSON.stringify(e))},SocketMock=function(e){function t(){classCallCheck(this,t);var e=possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this));return e.broadcast={to:function(t){return{emit:function(n,o){e.generalCallbacks[n]&&e.generalCallbacks[n](createPayload(o),t)}}}},e.joinedRooms=e.rooms=[],e.socketClient=new SocketClient(e),e.generalCallbacks={},e.broadcast={to:e.broadcast.to.bind(e)},e}return inherits(t,e),createClass(t,[{key:"emitEvent",value:function(e,t){debug("Event %s on server side is dispatched with payload %s",e,JSON.stringify(t)),emitFn.call(this,e,createPayload(t))}},{key:"onEmit",value:function(e,t){this.generalCallbacks[e]=t}},{key:"emit",value:function(e,t){this.socketClient.fireEvent(e,t)}},{key:"join",value:function(e){debug("Joining room %s",e),this.joinedRooms.push(e)}},{key:"leave",value:function(e){var t=this.joinedRooms.indexOf(e);this.joinedRooms.splice(t,1)}},{key:"monitor",value:function(e){return debug("Monitor: %s",e),e}}]),t}(index);module.exports=SocketMock; |
{ | ||
"name": "socket.io-mock", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "a mocked version of a socket.io socket for testing", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.min.js", |
@@ -12,3 +12,3 @@ import babel from 'rollup-plugin-babel'; | ||
const prodTargets = [ | ||
{ dest: 'dist/' + file + '.min.js', format: 'umd' } | ||
{ dest: 'dist/' + file + '.min.js', format: 'cjs' } | ||
]; | ||
@@ -15,0 +15,0 @@ const devTargets = [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55344
1175