Socket
Socket
Sign inDemoInstall

happened

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

happened - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

23

dist/happened.dev.js

@@ -19,8 +19,16 @@ (function (global, factory) {

// This weird magic is manual optimization for file size
var channelMap = Object.create(null);
function syncScheduler(callback) {
callback();
}
function createMap() {
return Object.create ? Object.create(null) : {};
}
function freezeIfPossible(obj) {
return Object.freeze ? Object.freeze(obj) : obj;
}
var channelMap = createMap();
var defaultScheduler = undefined && undefined.setTimeout || syncScheduler;

@@ -63,3 +71,3 @@

happened.create = function () {
var callbackMap = Object.create(null);
var callbackMap = createMap();
var scheduler = defaultScheduler;

@@ -84,3 +92,3 @@

if (!name && !callback) {
callbackMap = Object.create(null);
callbackMap = createMap();
return;

@@ -113,3 +121,4 @@ }

}
return Object.freeze({
return freezeIfPossible({
ALL_EVENTS: ALL_EVENTS,

@@ -212,3 +221,3 @@ off: off,

module.exports = Object.freeze(happened);
module.exports = freezeIfPossible(happened);
});

@@ -1,1 +0,1 @@

!function(e,n){if("function"==typeof define&&define.amd)define(["exports","module"],n);else if("undefined"!=typeof exports&&"undefined"!=typeof module)n(exports,module);else{var t={exports:{}};n(t.exports,t),e.happened=t.exports}}(this,function(e,n){"use strict";function t(e){e()}var r={},o=r.ALL_EVENTS="357dada3-e2a8-4966-8bd1-ea5c52752f63",c=Object.create(null),i=void 0||t;r.SYNC=t,r.setDefaultScheduler=function(e){i=e},r.create=function(){function e(e,n,r,o){t[e]||(t[e]=[]),t[e].push({thisArg:r,original:o,callback:n})}function n(e,n){if(!e&&!n)return void(t=Object.create(null));var r=t[e];if(r){if(!n)return void(t[e]=[]);for(var o=0;o<r.length;++o)(r[o].callback===n||r[o].original===n)&&r.splice(o--,1)}}var t=Object.create(null),r=i;return Object.freeze({ALL_EVENTS:o,off:n,setScheduler:function(e){i=e},trigger:function(e){for(var n=[],c=1;c<arguments.length;++c)n.push(arguments[c]);var i=t[e],f=t[o];(i||f)&&r(function(){if(i){i=i.slice();for(var t=0;t<i.length;++t)i[t].callback.apply(i[t].thisArg,n)}if(f){f=f.slice();for(var t=0;t<f.length;++t)f[t].callback.call(f[t].thisArg,e,n)}})},on:function(n,t,r){e(n,t,r)},once:function(t,r,o){function c(){n(t,c),r.apply(this,arguments)}e(t,c,o,r)}})},r.addTo=function(e){var n=r.create();return e.on=n.on,e.once=n.once,e.off=n.off,e.trigger=n.trigger,e.ALL_EVENTS=n.ALL_EVENTS,n},r.channel=function(e){return c[e]||(c[e]=r.create()),c[e]},r.global=r.create(),n.exports=Object.freeze(r)});
!function(e,n){if("function"==typeof define&&define.amd)define(["exports","module"],n);else if("undefined"!=typeof exports&&"undefined"!=typeof module)n(exports,module);else{var t={exports:{}};n(t.exports,t),e.happened=t.exports}}(this,function(e,n){"use strict";function t(e){e()}function r(){return Object.create?Object.create(null):{}}function o(e){return Object.freeze?Object.freeze(e):e}var i={},c=i.ALL_EVENTS="357dada3-e2a8-4966-8bd1-ea5c52752f63",f=r(),a=void 0||t;i.SYNC=t,i.setDefaultScheduler=function(e){a=e},i.create=function(){function e(e,n,r,o){t[e]||(t[e]=[]),t[e].push({thisArg:r,original:o,callback:n})}function n(e,n){if(!e&&!n)return void(t=r());var o=t[e];if(o){if(!n)return void(t[e]=[]);for(var i=0;i<o.length;++i)(o[i].callback===n||o[i].original===n)&&o.splice(i--,1)}}var t=r(),i=a;return o({ALL_EVENTS:c,off:n,setScheduler:function(e){a=e},trigger:function(e){for(var n=[],r=1;r<arguments.length;++r)n.push(arguments[r]);var o=t[e],f=t[c];(o||f)&&i(function(){if(o){o=o.slice();for(var t=0;t<o.length;++t)o[t].callback.apply(o[t].thisArg,n)}if(f){f=f.slice();for(var t=0;t<f.length;++t)f[t].callback.call(f[t].thisArg,e,n)}})},on:function(n,t,r){e(n,t,r)},once:function(t,r,o){function i(){n(t,i),r.apply(this,arguments)}e(t,i,o,r)}})},i.addTo=function(e){var n=i.create();return e.on=n.on,e.once=n.once,e.off=n.off,e.trigger=n.trigger,e.ALL_EVENTS=n.ALL_EVENTS,n},i.channel=function(e){return f[e]||(f[e]=i.create()),f[e]},i.global=i.create(),n.exports=o(i)});

@@ -5,3 +5,3 @@ {

"repository": "https://github.com/grassator/happened.git",
"version": "0.9.0",
"version": "0.9.1",
"scripts": {

@@ -8,0 +8,0 @@ "test": "gulp test"

@@ -8,3 +8,3 @@ # happened

`happened` is a tiny PubSub library (~700 bytes minified and gzipped). It's designed to be an easy replacement for any other PubSub library (e.g. Backbone.Events), but also because of it's tiny size, it's a good choice for any other client-side that wants to provide events without external dependencies.
`happened` is a tiny PubSub library (~730 bytes minified and gzipped). It's designed to be an easy replacement for any other PubSub library (e.g. Backbone.Events), but also because of it's tiny size, it's a good choice for any other client-side that wants to provide events without external dependencies.

@@ -101,3 +101,3 @@ ## Examples

* Support for custom schedulers.
* Support for legacy browsers (IE6) (see [requirements](#requirements) for details)
* Support for legacy browsers like IE6-8 and Android 2.3
* Node.js support

@@ -108,8 +108,6 @@ * all `happened` instances are [frozen](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze) (immutable) if supported by environment

For synchronous usage `happened` supports any ECMAScript 5 compliant environment. This require a [shim](https://github.com/zloirock/core-js#ecmascript-5) for IE6-8 and some older Android versions.
`happened` by default uses asynchronous event dispatching. If you want events to be dispatched faster, you can use `setScheduler` to inject other schedulers, such as [setImmediate](https://github.com/YuzuJS/setImmediate) for macro-task behavior or `process.nextTick` for micro-tasks.
Async (setTimeout) mode is supported for all mainstream browsers and Node.js, but may not is some esoteric environments, like [Qt QML](http://doc.qt.io/qt-5/qtqml-javascript-hostenvironment.html).
Default async (setTimeout) mode is supported for all mainstream browsers and Node.js, but may not work in some esoteric environments, like [Qt QML](http://doc.qt.io/qt-5/qtqml-javascript-hostenvironment.html). In this it falls back to synchronous scheduler.
`happened` by default uses asynchronous event dispatching. If you want events to be dispatched faster, you can use global `setDispatcher` to inject other schedulers, such as [setImmediate](https://github.com/YuzuJS/setImmediate) for macro-task behavior or `process.nextTick` for micro-tasks.
## API

@@ -116,0 +114,0 @@

const happened = {};
const ALL_EVENTS = happened.ALL_EVENTS = '357dada3-e2a8-4966-8bd1-ea5c52752f63';
// This weird magic is manual optimization for file size
const channelMap = Object.create(null);
function syncScheduler(callback) {
callback();
}
function syncScheduler(callback) { callback(); }
function createMap() {
return Object.create ? Object.create(null) : {};
}
function freezeIfPossible(obj) {
return Object.freeze ? Object.freeze(obj) : obj;
}
const channelMap = createMap();
let defaultScheduler = (this && this.setTimeout) || syncScheduler;

@@ -48,3 +58,3 @@

happened.create = function () {
let callbackMap = Object.create(null);
let callbackMap = createMap();
let scheduler = defaultScheduler;

@@ -73,3 +83,3 @@

if (!name && !callback) {
callbackMap = Object.create(null);
callbackMap = createMap();
return;

@@ -108,3 +118,4 @@ }

}
return Object.freeze({
return freezeIfPossible({
ALL_EVENTS,

@@ -217,2 +228,2 @@ off,

export default Object.freeze(happened);
export default freezeIfPossible(happened);

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc