Comparing version 0.1.2 to 0.1.3
(function(e, a) { for(var i in a) e[i] = a[i]; }(this, /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ | ||
/******/ // Create a new module (and put it into the cache) | ||
@@ -18,23 +18,23 @@ /******/ var module = installedModules[moduleId] = { | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ __webpack_require__.p = "http://localhost:5000/dist/"; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
@@ -48,5 +48,14 @@ /******/ return __webpack_require__(0); | ||
module.exports = __webpack_require__(1); | ||
/* WEBPACK VAR INJECTION */(function(global) {'use strict'; | ||
var _nflow = __webpack_require__(1); | ||
var _nflow2 = _interopRequireDefault(_nflow); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
global.nflow = _nflow2.default; | ||
module.exports = _nflow2.default; | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
/***/ }, | ||
@@ -57,20 +66,23 @@ /* 1 */ | ||
/* WEBPACK VAR INJECTION */(function(global) {'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _factory = __webpack_require__(2); | ||
var _factory2 = _interopRequireDefault(_factory); | ||
var _consts = __webpack_require__(5); | ||
var _logger = __webpack_require__(7); | ||
var _logger2 = _interopRequireDefault(_logger); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var root = (0, _factory2.default)(_consts.DEFAULTS, "flow"); | ||
_logger2.default.init(root); | ||
global.nflow = root; | ||
module.exports = root; | ||
exports.default = root; | ||
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()))) | ||
@@ -83,20 +95,20 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _behaviours = __webpack_require__(3); | ||
var behaviours = _interopRequireWildcard(_behaviours); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
exports.default = function (defaults, name, data) { | ||
var flow = defaults.factory(); | ||
defaults.behaviours.forEach(function (d) { | ||
behaviours[d](flow, defaults, name, data); | ||
}); | ||
return flow; | ||
@@ -110,9 +122,9 @@ }; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _cancellable = __webpack_require__(4); | ||
Object.defineProperty(exports, 'cancellable', { | ||
@@ -124,5 +136,5 @@ enumerable: true, | ||
}); | ||
var _connect = __webpack_require__(8); | ||
Object.defineProperty(exports, 'connect', { | ||
@@ -134,5 +146,5 @@ enumerable: true, | ||
}); | ||
var _create = __webpack_require__(9); | ||
Object.defineProperty(exports, 'create', { | ||
@@ -144,5 +156,5 @@ enumerable: true, | ||
}); | ||
var _emit = __webpack_require__(10); | ||
Object.defineProperty(exports, 'emit', { | ||
@@ -154,5 +166,5 @@ enumerable: true, | ||
}); | ||
var _identify = __webpack_require__(11); | ||
var _identify = __webpack_require__(16); | ||
Object.defineProperty(exports, 'identify', { | ||
@@ -164,5 +176,5 @@ enumerable: true, | ||
}); | ||
var _listen = __webpack_require__(12); | ||
var _listen = __webpack_require__(17); | ||
Object.defineProperty(exports, 'listen', { | ||
@@ -174,5 +186,5 @@ enumerable: true, | ||
}); | ||
var _loggable = __webpack_require__(13); | ||
var _loggable = __webpack_require__(18); | ||
Object.defineProperty(exports, 'loggable', { | ||
@@ -184,5 +196,5 @@ enumerable: true, | ||
}); | ||
var _stateful = __webpack_require__(14); | ||
var _stateful = __webpack_require__(19); | ||
Object.defineProperty(exports, 'stateful', { | ||
@@ -194,2 +206,11 @@ enumerable: true, | ||
}); | ||
var _get = __webpack_require__(20); | ||
Object.defineProperty(exports, 'get', { | ||
enumerable: true, | ||
get: function get() { | ||
return _get.default; | ||
} | ||
}); | ||
@@ -201,26 +222,26 @@ /***/ }, | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _consts = __webpack_require__(5); | ||
var _utils = __webpack_require__(6); | ||
exports.default = function (flow, defaults, name) { | ||
flow.cancel = function () { | ||
(0, _utils.assert)(arguments.length, _consts.ERRORS.invalidCancelArgs); | ||
flow.status.value = _consts.STATUS.CANCELLED; | ||
(0, _utils.dispatchInternalEvent)(flow, 'cancel', true); | ||
flow.status.value = _consts.STATUS.CANCELLED; | ||
return flow; | ||
}; | ||
flow.isCancelled = function () { | ||
return [flow].concat(flow.parents()).some(function (e) { | ||
return e.status.value == _consts.STATUS.CANCELLED; | ||
return e.status.value == _consts.STATUS.CANCELLED || e.status.value == _consts.STATUS.DISPOSED; | ||
}); | ||
}; | ||
flow.stopPropagation = function () { | ||
@@ -232,3 +253,3 @@ (0, _utils.assert)(arguments.length, _consts.ERRORS.invalidStopPropagationArgs); | ||
}; | ||
flow.propagationStopped = function () { | ||
@@ -244,3 +265,3 @@ return flow.status.value == _consts.STATUS.STOPPED; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -252,3 +273,3 @@ value: true | ||
*/ | ||
var UNSET = exports.UNSET = {}; | ||
@@ -261,3 +282,3 @@ var DIRECTION = exports.DIRECTION = { | ||
}; | ||
var STATUS = exports.STATUS = { | ||
@@ -268,5 +289,6 @@ IDLE: "IDLE", | ||
COMPLETED: "COMPLETED", | ||
CANCELLED: "CANCELLED" | ||
CANCELLED: "CANCELLED", | ||
DISPOSED: "DISPOSED" | ||
}; | ||
var DEFAULTS = exports.DEFAULTS = { | ||
@@ -289,2 +311,3 @@ factory: function factory() { | ||
invalidStatus: 'Invalid Argument. The .status() API is read only', | ||
invalidDisposeArgs: 'Invalid Argument. The .dispose() API requires no parameters', | ||
invalidCancelArgs: 'Invalid Argument. The .cancel() API requires no parameters', | ||
@@ -300,3 +323,3 @@ invalidStopPropagationArgs: 'Invalid Argument. The .stopPropagation() API requires no parameters', | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -313,15 +336,15 @@ value: true | ||
exports.dispatchInternalEvent = dispatchInternalEvent; | ||
var _factory = __webpack_require__(2); | ||
var _factory2 = _interopRequireDefault(_factory); | ||
var _consts = __webpack_require__(5); | ||
var _logger = __webpack_require__(7); | ||
var _logger2 = _interopRequireDefault(_logger); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
@@ -336,23 +359,23 @@ * utils | ||
} | ||
function isFlow(flow) { | ||
return flow && flow.name && flow.name.isFlow; | ||
} | ||
function isInternal(flow) { | ||
return flow && flow.name && flow.name.isInternal; | ||
} | ||
function detach(flow) { | ||
flow.parent() && flow.parent().children.detach(flow); | ||
} | ||
function isDetached(flow) { | ||
return !flow.parent() || !flow.parent().children.has(flow); | ||
} | ||
function flatten(array) { | ||
return [].concat.apply([], array); | ||
} | ||
function merge(source, target) { | ||
@@ -363,3 +386,3 @@ Object.keys(source).forEach(function (key) { | ||
} | ||
function dispatchInternalEvent(flow, name, newData, oldData) { | ||
@@ -376,7 +399,7 @@ var e = (0, _factory2.default)(_consts.DEFAULTS, "flow." + name); | ||
e.emit(); | ||
e.direction.value = _consts.DIRECTION.DOWNSTREAM; | ||
e.name.value = "flow.parent." + name; | ||
e.emit(); | ||
_logger2.default.log(flow, name, newData, oldData); | ||
@@ -390,20 +413,20 @@ } | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _utils = __webpack_require__(6); | ||
var _consts = __webpack_require__(5); | ||
var _factory = __webpack_require__(2); | ||
var _factory2 = _interopRequireDefault(_factory); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var devToolsEnabled = false; | ||
var loggers = []; | ||
function log(flow, name, newData, oldData) { | ||
@@ -413,14 +436,15 @@ !(0, _utils.isInternal)(flow) && loggers.forEach(function (f) { | ||
}); | ||
devToolsEnabled && debug(flow, name, newData, oldData); | ||
} | ||
function debug(flow, name, d, d0) { | ||
sendToDevTools(name, { | ||
name: d.name.value, | ||
id: d.guid.value, | ||
parentId: flow.guid.value | ||
flow: flow.toObj(), | ||
name: name, | ||
d: d && (d.toObj ? d.toObj() : d), | ||
d0: d0 && (d0.toObj ? d0.toObj() : d0) | ||
}); | ||
} | ||
function sendToDevTools(action, payload) { | ||
@@ -434,22 +458,19 @@ var eventDetail = { | ||
} | ||
function init(flow) { | ||
flow.enableDevTools = function () { | ||
var enabled = arguments.length <= 0 || arguments[0] === undefined ? _consts.UNSET : arguments[0]; | ||
if (enabled === _consts.UNSET) return devToolsEnabled; | ||
var enabled = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; | ||
devToolsEnabled = enabled; | ||
if (enabled) { | ||
sendToDevTools('start', { | ||
name: flow.name.value, | ||
id: flow.guid.value | ||
}); | ||
debug(flow, 'start', flow, flow); | ||
} | ||
return flow; | ||
}; | ||
flow.logger = function () { | ||
var logger = arguments.length <= 0 || arguments[0] === undefined ? _consts.UNSET : arguments[0]; | ||
if (logger === _consts.UNSET) return loggers; | ||
@@ -460,3 +481,3 @@ loggers.push(logger); | ||
} | ||
exports.default = { | ||
@@ -473,13 +494,13 @@ init: init, | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _utils = __webpack_require__(6); | ||
var _consts = __webpack_require__(5); | ||
exports.default = function (flow) { | ||
/** | ||
@@ -493,3 +514,3 @@ * .children() API | ||
flow.children.value = []; | ||
flow.children.has = function (matcher, recursive) { | ||
@@ -502,3 +523,3 @@ return flow.children.find(matcher, recursive) != null; | ||
flow.children.findAll = function (matcher, recursive) { | ||
var filter = matcher; | ||
@@ -512,9 +533,9 @@ if (matcher == null) return []; | ||
var children = recursive ? flow.children.all() : flow.children(); | ||
return children.filter(filter); | ||
}; | ||
flow.get = flow.children.find; | ||
flow.getAll = flow.children.find; | ||
/** | ||
@@ -527,3 +548,3 @@ * return all children recursively | ||
return getChildren(flow); | ||
function getChildren(flow) { | ||
@@ -534,7 +555,7 @@ if (childMap[flow.guid()]) return []; | ||
var gc = flow.children.value.map(getChildren); | ||
return c.concat.apply(c, gc); | ||
} | ||
}; | ||
/** | ||
@@ -545,3 +566,3 @@ * .parent() API | ||
var parent = arguments.length <= 0 || arguments[0] === undefined ? _consts.UNSET : arguments[0]; | ||
if (parent === _consts.UNSET) return flow.parent.value; | ||
@@ -556,3 +577,3 @@ parent && (0, _utils.assert)(!(0, _utils.isFlow)(parent), _consts.ERRORS.invalidParent, parent); | ||
}; | ||
flow.parents = function () { | ||
@@ -570,3 +591,3 @@ (0, _utils.assert)(arguments.length, _consts.ERRORS.invalidParents); | ||
}; | ||
flow.parents.find = function (matcher) { | ||
@@ -577,3 +598,3 @@ return flow.parents().filter(typeof matcher == "string" ? function (f) { | ||
}; | ||
flow.parents.root = function () { | ||
@@ -583,3 +604,3 @@ (0, _utils.assert)(arguments.length, _consts.ERRORS.invalidRoot); | ||
}; | ||
flow.children.detach = function (child) { | ||
@@ -590,3 +611,3 @@ flow.children.value = flow.children.value.filter(function (f) { | ||
}; | ||
function attach(parent) { | ||
@@ -603,21 +624,23 @@ parent && parent.children.value.push(flow); | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _factory = __webpack_require__(2); | ||
var _factory2 = _interopRequireDefault(_factory); | ||
var _logger = __webpack_require__(7); | ||
var _logger2 = _interopRequireDefault(_logger); | ||
var _utils = __webpack_require__(6); | ||
var _consts = __webpack_require__(5); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = function (flow, defaults) { | ||
flow.create = function (name) { | ||
@@ -627,7 +650,7 @@ for (var _len = arguments.length, data = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
} | ||
var instance = flow.get(name); | ||
if (instance) { | ||
var _instance; | ||
(_instance = instance).data.apply(_instance, data); | ||
@@ -642,3 +665,3 @@ return instance; | ||
}; | ||
flow.create.defaults = { | ||
@@ -648,4 +671,20 @@ factory: defaults.factory, | ||
direction: defaults.direction | ||
}; | ||
flow.dispose = function () { | ||
(0, _utils.assert)(arguments.length, _consts.ERRORS.invalidDisposeArgs); | ||
if (flow.status.value == _consts.STATUS.DISPOSED) return; | ||
(0, _utils.dispatchInternalEvent)(flow, 'dispose', true); | ||
flow.parent(null); | ||
flow.status.value = _consts.STATUS.DISPOSED; | ||
flow.on.listenerMap = {}; | ||
//recursively dispose all downstream nodes | ||
flow.children().forEach(function (f) { | ||
return f.dispose(); | ||
}); | ||
return flow; | ||
}; | ||
}; | ||
@@ -658,21 +697,29 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _consts = __webpack_require__(5); | ||
var _utils = __webpack_require__(6); | ||
var _logger = __webpack_require__(7); | ||
var _logger2 = _interopRequireDefault(_logger); | ||
var _routes = __webpack_require__(11); | ||
var routes = _interopRequireWildcard(_routes); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
var log = _logger2.default.log; | ||
exports.default = function (flow) { | ||
flow.status = function () { | ||
@@ -684,6 +731,6 @@ (0, _utils.assert)(arguments.length, _consts.ERRORS.invalidStatus); | ||
(0, _utils.merge)(_consts.STATUS, flow.status); | ||
flow.direction = function () { | ||
var direction = arguments.length <= 0 || arguments[0] === undefined ? _consts.UNSET : arguments[0]; | ||
if (direction === _consts.UNSET) return flow.direction.value; | ||
@@ -695,3 +742,3 @@ flow.direction.value = direction; | ||
(0, _utils.merge)(_consts.DIRECTION, flow.direction); | ||
flow.emit = function () { | ||
@@ -701,8 +748,18 @@ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
} | ||
var name = arguments.length <= 0 || arguments[0] === undefined ? _consts.UNSET : arguments[0]; | ||
return emit(name, args); | ||
}; | ||
createEmitAPI(flow); | ||
function emit() { | ||
var name = arguments.length <= 0 || arguments[0] === undefined ? _consts.UNSET : arguments[0]; | ||
var args = arguments[1]; | ||
var direction = arguments[2]; | ||
if (name == _consts.UNSET) { | ||
// emit current flow object | ||
(0, _utils.detach)(flow); | ||
direction && flow.direction(direction); | ||
log(flow, 'emit', flow); | ||
@@ -716,5 +773,5 @@ flow.emit.route(flow); | ||
name.parent(flow); | ||
//2. emit the passed in flow object | ||
(0, _utils.detach)(flow); | ||
(0, _utils.detach)(name); | ||
direction && name.direction(direction); | ||
log(name, 'emit', name); | ||
@@ -725,7 +782,8 @@ flow.emit.route(name); | ||
} | ||
(0, _utils.assert)(typeof name != 'string', _consts.ERRORS.invalidEventName); | ||
var event = flow.create.apply(flow, [name].concat(args)); | ||
var event = flow.create.apply(flow, [name].concat(_toConsumableArray(args))); | ||
(0, _utils.detach)(event); | ||
direction && event.direction(direction); | ||
log(event, 'emit', event); | ||
@@ -735,4 +793,4 @@ flow.emit.route(event); | ||
return event; | ||
}; | ||
} | ||
flow.emit.route = function (flow) { | ||
@@ -742,11 +800,11 @@ // 2. reset status | ||
flow.emit.recipientsMap = {}; | ||
flow.status.value = _consts.STATUS.FLOWING; | ||
// only keep unique recipients | ||
flow.emit.targets = flow.emit.route[flow.direction()](flow).filter(function (f) { | ||
if (flow.emit.recipientsMap[f.guid()]) return false; | ||
return flow.emit.recipientsMap[f.guid()] = true; | ||
if (flow.emit.recipientsMap[f.flow.guid()]) return false; | ||
return flow.emit.recipientsMap[f.flow.guid()] = true; | ||
}); | ||
while (flow.emit.targets.length) { | ||
@@ -756,40 +814,32 @@ var destination = flow.emit.targets.shift(); | ||
if (flow.propagationStopped()) break; | ||
if (destination.flow.isCancelled()) continue; | ||
notify(flow, destination); | ||
} | ||
}; | ||
flow.emit.route.DEFAULT = function (flow) { | ||
return (0, _utils.flatten)([flow].concat(flow.parents()).map(function (node) { | ||
if ((0, _utils.isDetached)(node) || !node.parent()) return [node].concat(node.children.all()); | ||
//TODO check circular deps | ||
return [node]; | ||
})); | ||
}; | ||
flow.emit.route.UPSTREAM = function (flow) { | ||
return [flow].concat(flow.parents()); | ||
}; | ||
flow.emit.route.DOWNSTREAM = function (flow) { | ||
return (0, _utils.flatten)([flow].concat(flow.parent()).concat(flow.parent().children.all()).filter(Boolean)); | ||
}; | ||
flow.emit.route.NONE = function (flow) { | ||
return [flow, flow.parent()]; | ||
}; | ||
flow.emit.route.DOWNSTREAM = routes.downstream; | ||
flow.emit.route.UPSTREAM = routes.upstream; | ||
flow.emit.route.DEFAULT = routes.default; | ||
flow.emit.route.NONE = routes.none; | ||
function notify(flow, currentNode) { | ||
if (currentNode.on.notifyListeners(flow)) { | ||
flow.emit.recipientsMap[currentNode.guid()] = flow.direction(); | ||
if (currentNode.flow.on.notifyListeners(flow)) { | ||
flow.emit.recipientsMap[currentNode.flow.guid()] = flow.direction(); | ||
flow.emit.recipients.push(currentNode); | ||
} | ||
} | ||
function getNextFlowDestination(currentNode, direction) { | ||
return ({ | ||
NONE: [currentNode], | ||
UPSTREAM: [currentNode.parent()], | ||
DEFAULT: [currentNode.parent()], | ||
DOWNSTREAM: currentNode.children() | ||
})[direction]; | ||
/** | ||
* create directional (eg. `flow.emit.dowsntream(...)`) API | ||
*/ | ||
function createEmitAPI(flow) { | ||
Object.keys(_consts.DIRECTION).forEach(function (direction) { | ||
flow.emit[direction] = flow.emit[direction.toLowerCase()] = function (name) { | ||
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { | ||
args[_key2 - 1] = arguments[_key2]; | ||
} | ||
return emit(name, args, direction); | ||
}; | ||
}); | ||
} | ||
@@ -803,21 +853,183 @@ }; | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _upstream = __webpack_require__(12); | ||
Object.defineProperty(exports, 'upstream', { | ||
enumerable: true, | ||
get: function get() { | ||
return _upstream.default; | ||
} | ||
}); | ||
var _none = __webpack_require__(13); | ||
Object.defineProperty(exports, 'none', { | ||
enumerable: true, | ||
get: function get() { | ||
return _none.default; | ||
} | ||
}); | ||
var _downstream = __webpack_require__(14); | ||
Object.defineProperty(exports, 'downstream', { | ||
enumerable: true, | ||
get: function get() { | ||
return _downstream.default; | ||
} | ||
}); | ||
var _default = __webpack_require__(15); | ||
Object.defineProperty(exports, 'default', { | ||
enumerable: true, | ||
get: function get() { | ||
return _default.default; | ||
} | ||
}); | ||
/***/ }, | ||
/* 12 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
* returns: all parent nodes | ||
*/ | ||
exports.default = function (flow) { | ||
return [flow].concat(flow.parents()).map(function (flow, i, arr) { | ||
return { | ||
flow: flow, | ||
route: arr.slice(0, i + 1).reverse() | ||
}; | ||
}); | ||
}; | ||
var _consts = __webpack_require__(5); | ||
/***/ }, | ||
/* 13 */ | ||
/***/ function(module, exports) { | ||
var _logger = __webpack_require__(7); | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
* returns: only itself and the node emitting it | ||
*/ | ||
exports.default = function (flow) { | ||
return [flow].concat(flow.parent()).map(function (flow, i, arr) { | ||
return { | ||
flow: flow, | ||
route: arr.slice(0, i + 1).reverse() | ||
}; | ||
}); | ||
}; | ||
var _logger2 = _interopRequireDefault(_logger); | ||
/***/ }, | ||
/* 14 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = function (flow) { | ||
var visitedNodesMap = {}; | ||
var route = getChildren(flow, []).concat(getChildren(flow.parent(), [flow])); | ||
return route; | ||
function getChildren(flow, route) { | ||
if (visitedNodesMap[flow.guid()]) return []; | ||
visitedNodesMap[flow.guid()] = true; | ||
route = [flow].concat(route); | ||
var nodes = [{ flow: flow, route: route }]; | ||
flow.children().forEach(function (f) { | ||
return nodes = nodes.concat(getChildren(f, route)); | ||
}); | ||
return nodes; | ||
} | ||
}; | ||
/***/ }, | ||
/* 15 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _utils = __webpack_require__(6); | ||
exports.default = function (flow) { | ||
var visitedNodesMap = {}; | ||
var route = []; | ||
var parents = [flow].concat(flow.parents()).map(function (flow, i, arr) { | ||
return { | ||
flow: flow, | ||
route: arr.slice(0, i) | ||
}; | ||
}); | ||
parents.forEach(function (f) { | ||
// traverse downstream on detached nodes: | ||
if ((0, _utils.isDetached)(f.flow)) { | ||
route = route.concat(getChildren(f.flow, f.route.reverse())); | ||
} else { | ||
visitedNodesMap[f.flow.guid()] = true; | ||
route.push({ flow: f.flow, route: f.route.reverse() }); | ||
} | ||
}); | ||
return route; | ||
function getChildren(flow, route) { | ||
var visited = visitedNodesMap[flow.guid()]; | ||
visitedNodesMap[flow.guid()] = true; | ||
route = [flow].concat(route); | ||
var nodes = visited ? [] : [{ flow: flow, route: route }]; | ||
flow.children().forEach(function (f) { | ||
return nodes = nodes.concat(getChildren(f, route)); | ||
}); | ||
return nodes; | ||
} | ||
}; | ||
/***/ }, | ||
/* 16 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _consts = __webpack_require__(5); | ||
var _logger = __webpack_require__(7); | ||
var _logger2 = _interopRequireDefault(_logger); | ||
var _utils = __webpack_require__(6); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var guid = 0; | ||
exports.default = function (flow, defaults, name) { | ||
flow.guid = function () { | ||
@@ -828,6 +1040,6 @@ (0, _utils.assert)(arguments.length, _consts.ERRORS.invalidGuid); | ||
flow.guid.value = "" + guid++; | ||
flow.name = function () { | ||
var name = arguments.length <= 0 || arguments[0] === undefined ? _consts.UNSET : arguments[0]; | ||
if (name === _consts.UNSET) return flow.name.value; | ||
@@ -843,3 +1055,3 @@ (0, _utils.assert)(typeof name != "string", _consts.ERRORS.invalidName, name); | ||
flow.name.isInternal = false; | ||
flow.call = function () { | ||
@@ -849,3 +1061,3 @@ for (var _len = arguments.length, functions = Array(_len), _key = 0; _key < _len; _key++) { | ||
} | ||
functions.filter(function (f) { | ||
@@ -860,25 +1072,24 @@ return typeof f == 'function'; | ||
/***/ }, | ||
/* 12 */ | ||
/* 17 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _consts = __webpack_require__(5); | ||
var _utils = __webpack_require__(6); | ||
var _logger = __webpack_require__(7); | ||
var _logger2 = _interopRequireDefault(_logger); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _typeof(obj) { return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj; } | ||
exports.default = function (flow) { | ||
var listenerMap = {}; | ||
flow.on = function () { | ||
@@ -888,26 +1099,30 @@ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
} | ||
var name = arguments.length <= 0 || arguments[0] === undefined ? _consts.UNSET : arguments[0]; | ||
if (name == _consts.UNSET) return listenerMap; //TODO clone this! | ||
if (name == _consts.UNSET) return flow.on.listenerMap; //TODO clone this! | ||
(0, _utils.assert)(typeof name != 'string', _consts.ERRORS.invalidListener); | ||
if (!args.length) { | ||
return listenerMap[name]; | ||
return flow.on.listenerMap[name]; | ||
} | ||
if (args.length == 1 && args[0] == null) { | ||
delete listenerMap[name]; | ||
(0, _utils.dispatchInternalEvent)(flow, 'listenerRemoved', name); | ||
delete flow.on.listenerMap[name]; | ||
return flow; | ||
} | ||
listenerMap[name] = args.filter(function (l) { | ||
var oldListeners = flow.on.listenerMap[name]; | ||
flow.on.listenerMap[name] = args.filter(function (l) { | ||
return !(0, _utils.assert)(typeof l != 'function', _consts.ERRORS.invalidListenerType, (typeof l === 'undefined' ? 'undefined' : _typeof(l)) + ": " + l); | ||
}); | ||
(0, _utils.dispatchInternalEvent)(flow, oldListeners ? 'listenerChanged' : 'listenerAdded', name); | ||
return flow; | ||
}; | ||
flow.on.listenerMap = {}; | ||
flow.on.notifyListeners = function (event) { | ||
if (listenerMap[event.name()]) { | ||
if (flow.on.listenerMap[event.name()]) { | ||
event.target = flow; | ||
listenerMap[event.name()].every(function (listener) { | ||
flow.on.listenerMap[event.name()].every(function (listener) { | ||
listener.apply(event, event.data.value); | ||
@@ -922,16 +1137,16 @@ return event.status() == _consts.STATUS.FLOWING; | ||
/***/ }, | ||
/* 13 */ | ||
/* 18 */ | ||
/***/ function(module, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = function (flow) { | ||
flow.toString = function () { | ||
return "{ Object Flow, name:%name }".replace("%name", flow.name()); | ||
return JSON.stringify(flow.toObj()); | ||
}; | ||
flow.toObj = function () { | ||
@@ -947,2 +1162,14 @@ return { | ||
return { name: f.name(), guid: f.guid() }; | ||
}), | ||
recipients: flow.emit.recipients && flow.emit.recipients.map(function (f) { | ||
return { | ||
flow: { | ||
guid: f.flow.guid(), | ||
name: f.flow.name() }, | ||
route: f.route.map(function (f) { | ||
return { | ||
guid: f.guid(), | ||
name: f.name() }; | ||
}) | ||
}; | ||
}) | ||
@@ -954,19 +1181,19 @@ }; | ||
/***/ }, | ||
/* 14 */ | ||
/* 19 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _logger = __webpack_require__(7); | ||
var _logger2 = _interopRequireDefault(_logger); | ||
var _utils = __webpack_require__(6); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = function (flow, defaults, name, data) { | ||
@@ -977,3 +1204,3 @@ flow.data = function () { | ||
} | ||
if (!data.length) { | ||
@@ -990,3 +1217,26 @@ return flow.data.value.length <= 1 ? flow.data.value[0] : flow.data.value; | ||
/***/ }, | ||
/* 20 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _consts = __webpack_require__(5); | ||
var _logger = __webpack_require__(7); | ||
var _logger2 = _interopRequireDefault(_logger); | ||
var _utils = __webpack_require__(6); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.default = function (flow, defaults, name) {}; | ||
/***/ } | ||
/******/ ]))); | ||
/******/ ]))); | ||
//# sourceMappingURL=nflow.js.map |
{ | ||
"name": "nflow", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "event/data/control flow", | ||
"main": "dist/nflow.js", | ||
"scripts": { | ||
"test-dev": "webpack-dev-server --config webpack.tests.config.js", | ||
"pretest": "webpack --config webpack.tests.config.js", | ||
"test": "mocha ./.test/test.node.js --reporter mocha-circleci-reporter", | ||
"start": "webpack --watch --colors", | ||
"dev": "webpack-dev-server", | ||
"start": "webpack-dev-server", | ||
"build": "webpack --watch", | ||
"pretest": "webpack", | ||
"test": "mocha ./dist/node-test.js --reporter mocha-circleci-reporter", | ||
"prepublish-to-npm": "webpack", | ||
@@ -13,0 +12,0 @@ "publish-to-npm": "publish" |
@@ -25,4 +25,7 @@ | ||
nFlow uses a single build script that compiles the code and the tests, creates a dev server and watches all source files for changes. | ||
Clone this repo and run: | ||
- `npm start` | ||
- navigate to `http://localhost:4000/webpack-dev-server/` | ||
@@ -29,0 +32,0 @@ ### Unit tests |
@@ -13,4 +13,4 @@ import { DEFAULTS | ||
, ERRORS.invalidCancelArgs) | ||
flow.status.value = STATUS.CANCELLED | ||
dispatchInternalEvent(flow, 'cancel', true) | ||
flow.status.value = STATUS.CANCELLED | ||
return flow | ||
@@ -22,3 +22,5 @@ } | ||
.concat(flow.parents()) | ||
.some(e=>e.status.value == STATUS.CANCELLED) | ||
.some(e=>e.status.value == STATUS.CANCELLED | ||
|| e.status.value == STATUS.DISPOSED | ||
) | ||
} | ||
@@ -25,0 +27,0 @@ |
import factory from '../factory' | ||
import logger from '../logger' | ||
import {assert, dispatchInternalEvent} from '../utils' | ||
import { DEFAULTS | ||
, ERRORS | ||
, STATUS | ||
, DIRECTION | ||
, UNSET } from '../consts' | ||
export default (flow, defaults)=>{ | ||
@@ -28,2 +34,18 @@ | ||
flow.dispose = (...args) => { | ||
assert(args.length | ||
, ERRORS.invalidDisposeArgs) | ||
if (flow.status.value == STATUS.DISPOSED) return; | ||
dispatchInternalEvent(flow, 'dispose', true) | ||
flow.parent(null) | ||
flow.status.value = STATUS.DISPOSED | ||
flow.on.listenerMap = {} | ||
//recursively dispose all downstream nodes | ||
flow.children().forEach(f=>f.dispose()) | ||
return flow | ||
} | ||
} |
@@ -9,2 +9,3 @@ import { DEFAULTS | ||
import logger from '../logger' | ||
import * as routes from '../routes' | ||
@@ -31,6 +32,12 @@ var log = logger.log | ||
flow.emit = (name=UNSET, ...args) => { | ||
flow.emit = (name=UNSET, ...args)=>{ | ||
return emit(name, args) | ||
} | ||
createEmitAPI(flow) | ||
function emit(name=UNSET, args, direction){ | ||
if (name==UNSET) { | ||
// emit current flow object | ||
detach(flow) | ||
direction && flow.direction(direction) | ||
log(flow, 'emit', flow) | ||
@@ -44,5 +51,5 @@ flow.emit.route(flow) | ||
name.parent(flow) | ||
//2. emit the passed in flow object | ||
detach(flow) | ||
detach(name) | ||
direction && name.direction(direction) | ||
log(name, 'emit', name) | ||
@@ -59,2 +66,3 @@ flow.emit.route(name) | ||
detach(event) | ||
direction && event.direction(direction) | ||
log(event, 'emit', event) | ||
@@ -65,3 +73,3 @@ flow.emit.route(event) | ||
} | ||
flow.emit.route = (flow)=>{ | ||
@@ -77,4 +85,4 @@ // 2. reset status | ||
.filter(f=>{ | ||
if (flow.emit.recipientsMap[f.guid()]) return false | ||
return flow.emit.recipientsMap[f.guid()] = true | ||
if (flow.emit.recipientsMap[f.flow.guid()]) return false | ||
return flow.emit.recipientsMap[f.flow.guid()] = true | ||
}) | ||
@@ -86,32 +94,15 @@ | ||
if (flow.propagationStopped()) break; | ||
if (destination.flow.isCancelled()) continue; | ||
notify(flow, destination) | ||
} | ||
} | ||
flow.emit.route.DEFAULT = (flow)=>{ | ||
return flatten([flow].concat(flow.parents()) | ||
.map((node)=>{ | ||
if (isDetached(node) | ||
|| !node.parent()) return [node] | ||
.concat(node.children.all()) | ||
//TODO check circular deps | ||
return [node] | ||
}))} | ||
flow.emit.route.UPSTREAM = (flow)=>{ | ||
return [flow].concat(flow.parents()) | ||
} | ||
flow.emit.route.DOWNSTREAM = (flow)=>{ | ||
return flatten([flow] | ||
.concat(flow.parent()) | ||
.concat(flow.parent().children.all()) | ||
.filter(Boolean) | ||
)} | ||
flow.emit.route.NONE = (flow)=>[flow, flow.parent()] | ||
flow.emit.route.DOWNSTREAM = routes.downstream | ||
flow.emit.route.UPSTREAM = routes.upstream | ||
flow.emit.route.DEFAULT = routes.default | ||
flow.emit.route.NONE = routes.none | ||
function notify(flow, currentNode){ | ||
if (currentNode.on.notifyListeners(flow)) { | ||
flow.emit.recipientsMap[currentNode.guid()] = flow.direction() | ||
if (currentNode.flow.on.notifyListeners(flow)) { | ||
flow.emit.recipientsMap[currentNode.flow.guid()] = flow.direction() | ||
flow.emit.recipients.push(currentNode) | ||
@@ -121,13 +112,17 @@ } | ||
function getNextFlowDestination(currentNode, direction){ | ||
return { | ||
NONE: [currentNode], | ||
UPSTREAM: [currentNode.parent()], | ||
DEFAULT: [currentNode.parent()], | ||
DOWNSTREAM: currentNode.children() | ||
}[direction] | ||
/** | ||
* create directional (eg. `flow.emit.dowsntream(...)`) API | ||
*/ | ||
function createEmitAPI(flow){ | ||
Object.keys(DIRECTION) | ||
.forEach(direction=>{ | ||
flow.emit[direction] | ||
= flow.emit[direction.toLowerCase()] | ||
= (name, ...args)=>{ | ||
return emit(name,args, direction) | ||
} | ||
}) | ||
} | ||
} | ||
} |
@@ -9,1 +9,2 @@ export {default as cancellable } from './cancellable' | ||
export {default as stateful } from './stateful' | ||
export {default as get } from './get' |
import { ERRORS, UNSET, STATUS } from '../consts' | ||
import {assert} from '../utils' | ||
import {assert, dispatchInternalEvent} from '../utils' | ||
import logger from '../logger' | ||
export default (flow)=>{ | ||
var listenerMap = {}; | ||
flow.on = (name=UNSET, ...args) => { | ||
if (name==UNSET) return listenerMap //TODO clone this! | ||
if (name==UNSET) return flow.on.listenerMap //TODO clone this! | ||
assert(typeof(name)!='string' | ||
@@ -13,20 +12,27 @@ , ERRORS.invalidListener) | ||
if (!args.length) { | ||
return listenerMap[name] | ||
return flow.on.listenerMap[name] | ||
} | ||
if (args.length==1 && args[0]==null) { | ||
delete listenerMap[name] | ||
dispatchInternalEvent(flow, 'listenerRemoved', name) | ||
delete flow.on.listenerMap[name] | ||
return flow; | ||
} | ||
listenerMap[name] = args | ||
var oldListeners = flow.on.listenerMap[name] | ||
flow.on.listenerMap[name] = args | ||
.filter(l=>!assert(typeof(l)!='function' | ||
, ERRORS.invalidListenerType, typeof(l)+": "+l) | ||
) | ||
dispatchInternalEvent(flow, oldListeners | ||
? 'listenerChanged' | ||
: 'listenerAdded' | ||
, name) | ||
return flow | ||
} | ||
flow.on.listenerMap = {}; | ||
flow.on.notifyListeners = (event)=>{ | ||
if (listenerMap[event.name()]) { | ||
if (flow.on.listenerMap[event.name()]) { | ||
event.target = flow | ||
listenerMap[event.name()] | ||
flow.on.listenerMap[event.name()] | ||
.every(listener=>{ | ||
@@ -33,0 +39,0 @@ listener.apply(event, event.data.value) |
export default (flow)=>{ | ||
flow.toString = () => { | ||
return "{ Object Flow, name:%name }" | ||
.replace("%name", flow.name()) | ||
return JSON.stringify(flow.toObj()) | ||
} | ||
@@ -14,4 +13,12 @@ | ||
listeners: Object.keys(flow.on()), | ||
children: flow.children().map(f=>({ name: f.name(), guid: f.guid() })) | ||
children: flow.children().map(f=>({ name: f.name(), guid: f.guid() })), | ||
recipients: flow.emit.recipients && flow.emit.recipients.map(f=>({ | ||
flow: { | ||
guid: f.flow.guid(), | ||
name: f.flow.name() }, | ||
route: f.route.map(f=>({ | ||
guid: f.guid(), | ||
name: f.name() })) | ||
})) | ||
}) | ||
} |
@@ -18,3 +18,4 @@ /** | ||
COMPLETED: "COMPLETED", | ||
CANCELLED: "CANCELLED" | ||
CANCELLED: "CANCELLED", | ||
DISPOSED: "DISPOSED" | ||
} | ||
@@ -46,2 +47,3 @@ | ||
, invalidStatus:'Invalid Argument. The .status() API is read only' | ||
, invalidDisposeArgs:'Invalid Argument. The .dispose() API requires no parameters' | ||
, invalidCancelArgs:'Invalid Argument. The .cancel() API requires no parameters' | ||
@@ -48,0 +50,0 @@ , invalidStopPropagationArgs:'Invalid Argument. The .stopPropagation() API requires no parameters' |
@@ -23,5 +23,6 @@ import {isInternal} from './utils' | ||
{ | ||
name: d.name.value, | ||
id: d.guid.value, | ||
parentId: flow.guid.value | ||
flow: flow.toObj(), | ||
name: name, | ||
d: d && (d.toObj? d.toObj():d), | ||
d0: d0 && (d0.toObj? d0.toObj():d0) | ||
}) | ||
@@ -42,10 +43,7 @@ } | ||
flow.enableDevTools = (enabled=UNSET)=>{ | ||
if (enabled===UNSET) return devToolsEnabled | ||
flow.enableDevTools = (enabled=true)=>{ | ||
devToolsEnabled = enabled | ||
if (enabled) { | ||
sendToDevTools('start', { | ||
name: flow.name.value, | ||
id: flow.guid.value | ||
}) | ||
debug(flow, 'start', flow, flow) | ||
} | ||
@@ -52,0 +50,0 @@ return flow |
@@ -1,2 +0,2 @@ | ||
import flow from 'flow' | ||
import flow from 'nflow' | ||
import assert from 'assert' | ||
@@ -92,3 +92,22 @@ import {expect} from 'chai' | ||
}) | ||
it('should not deliver events into a cancelled subtree', function(done){ | ||
function shouldCall(){ | ||
done() | ||
} | ||
function shouldNotCall(){ | ||
done('stopped event should not call listener') | ||
} | ||
var a = sut.create('a') | ||
.on('test',shouldNotCall) | ||
var b = a.create('b') | ||
.on('test',shouldNotCall) | ||
var c = sut.create('c') | ||
c.create('d') | ||
.on('test',shouldCall) | ||
a.cancel() | ||
c.emit('test') | ||
}) | ||
}) | ||
@@ -151,2 +170,4 @@ | ||
}) | ||
@@ -153,0 +174,0 @@ |
@@ -1,2 +0,2 @@ | ||
import flow from 'flow' | ||
import flow from 'nflow' | ||
import assert from 'assert' | ||
@@ -3,0 +3,0 @@ import {expect} from 'chai' |
@@ -1,2 +0,2 @@ | ||
import flow from 'flow' | ||
import flow from 'nflow' | ||
import assert from 'assert' | ||
@@ -43,2 +43,33 @@ import {expect} from 'chai' | ||
describe('.dispose() API', function(){ | ||
it('should detach disposed nodes', function(){ | ||
var sut = testFlow.create('test') | ||
sut.dispose() | ||
expect(sut.parent()).to.equal(null) | ||
}) | ||
it('should not emit events on disposed nodes', function(){ | ||
var sut1 = testFlow.create() | ||
.on('foo', ()=>{ | ||
assert.fail('should not deliver message on disposed nodes') | ||
}) | ||
sut1.dispose() | ||
sut1.emit('foo') | ||
assert.ok(sut1) | ||
}) | ||
it('should not emit events on children of disposed nodes', function(){ | ||
var sut1 = testFlow.create() | ||
sut1.dispose() | ||
sut1 | ||
.on('foo', ()=>{ | ||
assert.fail('should not deliver message on disposed nodes') | ||
}) | ||
sut1.emit('foo') | ||
assert.ok(sut1) | ||
}) | ||
}) | ||
describe('creating flow objects with data', function(){ | ||
@@ -45,0 +76,0 @@ |
@@ -1,2 +0,2 @@ | ||
import flow from 'flow' | ||
import flow from 'nflow' | ||
import assert from 'assert' | ||
@@ -3,0 +3,0 @@ import {expect} from 'chai' |
@@ -1,2 +0,2 @@ | ||
import flow from 'flow' | ||
import flow from 'nflow' | ||
import assert from 'assert' | ||
@@ -3,0 +3,0 @@ import {expect} from 'chai' |
@@ -1,2 +0,2 @@ | ||
import flow from 'flow' | ||
import flow from 'nflow' | ||
import assert from 'assert' | ||
@@ -3,0 +3,0 @@ import {expect} from 'chai' |
@@ -1,2 +0,2 @@ | ||
import flow from 'flow' | ||
import flow from 'nflow' | ||
import assert from 'assert' | ||
@@ -3,0 +3,0 @@ import {expect} from 'chai' |
@@ -8,1 +8,2 @@ import './spec/cancellation.js' | ||
import './spec/logging.js' | ||
import './spec/routes.js' |
var path = require('path'); | ||
var ExtractTextPlugin = require("extract-text-webpack-plugin"); | ||
var hostname = 'localhost' | ||
var port = '5000' | ||
module.exports = { | ||
entry: [ | ||
'./src/main.js' | ||
], | ||
entry: { | ||
'node-test': './test/node-test.js', | ||
'web-test': './test/web-test.js', | ||
'nflow': './src/' | ||
}, | ||
output: { | ||
filename: 'nflow.js', | ||
filename: '[name].js', | ||
path: path.join(__dirname, 'dist'), | ||
libraryTarget: 'this' | ||
libraryTarget: 'this', | ||
publicPath: 'http://' + hostname + ':' + port + '/dist/' | ||
}, | ||
resolve:{ | ||
root: path.resolve(__dirname, 'src'), | ||
alias:{ | ||
'nflow': 'nflow.js' | ||
} | ||
}, | ||
module: { | ||
loaders: [ | ||
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel', query: { presets: ['es2015'] }} | ||
{ test: /\.js$/ | ||
, exclude: /node_modules/ | ||
, loader: 'babel' | ||
, query: { presets: ['es2015', 'stage-0'] }}, | ||
] | ||
} | ||
}, | ||
stats: { | ||
colors: true, | ||
reasons: true | ||
}, | ||
debug: true, | ||
cache: true, | ||
devtool: 'source-map', | ||
devServer: { | ||
progress: true, | ||
contentBase: "test", | ||
host: hostname, | ||
port: port | ||
}, | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
2245246
47
21753
37
4
3