Comparing version 0.6.1-rc6 to 0.6.1
179
dist/core.js
@@ -29,3 +29,3 @@ "use strict"; | ||
_.hooks._hooks = { _: [_hooks] }; | ||
_.hooks._mount = { $: [_mount] }; | ||
_.symbolHooks = symbolHooks(_); | ||
_.$use = function (_object) { | ||
@@ -40,2 +40,3 @@ return $use(_, _object); | ||
}; | ||
_.$use({ _hooks: { _mount: _mount } }); | ||
_.$use(_object); | ||
@@ -64,14 +65,5 @@ return _; | ||
var rootHookDepth = (0, _utils.getRootHookDepth)(depth); | ||
var eachHookDepth = (0, _utils.getEachHookDepth)(depth); | ||
var rootHooks = (0, _lodash.get)(_.hooks, rootHookDepth, []); | ||
var eachHooks = (0, _lodash.get)(_.hooks, eachHookDepth, []); | ||
rootHooks.length > 0 && rootHooks.forEach(function (h) { | ||
return h({ _: _, _key: _key, _val: _val, cp: _object }); | ||
(0, _utils.$)(_.symbolHooks, function (key, hook) { | ||
hook({ object: object, depth: depth, _key: _key, _val: _val, _object: _object }); | ||
}); | ||
eachHooks.length > 0 && (0, _utils.$)(_val, function (key, val) { | ||
eachHooks.forEach(function (h) { | ||
return h({ _: _, _key: key, _val: val, cp: _object }); | ||
}); | ||
}); | ||
@@ -115,9 +107,3 @@ (0, _utils.scanObject)({ object: object, depth: depth, onObject: onObject, onVariable: onVariable, onFunction: onVariable }); | ||
(0, _utils.scanObject)({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onVariable: onVariable, | ||
onFunction: onFunction | ||
}); | ||
(0, _utils.scanObject)({ object: object, depth: depth, onObject: onObject, onVariable: onVariable, onFunction: onFunction }); | ||
}; | ||
@@ -161,9 +147,3 @@ if ((typeof _object === "undefined" ? "undefined" : (0, _typeof3.default)(_object)) === "object") { | ||
(0, _utils.scanObject)({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onFunction: onFunction, | ||
onVariable: onVariable | ||
}); | ||
(0, _utils.scanObject)({ object: object, depth: depth, onObject: onObject, onFunction: onFunction, onVariable: onVariable }); | ||
}; | ||
@@ -218,41 +198,124 @@ | ||
var _mount = exports._mount = function _mount(_ref13) { | ||
var _ = _ref13._, | ||
_val = _ref13._val, | ||
cp = _ref13.cp; | ||
var _mount = exports._mount = { | ||
$: function $(_ref13) { | ||
var _this = this; | ||
var cps = Array.isArray(_val) ? _val : [_val]; | ||
cps.forEach(function () { | ||
var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(component) { | ||
var cp, name; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
cp = typeof component === "function" ? component({ _: _ }) : component; | ||
name = cp.name; | ||
var _ = _ref13._, | ||
_val = _ref13._val, | ||
cp = _ref13.cp; | ||
if (!_[name]) { | ||
_context.next = 4; | ||
break; | ||
} | ||
var cps = Array.isArray(_val) ? _val : [_val]; | ||
cps.forEach(function () { | ||
var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(component) { | ||
var cp, name; | ||
return _regenerator2.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
cp = typeof component === "function" ? component({ _: _ }) : component; | ||
throw new Error("_mount: name \"" + name + "\" exists, please another one"); | ||
_.$use(cp); | ||
name = cp.name; | ||
case 4: | ||
_[name] = cp; | ||
_.$use(_[name]); | ||
if (!_[name]) { | ||
_context.next = 5; | ||
break; | ||
} | ||
case 6: | ||
case "end": | ||
return _context.stop(); | ||
throw new Error("_mount: name \"" + name + "\" exists, please another one"); | ||
case 5: | ||
_[name] = cp; | ||
case 6: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}, _callee, undefined); | ||
})); | ||
}, _callee, _this); | ||
})); | ||
return function (_x) { | ||
return _ref14.apply(this, arguments); | ||
}; | ||
}()); | ||
return function (_x) { | ||
return _ref14.apply(this, arguments); | ||
}; | ||
}()); | ||
} | ||
}; | ||
var symbolHooks = function symbolHooks(_2) { | ||
return { | ||
_: function _(_ref15) { | ||
var object = _ref15.object, | ||
depth = _ref15.depth, | ||
_key = _ref15._key, | ||
_val = _ref15._val, | ||
_object = _ref15._object; | ||
var rootHookDepth = depth + "._"; | ||
var rootHooks = (0, _lodash.get)(_2.hooks, rootHookDepth, []); | ||
rootHooks.length > 0 && rootHooks.forEach(function (h) { | ||
return h({ _: _2, _key: _key, _val: _val, cp: _object }); | ||
}); | ||
}, | ||
$: function $(_ref16) { | ||
var object = _ref16.object, | ||
depth = _ref16.depth, | ||
_key = _ref16._key, | ||
_val = _ref16._val, | ||
_object = _ref16._object; | ||
var eachHookDepth = depth + ".$"; | ||
var eachHooks = (0, _lodash.get)(_2.hooks, eachHookDepth, []); | ||
eachHooks.length > 0 && (0, _utils.$)(_val, function (key, val) { | ||
eachHooks.forEach(function (h) { | ||
return h({ _: _2, _key: key, _val: val, cp: _object }); | ||
}); | ||
}); | ||
}, | ||
$O: function $O(_ref17) { | ||
var object = _ref17.object, | ||
depth = _ref17.depth, | ||
_key = _ref17._key, | ||
_val = _ref17._val, | ||
_object = _ref17._object; | ||
var eachObjectDepth = depth + ".$O"; | ||
var eachObjects = (0, _lodash.get)(_2.hooks, eachObjectDepth, []); | ||
eachObjects.length > 0 && (0, _utils.$O)(_val, function (key, val) { | ||
eachObjects.forEach(function (h) { | ||
return h({ _: _2, _key: key, _val: val, cp: _object }); | ||
}); | ||
}); | ||
}, | ||
$F: function $F(_ref18) { | ||
var object = _ref18.object, | ||
depth = _ref18.depth, | ||
_key = _ref18._key, | ||
_val = _ref18._val, | ||
_object = _ref18._object; | ||
var eachFunctionDepth = depth + ".$F"; | ||
var eachFunctions = (0, _lodash.get)(_2.hooks, eachFunctionDepth, []); | ||
eachFunctions.length > 0 && (0, _utils.$F)(_val, function (key, val) { | ||
eachFunctions.forEach(function (h) { | ||
return h({ _: _2, _key: key, _val: val, cp: _object }); | ||
}); | ||
}); | ||
}, | ||
$V: function $V(_ref19) { | ||
var object = _ref19.object, | ||
depth = _ref19.depth, | ||
_key = _ref19._key, | ||
_val = _ref19._val, | ||
_object = _ref19._object; | ||
var eachVariableDepth = depth + ".$V"; | ||
var eachVariables = (0, _lodash.get)(_2.hooks, eachVariableDepth, []); | ||
eachVariables.length > 0 && (0, _utils.$V)(_val, function (key, val) { | ||
eachVariables.forEach(function (h) { | ||
return h({ _: _2, _key: key, _val: val, cp: _object }); | ||
}); | ||
}); | ||
} | ||
}; | ||
}; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.getEachHookDepth = exports.getRootHookDepth = exports.scanObject = exports.$ = undefined; | ||
exports.scanObject = exports.$V = exports.$F = exports.$O = exports.$ = undefined; | ||
@@ -13,2 +13,6 @@ var _regenerator = require("babel-runtime/regenerator"); | ||
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator"); | ||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | ||
var _typeof2 = require("babel-runtime/helpers/typeof"); | ||
@@ -18,6 +22,2 @@ | ||
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator"); | ||
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2); | ||
var _slicedToArray2 = require("babel-runtime/helpers/slicedToArray"); | ||
@@ -60,3 +60,27 @@ | ||
}; | ||
var $O = exports.$O = function $O(obj, cb) { | ||
$(obj, function (key, val) { | ||
if ((typeof val === "undefined" ? "undefined" : (0, _typeof3.default)(val)) === "object") { | ||
cb(key, val); | ||
} | ||
}); | ||
}; | ||
var $F = exports.$F = function $F(obj, cb) { | ||
$(obj, function (key, val) { | ||
if (typeof val === "function") { | ||
cb(key, val); | ||
} | ||
}); | ||
}; | ||
var $V = exports.$V = function $V(obj, cb) { | ||
$(obj, function (key, val) { | ||
var type = typeof val === "undefined" ? "undefined" : (0, _typeof3.default)(val); | ||
if (type !== "function" && type !== "object") { | ||
cb(key, val); | ||
} | ||
}); | ||
}; | ||
var scanObject = exports.scanObject = function () { | ||
@@ -126,10 +150,2 @@ var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref4) { | ||
}; | ||
}(); | ||
var getRootHookDepth = exports.getRootHookDepth = function getRootHookDepth(depth) { | ||
return depth + "._"; | ||
}; | ||
var getEachHookDepth = exports.getEachHookDepth = function getEachHookDepth(depth) { | ||
return depth + ".$"; | ||
}; | ||
}(); |
{ | ||
"name": "menhera", | ||
"version": "0.6.1-rc6", | ||
"version": "0.6.1", | ||
"main": "dist", | ||
@@ -19,3 +19,3 @@ "files": [ | ||
"babel-preset-stage-3": "^6.24.1", | ||
"menhera": "^0.4.5" | ||
"menhera": "^0.6.1-rc6" | ||
}, | ||
@@ -22,0 +22,0 @@ "dependencies": { |
@@ -75,9 +75,11 @@ # Menhera | ||
String: "123456", | ||
Boolean: false, | ||
Number: 123, | ||
Array: ({ tar = [1, 2, 3] }) => tar, | ||
Object: ({ tar }) => ({ | ||
Array: [1, 2, 3], | ||
Object: { | ||
1: 1, | ||
2: 2, | ||
3: 3 | ||
}) | ||
}, | ||
Function: ({ tar }) => val => val + 1 | ||
} | ||
@@ -92,5 +94,7 @@ } | ||
String: "", | ||
Boolean: ({ tar }) => !tar, | ||
Number: ({ tar }) => tar + 123333, | ||
Array: ({ tar }) => [...tar, ...[4, 5, 6]], | ||
Object: ({ tar }) => ({ ...tar, ...{ 4: 4, 5: 5, 6: 6 } }) | ||
Object: ({ tar }) => ({ ...tar, ...{ 4: 4, 5: 5, 6: 6 } }), | ||
Function: ({ tar }) => tar(123455) | ||
} | ||
@@ -97,0 +101,0 @@ } |
16923
417
105