Comparing version 0.6.6-rc1 to 0.6.6-rc2
@@ -24,3 +24,2 @@ "use strict"; | ||
_.hooks = (0, _utils.initHooks)(_); | ||
_.hooks._hooks = { _: [_utils._hooks] }; | ||
_.events = new _events.EventEmitter(); | ||
@@ -39,3 +38,2 @@ _.events.on("$use", function (_object) { | ||
}; | ||
_.$use({ _hooks: { _mount: _utils._mount } }); | ||
_.$use(_object); | ||
@@ -42,0 +40,0 @@ return _; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports._mount = exports._hooks = undefined; | ||
exports._mount = exports._hooks = exports.initHooks = undefined; | ||
@@ -33,39 +33,48 @@ var _regenerator = require("babel-runtime/regenerator"); | ||
var _hooks = exports._hooks = function _hooks(_ref) { | ||
var _ = _ref._, | ||
_val = _ref._val, | ||
cp = _ref.cp; | ||
var initHooks = exports.initHooks = function initHooks(_) { | ||
var cache = {}; | ||
cache._hooks = { _: [_hooks._] }; | ||
cache._mount = { $: [_mount.$] }; | ||
return cache; | ||
}; | ||
if ((typeof _val === "undefined" ? "undefined" : (0, _typeof3.default)(_val)) === "object") { | ||
var onFunction = function onFunction(_ref2) { | ||
var depth = _ref2.depth, | ||
_val = _ref2._val; | ||
var _hooks = exports._hooks = { | ||
_: function _(_ref) { | ||
var _ = _ref._, | ||
_val = _ref._val, | ||
cp = _ref.cp; | ||
var target = (0, _lodash2.default)(_.hooks, depth, []); | ||
if (!target.includes(_val.bind(cp))) { | ||
target.push(_val.bind(cp)); | ||
(0, _lodash4.default)(_.hooks, depth, target); | ||
} | ||
}; | ||
var onVariable = function onVariable(_ref3) { | ||
var depth = _ref3.depth, | ||
_val = _ref3._val; | ||
if ((typeof _val === "undefined" ? "undefined" : (0, _typeof3.default)(_val)) === "object") { | ||
var onFunction = function onFunction(_ref2) { | ||
var depth = _ref2.depth, | ||
_val = _ref2._val; | ||
if (Array.isArray(_val)) { | ||
_val.forEach(function (val) { | ||
if (typeof val === "function") { | ||
onFunction({ depth: depth, _val: val }); | ||
} | ||
}); | ||
} | ||
}; | ||
var onObject = function onObject(_ref4) { | ||
var object = _ref4.object, | ||
depth = _ref4.depth, | ||
_key = _ref4._key, | ||
_val = _ref4._val; | ||
var target = (0, _lodash2.default)(_.hooks, depth, []); | ||
if (!target.includes(_val.bind(cp))) { | ||
target.push(_val.bind(cp)); | ||
(0, _lodash4.default)(_.hooks, depth, target); | ||
} | ||
}; | ||
var onVariable = function onVariable(_ref3) { | ||
var depth = _ref3.depth, | ||
_val = _ref3._val; | ||
(0, _utils.scanObject)({ object: object, depth: depth, onObject: onObject, onFunction: onFunction, onVariable: onVariable }); | ||
}; | ||
onObject({ object: _val, depth: "" }); | ||
if (Array.isArray(_val)) { | ||
_val.forEach(function (val) { | ||
if (typeof val === "function") { | ||
onFunction({ depth: depth, _val: val }); | ||
} | ||
}); | ||
} | ||
}; | ||
var onObject = function onObject(_ref4) { | ||
var object = _ref4.object, | ||
depth = _ref4.depth, | ||
_key = _ref4._key, | ||
_val = _ref4._val; | ||
(0, _utils.scanObject)({ object: object, depth: depth, onObject: onObject, onFunction: onFunction, onVariable: onVariable }); | ||
}; | ||
onObject({ object: _val, depth: "" }); | ||
} | ||
} | ||
@@ -72,0 +81,0 @@ }; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.scanObject = exports.initHooks = exports.$ = undefined; | ||
exports.scanObject = exports.$ = undefined; | ||
@@ -49,8 +49,2 @@ var _regenerator = require("babel-runtime/regenerator"); | ||
var _scanHooks = require("./scanHooks"); | ||
var scanHooks = _interopRequireWildcard(_scanHooks); | ||
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 }; } | ||
@@ -89,9 +83,2 @@ | ||
}; | ||
var initHooks = exports.initHooks = function initHooks(_) { | ||
var cache = {}; | ||
$(scanHooks, function (key, val) { | ||
cache[key] = val(_); | ||
}); | ||
return cache; | ||
}; | ||
@@ -98,0 +85,0 @@ var scanObject = exports.scanObject = function () { |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _scanHooks = require("./scanHooks"); | ||
var _lodash = require("lodash.get"); | ||
@@ -23,6 +25,10 @@ | ||
var _lodash5 = require("lodash.has"); | ||
var _lodash6 = _interopRequireDefault(_lodash5); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var use = function use(_, _object) { | ||
var hooks = _.hooks["$use"]; | ||
var hooks = (0, _scanHooks.useHooks)(_); | ||
var BindHook = function BindHook(_ref) { | ||
@@ -48,2 +54,6 @@ var hook = _ref.hook, | ||
hook && BindHook(data); | ||
var validHook = (0, _lodash6.default)(_.hooks, depth); | ||
if (depth != "" && !validHook) return; | ||
(0, _utils.scanObject)({ | ||
@@ -50,0 +60,0 @@ object: object, |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.$use = undefined; | ||
exports.useHooks = undefined; | ||
@@ -21,3 +21,3 @@ var _lodash = require("lodash.get"); | ||
var $use = exports.$use = function $use(_2) { | ||
var useHooks = exports.useHooks = function useHooks(_2) { | ||
return { | ||
@@ -24,0 +24,0 @@ onAny: { |
{ | ||
"name": "menhera", | ||
"version": "0.6.6-rc1", | ||
"version": "0.6.6-rc2", | ||
"main": "dist", | ||
@@ -10,3 +10,3 @@ "files": [ | ||
"example": "babel-node ./example/index", | ||
"build": "rm -rf dist/; babel ./src --out-dir dist", | ||
"build": "babel ./src --out-dir dist", | ||
"prepublishOnly": "npm run build" | ||
@@ -23,5 +23,8 @@ }, | ||
"dependencies": { | ||
"@types/lodash.get": "^4.4.3", | ||
"@types/lodash.set": "^4.3.3", | ||
"lodash.get": "^4.4.2", | ||
"lodash.has": "^4.5.2", | ||
"lodash.set": "^4.3.2" | ||
} | ||
} |
@@ -0,0 +0,0 @@ # Menhera |
23972
617
5
+ Added@types/lodash.get@^4.4.3
+ Added@types/lodash.set@^4.3.3
+ Addedlodash.has@^4.5.2
+ Added@types/lodash@4.17.13(transitive)
+ Added@types/lodash.get@4.4.9(transitive)
+ Added@types/lodash.set@4.3.9(transitive)
+ Addedlodash.has@4.5.2(transitive)