Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eroc/core

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eroc/core - npm Package Compare versions

Comparing version 0.12.1 to 0.13.1

129

dist/core.iife.js

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

/* core.js v0.8.0 2018-10-22T21:42:27.122Z licensed MIT */
/* @eroc/core v0.13.0 2018-10-30T22:21:33.784Z licensed MIT */
var Core = (function (exports) {

@@ -12,7 +12,7 @@ 'use strict';

*/
var err = function(error, message) {
const err = function (error, message) {
console.error(`${messages[error]}: "${message}"`);
};
var messages = {
const messages = {
'!start': `Could not start the given module, it's either already started and is not facory`,

@@ -25,12 +25,2 @@ '!stop': `Could not stop the given module, it's either already stopped or is not registered`,

/**
* The constructor of Sandbox
*
* @class Sandbox
* @constructor
*/
var Sandbox = function(module) {
this.module = module;
};
/**
* All notifications from sandbox

@@ -40,13 +30,15 @@ *

*/
var notifications = {};
const notifications = {};
/**
* Clear all notifications from an specific module
* The constructor of Sandbox
*
* @method clearNotifications
* @param {string} module the name of the module
* @class Sandbox
* @constructor
*/
Sandbox.clearNotifications = function(module) {
delete notifications[module];
};
const Sandbox = class {
constructor(module) {
this.module = module;
}

@@ -59,5 +51,5 @@ /**

*/
Sandbox.prototype.notify = function(notification) {
for(var module in notifications) {
var listening = notifications[module][notification.type];
notify (notification) {
for(let module in notifications) {
const listening = notifications[module][notification.type];
if(listening) {

@@ -67,3 +59,3 @@ listening.callback.call(listening.context, notification.data);

}
};
}

@@ -76,11 +68,11 @@ /**

*/
Sandbox.prototype.listen = function(notification) {
var args = Array.from(arguments);
listen(notification) {
const args = Array.from(arguments);
if(!Array.isArray(notification)) return this.addNotification.apply(this, arguments);
for(var i = 0, len = notification.length; i < len; i += 1) {
for(let i = 0, len = notification.length; i < len; i += 1) {
args[0] = notification[i];
this.addNotification.apply(this, args);
}
};
}

@@ -96,8 +88,8 @@ /**

*/
Sandbox.prototype.addNotification = function(notification, callback, context, replace) {
var addNotification = false;
addNotification(notification, callback, context, replace) {
let addNotification = false;
if(!notifications[this.module] || !notifications[this.module][notification]) {
if (!notifications[this.module] || !notifications[this.module][notification]) {
addNotification = true;
} else if(replace) {
} else if (replace) {
addNotification = true;

@@ -115,4 +107,16 @@ } else {

}
}
};
/**
* Clear all notifications from an specific module
*
* @method clearNotifications
* @param {string} module the name of the module
*/
Sandbox.clearNotifications = function(module) {
delete notifications[module];
};
/**

@@ -124,8 +128,9 @@ * The constructor of Core

*/
var CoreClass = function() {
this.modules = {};
this.moduleInstances = {};
};
/**
const CoreClass = class {
constructor() {
this.modules = {};
this.moduleInstances = {};
}
/**
* Registers a new module

@@ -137,3 +142,3 @@ *

*/
CoreClass.prototype.register = function(module, constructor, factory = false) {
register (module, constructor, factory = false) {
if(this.modules[module]) {

@@ -156,8 +161,8 @@ err('!!module', module);

*/
CoreClass.prototype.start = function(moduleName, alias = moduleName) {
start(moduleName, alias = moduleName) {
if (!moduleName) {
return this.startAll();
return this.xAll('start');
}
var moduleWrapper = this.modules[moduleName];
const moduleWrapper = this.modules[moduleName];

@@ -181,3 +186,3 @@ if (!moduleWrapper) {

return true;
};
}

@@ -190,5 +195,5 @@ /**

*/
CoreClass.prototype.stop = function(moduleName) {
stop (moduleName) {
if (!moduleName) {
return this.stopAll();
return this.xAll('stop');
}

@@ -204,4 +209,4 @@

var stopReturn;
if(instance.destroy) {
let stopReturn;
if (instance.destroy) {
stopReturn = instance.destroy();

@@ -215,23 +220,6 @@ }

return stopReturn;
};
}
/**
* Stop all started modules
*
* @method stopAll
*/
CoreClass.prototype.stopAll = function() {
this.xAll('stop');
};
/**
* Stop all started modules
*
* @method stopAll
*/
CoreClass.prototype.startAll = function() {
this.xAll('start');
};
/**
* Helper for startAll and stopAll

@@ -242,10 +230,13 @@ *

*/
CoreClass.prototype.xAll = function(method) {
for(var module in this.moduleInstances) {
if(this.modules.hasOwnProperty(module)) this[method](module);
xAll(method) {
for(let module in this.moduleInstances) {
if(this.modules.hasOwnProperty(module)) this[method](module);
}
}
};
var Core = new CoreClass();
const Core = new CoreClass();
exports.Core = Core;

@@ -252,0 +243,0 @@ exports.CoreClass = CoreClass;

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

/* core.js v0.8.0 2018-10-22T21:42:27.122Z licensed MIT */
/* @eroc/core v0.13.0 2018-10-30T22:21:33.784Z licensed MIT */
/**

@@ -9,7 +9,7 @@ * Handles error messages

*/
var err = function(error, message) {
const err = function (error, message) {
console.error(`${messages[error]}: "${message}"`);
};
var messages = {
const messages = {
'!start': `Could not start the given module, it's either already started and is not facory`,

@@ -22,12 +22,2 @@ '!stop': `Could not stop the given module, it's either already stopped or is not registered`,

/**
* The constructor of Sandbox
*
* @class Sandbox
* @constructor
*/
var Sandbox = function(module) {
this.module = module;
};
/**
* All notifications from sandbox

@@ -37,13 +27,15 @@ *

*/
var notifications = {};
const notifications = {};
/**
* Clear all notifications from an specific module
* The constructor of Sandbox
*
* @method clearNotifications
* @param {string} module the name of the module
* @class Sandbox
* @constructor
*/
Sandbox.clearNotifications = function(module) {
delete notifications[module];
};
const Sandbox = class {
constructor(module) {
this.module = module;
}

@@ -56,5 +48,5 @@ /**

*/
Sandbox.prototype.notify = function(notification) {
for(var module in notifications) {
var listening = notifications[module][notification.type];
notify (notification) {
for(let module in notifications) {
const listening = notifications[module][notification.type];
if(listening) {

@@ -64,3 +56,3 @@ listening.callback.call(listening.context, notification.data);

}
};
}

@@ -73,11 +65,11 @@ /**

*/
Sandbox.prototype.listen = function(notification) {
var args = Array.from(arguments);
listen(notification) {
const args = Array.from(arguments);
if(!Array.isArray(notification)) return this.addNotification.apply(this, arguments);
for(var i = 0, len = notification.length; i < len; i += 1) {
for(let i = 0, len = notification.length; i < len; i += 1) {
args[0] = notification[i];
this.addNotification.apply(this, args);
}
};
}

@@ -93,8 +85,8 @@ /**

*/
Sandbox.prototype.addNotification = function(notification, callback, context, replace) {
var addNotification = false;
addNotification(notification, callback, context, replace) {
let addNotification = false;
if(!notifications[this.module] || !notifications[this.module][notification]) {
if (!notifications[this.module] || !notifications[this.module][notification]) {
addNotification = true;
} else if(replace) {
} else if (replace) {
addNotification = true;

@@ -112,4 +104,16 @@ } else {

}
}
};
/**
* Clear all notifications from an specific module
*
* @method clearNotifications
* @param {string} module the name of the module
*/
Sandbox.clearNotifications = function(module) {
delete notifications[module];
};
/**

@@ -121,8 +125,9 @@ * The constructor of Core

*/
var CoreClass = function() {
this.modules = {};
this.moduleInstances = {};
};
/**
const CoreClass = class {
constructor() {
this.modules = {};
this.moduleInstances = {};
}
/**
* Registers a new module

@@ -134,3 +139,3 @@ *

*/
CoreClass.prototype.register = function(module, constructor, factory = false) {
register (module, constructor, factory = false) {
if(this.modules[module]) {

@@ -153,8 +158,8 @@ err('!!module', module);

*/
CoreClass.prototype.start = function(moduleName, alias = moduleName) {
start(moduleName, alias = moduleName) {
if (!moduleName) {
return this.startAll();
return this.xAll('start');
}
var moduleWrapper = this.modules[moduleName];
const moduleWrapper = this.modules[moduleName];

@@ -178,3 +183,3 @@ if (!moduleWrapper) {

return true;
};
}

@@ -187,5 +192,5 @@ /**

*/
CoreClass.prototype.stop = function(moduleName) {
stop (moduleName) {
if (!moduleName) {
return this.stopAll();
return this.xAll('stop');
}

@@ -201,4 +206,4 @@

var stopReturn;
if(instance.destroy) {
let stopReturn;
if (instance.destroy) {
stopReturn = instance.destroy();

@@ -212,23 +217,6 @@ }

return stopReturn;
};
}
/**
* Stop all started modules
*
* @method stopAll
*/
CoreClass.prototype.stopAll = function() {
this.xAll('stop');
};
/**
* Stop all started modules
*
* @method stopAll
*/
CoreClass.prototype.startAll = function() {
this.xAll('start');
};
/**
* Helper for startAll and stopAll

@@ -239,10 +227,13 @@ *

*/
CoreClass.prototype.xAll = function(method) {
for(var module in this.moduleInstances) {
if(this.modules.hasOwnProperty(module)) this[method](module);
xAll(method) {
for(let module in this.moduleInstances) {
if(this.modules.hasOwnProperty(module)) this[method](module);
}
}
};
var Core = new CoreClass();
const Core = new CoreClass();
export { Core, CoreClass };

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

/* core.js v0.8.0 2018-10-22T21:42:27.122Z licensed MIT */
/* @eroc/core v0.13.0 2018-10-30T22:21:33.784Z licensed MIT */
(function (global, factory) {

@@ -15,7 +15,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

*/
var err = function(error, message) {
const err = function (error, message) {
console.error(`${messages[error]}: "${message}"`);
};
var messages = {
const messages = {
'!start': `Could not start the given module, it's either already started and is not facory`,

@@ -28,12 +28,2 @@ '!stop': `Could not stop the given module, it's either already stopped or is not registered`,

/**
* The constructor of Sandbox
*
* @class Sandbox
* @constructor
*/
var Sandbox = function(module) {
this.module = module;
};
/**
* All notifications from sandbox

@@ -43,13 +33,15 @@ *

*/
var notifications = {};
const notifications = {};
/**
* Clear all notifications from an specific module
* The constructor of Sandbox
*
* @method clearNotifications
* @param {string} module the name of the module
* @class Sandbox
* @constructor
*/
Sandbox.clearNotifications = function(module) {
delete notifications[module];
};
const Sandbox = class {
constructor(module) {
this.module = module;
}

@@ -62,5 +54,5 @@ /**

*/
Sandbox.prototype.notify = function(notification) {
for(var module in notifications) {
var listening = notifications[module][notification.type];
notify (notification) {
for(let module in notifications) {
const listening = notifications[module][notification.type];
if(listening) {

@@ -70,3 +62,3 @@ listening.callback.call(listening.context, notification.data);

}
};
}

@@ -79,11 +71,11 @@ /**

*/
Sandbox.prototype.listen = function(notification) {
var args = Array.from(arguments);
listen(notification) {
const args = Array.from(arguments);
if(!Array.isArray(notification)) return this.addNotification.apply(this, arguments);
for(var i = 0, len = notification.length; i < len; i += 1) {
for(let i = 0, len = notification.length; i < len; i += 1) {
args[0] = notification[i];
this.addNotification.apply(this, args);
}
};
}

@@ -99,8 +91,8 @@ /**

*/
Sandbox.prototype.addNotification = function(notification, callback, context, replace) {
var addNotification = false;
addNotification(notification, callback, context, replace) {
let addNotification = false;
if(!notifications[this.module] || !notifications[this.module][notification]) {
if (!notifications[this.module] || !notifications[this.module][notification]) {
addNotification = true;
} else if(replace) {
} else if (replace) {
addNotification = true;

@@ -118,4 +110,16 @@ } else {

}
}
};
/**
* Clear all notifications from an specific module
*
* @method clearNotifications
* @param {string} module the name of the module
*/
Sandbox.clearNotifications = function(module) {
delete notifications[module];
};
/**

@@ -127,8 +131,9 @@ * The constructor of Core

*/
var CoreClass = function() {
this.modules = {};
this.moduleInstances = {};
};
/**
const CoreClass = class {
constructor() {
this.modules = {};
this.moduleInstances = {};
}
/**
* Registers a new module

@@ -140,3 +145,3 @@ *

*/
CoreClass.prototype.register = function(module, constructor, factory = false) {
register (module, constructor, factory = false) {
if(this.modules[module]) {

@@ -159,8 +164,8 @@ err('!!module', module);

*/
CoreClass.prototype.start = function(moduleName, alias = moduleName) {
start(moduleName, alias = moduleName) {
if (!moduleName) {
return this.startAll();
return this.xAll('start');
}
var moduleWrapper = this.modules[moduleName];
const moduleWrapper = this.modules[moduleName];

@@ -184,3 +189,3 @@ if (!moduleWrapper) {

return true;
};
}

@@ -193,5 +198,5 @@ /**

*/
CoreClass.prototype.stop = function(moduleName) {
stop (moduleName) {
if (!moduleName) {
return this.stopAll();
return this.xAll('stop');
}

@@ -207,4 +212,4 @@

var stopReturn;
if(instance.destroy) {
let stopReturn;
if (instance.destroy) {
stopReturn = instance.destroy();

@@ -218,23 +223,6 @@ }

return stopReturn;
};
}
/**
* Stop all started modules
*
* @method stopAll
*/
CoreClass.prototype.stopAll = function() {
this.xAll('stop');
};
/**
* Stop all started modules
*
* @method stopAll
*/
CoreClass.prototype.startAll = function() {
this.xAll('start');
};
/**
* Helper for startAll and stopAll

@@ -245,10 +233,13 @@ *

*/
CoreClass.prototype.xAll = function(method) {
for(var module in this.moduleInstances) {
if(this.modules.hasOwnProperty(module)) this[method](module);
xAll(method) {
for(let module in this.moduleInstances) {
if(this.modules.hasOwnProperty(module)) this[method](module);
}
}
};
var Core = new CoreClass();
const Core = new CoreClass();
exports.Core = Core;

@@ -255,0 +246,0 @@ exports.CoreClass = CoreClass;

{
"name": "@eroc/core",
"version": "0.12.1",
"version": "0.13.1",
"description": "Lightweight framework for scalable applications",

@@ -15,7 +15,7 @@ "author": "Mauricio Soares",

"files": [
"dist/core.umd.js",
"dist/core.iife.js",
"dist/core.js",
"LICENSE",
"README.md"
"dist/core.umd.js",
"dist/core.iife.js",
"dist/core.js",
"LICENSE",
"README.md"
],

@@ -38,3 +38,3 @@ "scripts": {

"rollup": "^0.66.6"
}
}
}

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

# Core.js [![Build Status](https://travis-ci.org/mauriciosoares/core.js.svg?branch=master)](https://travis-ci.org/mauriciosoares/core.js) [![Coverage Status](https://img.shields.io/coveralls/mauriciosoares/core.js.svg)](https://coveralls.io/r/mauriciosoares/core.js) [![Code Climate](https://codeclimate.com/github/mauriciosoares/core.js/badges/gpa.svg)](https://codeclimate.com/github/mauriciosoares/core.js)
# core [![Build Status](https://travis-ci.org/mauriciosoares/core.js.svg?branch=master)](https://travis-ci.org/mauriciosoares/core.js) [![Coverage Status](https://img.shields.io/coveralls/mauriciosoares/core.js.svg)](https://coveralls.io/r/mauriciosoares/core.js) [![Code Climate](https://codeclimate.com/github/mauriciosoares/core.js/badges/gpa.svg)](https://codeclimate.com/github/mauriciosoares/core.js)
__Core.js__ is a concept introduced by Nicholas C. Zakas in this [video](https://www.youtube.com/watch?v=b5pFv9NB9fs)
__core__ is a concept introduced by Nicholas C. Zakas in this [video](https://www.youtube.com/watch?v=b5pFv9NB9fs)

@@ -21,3 +21,3 @@ It helps you create scalable applications written in Javascript, giving you some structure and patterns to keep everything separated.

So let's think about the twitter page, and how we could re-build it using the __Core.js__ concept
So let's think about the twitter page, and how we could re-build it using the __core__ concept

@@ -122,3 +122,3 @@ ![Twitter Modules](https://cloud.githubusercontent.com/assets/2321259/5558085/3caa2e2c-8d00-11e4-8eba-4613b593193f.png)

author: 'Mauricio Soares',
text: 'Core.js is pretty #cool'
text: 'core is pretty #cool'
}

@@ -197,3 +197,3 @@ })

This is basically how Core.js works, below you will find the documentation of methods and parameters.
This is basically how core works, below you will find the documentation of methods and parameters.

@@ -227,3 +227,3 @@ ## Docs

#### Core.stop( moduleName )
Stops the named module. If a value is returned in the `destroy` method, it can be grabbed in the return of the method `Core.stop`
Stops the named module. If a value is returned in the `destroy` method, it can be grabbed in the return of the method `Core.stop`, If no parameters are passed, it stop all modules.

@@ -238,20 +238,2 @@ - `moduleName` (string): The name of the module

#### Core.startAll() - _deprecated_
Starts all modules. (You should use `Core.start()` with no parameters instead)
__Usage__
```js
Core.startAll();
```
#### Core.stopAll() - _deprecated_
Stops all modules. (You should use `Core.stop()` with no parameters instead)
__Usage__
```js
Core.stopAll();
```
#### sandbox.listen( notification, callback, context, force )

@@ -279,3 +261,3 @@ Listens to other modules notifications, to overwrite a notification you must use the parameter force

1. [Fork](http://help.github.com/forking/) Core.js
1. [Fork](http://help.github.com/forking/) core
2. Create a topic branch - `git checkout -b my_branch`

@@ -302,2 +284,3 @@ 3. Push to your branch - `git push origin my_branch`

* 2018-10-30 v0.13.0 remove deprecated startAll and stopAll
* 2018-10-29 v0.12.0 Drop bower and publish on npm

@@ -304,0 +287,0 @@ * 2018 Various changes

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