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

menhera

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

menhera - npm Package Compare versions

Comparing version 0.5.9-rc3 to 0.6.0

4

dist/index.js

@@ -19,4 +19,4 @@ "use strict";

exports.default = function (parms) {
return (0, _menhera.core)({ _: {}, parms: parms });
exports.default = function (_object) {
return (0, _menhera.core)({ _: {}, _object: _object });
};

@@ -12,3 +12,3 @@ "use strict";

var _ = _ref._,
parms = _ref.parms;
_object = _ref._object;

@@ -19,4 +19,6 @@ _.hooks = {};

_.$use = (0, _plugins.$use)({ _: _ });
_.$use(parms);
_.$get = (0, _plugins.$get)({ _: _ });
_.$set = (0, _plugins.$set)({ _: _ });
_.$use(_object);
return _;
};

@@ -6,3 +6,3 @@ "use strict";

});
exports._mount = exports._hooks = exports.$use = undefined;
exports._mount = exports._hooks = exports.$get = exports.$set = exports.$use = undefined;

@@ -33,3 +33,3 @@ var _regenerator = require("babel-runtime/regenerator");

var _ = _ref._;
return function (parms) {
return function (_object) {
var onVariable = function onVariable(_ref2) {

@@ -44,3 +44,3 @@ var object = _ref2.object,

hooks.length > 0 && hooks.forEach(function (h) {
return h({ _: _, _key: _key, _val: _val, cp: parms });
return h({ _: _, _key: _key, _val: _val, cp: _object });
});

@@ -59,3 +59,3 @@ };

rootHooks.length > 0 && rootHooks.forEach(function (h) {
return h({ _: _, _key: _key, _val: _val, cp: parms });
return h({ _: _, _key: _key, _val: _val, cp: _object });
});

@@ -65,3 +65,3 @@ if (eachHooks.length > 0) {

eachHooks.forEach(function (h) {
return h({ _: _, _key: key, _val: val, cp: parms });
return h({ _: _, _key: key, _val: val, cp: _object });
});

@@ -103,5 +103,4 @@ };

};
if ((typeof parms === "undefined" ? "undefined" : (0, _typeof3.default)(parms)) === "object") {
onObject({ object: parms, depth: "" });
if ((typeof _object === "undefined" ? "undefined" : (0, _typeof3.default)(_object)) === "object") {
onObject({ object: _object, depth: "" });
}

@@ -112,12 +111,72 @@ return _;

var _hooks = exports._hooks = function _hooks(_ref6) {
var _ = _ref6._,
_key = _ref6._key,
_val = _ref6._val,
cp = _ref6.cp;
var $set = exports.$set = function $set(_ref6) {
var _ = _ref6._;
return function (_object) {
var cache = {};
var onVariable = function onVariable(_ref7) {
var object = _ref7.object,
depth = _ref7.depth,
_key = _ref7._key,
_val = _ref7._val;
var onFunction = function onFunction(_ref7) {
var depth = _ref7.depth,
_val = _ref7._val;
(0, _lodash.set)(_, depth, _val);
(0, _lodash.set)(cache, depth, _val);
};
var onObject = function onObject(_ref8) {
var object = _ref8.object,
depth = _ref8.depth,
_key = _ref8._key,
_val = _ref8._val;
(0, _utils.scanObject)({ object: object, depth: depth, onObject: onObject, onVariable: onVariable });
};
if ((typeof _object === "undefined" ? "undefined" : (0, _typeof3.default)(_object)) === "object") {
onObject({ object: _object, depth: "" });
}
return cache;
};
};
var $get = exports.$get = function $get(_ref9) {
var _ = _ref9._;
return function (_object) {
var cache = {};
var onVariable = function onVariable(_ref10) {
var object = _ref10.object,
depth = _ref10.depth,
_key = _ref10._key,
_val = _ref10._val;
var result = (0, _lodash.get)(_, depth, "");
result && (0, _lodash.set)(cache, depth, result);
!result && (0, _lodash.set)(cache, depth, _val);
};
var onObject = function onObject(_ref11) {
var object = _ref11.object,
depth = _ref11.depth,
_key = _ref11._key,
_val = _ref11._val;
(0, _utils.scanObject)({ object: object, depth: depth, onObject: onObject, onVariable: onVariable });
};
if ((typeof _object === "undefined" ? "undefined" : (0, _typeof3.default)(_object)) === "object") {
onObject({ object: _object, depth: "" });
}
return cache;
};
};
var _hooks = exports._hooks = function _hooks(_ref12) {
var _ = _ref12._,
_key = _ref12._key,
_val = _ref12._val,
cp = _ref12.cp;
var onFunction = function onFunction(_ref13) {
var depth = _ref13.depth,
_val = _ref13._val;
var target = (0, _lodash.get)(_.hooks, depth, []);

@@ -129,5 +188,5 @@ if (!target.includes(_val.bind(cp))) {

};
var onVariable = function onVariable(_ref8) {
var depth = _ref8.depth,
_val = _ref8._val;
var onVariable = function onVariable(_ref14) {
var depth = _ref14.depth,
_val = _ref14._val;

@@ -142,7 +201,7 @@ if (Array.isArray(_val)) {

};
var onObject = function onObject(_ref9) {
var object = _ref9.object,
depth = _ref9.depth,
_key = _ref9._key,
_val = _ref9._val;
var onObject = function onObject(_ref15) {
var object = _ref15.object,
depth = _ref15.depth,
_key = _ref15._key,
_val = _ref15._val;

@@ -156,40 +215,41 @@ (0, _utils.scanObject)({ object: object, depth: depth, onObject: onObject, onFunction: onFunction, onVariable: onVariable });

var _mount = exports._mount = function _mount(_ref10) {
var _ = _ref10._,
_val = _ref10._val,
cp = _ref10.cp;
var _mount = exports._mount = function _mount(_ref16) {
var _ = _ref16._,
_val = _ref16._val,
cp = _ref16.cp;
if (Array.isArray(_val)) {
_val.forEach(function () {
var _ref11 = (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 cps = Array.isArray(_val) ? _val : [_val];
cps.forEach(function () {
var _ref17 = (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;
_[name] = cp;
_.$use(_[name]);
if (!_[name]) {
_context.next = 4;
break;
}
case 4:
case "end":
return _context.stop();
}
throw new Error("_mount: name \"" + name + "\" exists, please another one");
case 4:
_[name] = cp;
_.$use(_[name]);
case 6:
case "end":
return _context.stop();
}
}, _callee, undefined);
}));
}
}, _callee, undefined);
}));
return function (_x) {
return _ref11.apply(this, arguments);
};
}());
} else {
var _cp = typeof _val === "function" ? _val({ _: _ }) : _val;
var name = _cp.name;
_[name] = _cp;
_.$use(_[name]);
}
return function (_x) {
return _ref17.apply(this, arguments);
};
}());
};

@@ -8,2 +8,6 @@ "use strict";

var _regenerator = require("babel-runtime/regenerator");
var _regenerator2 = _interopRequireDefault(_regenerator);
var _typeof2 = require("babel-runtime/helpers/typeof");

@@ -17,73 +21,122 @@

var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var scanObject = exports.scanObject = function scanObject(_ref) {
var object = _ref.object,
_ref$depth = _ref.depth,
depth = _ref$depth === undefined ? null : _ref$depth,
onObject = _ref.onObject,
onFunction = _ref.onFunction,
onVariable = _ref.onVariable,
onAll = _ref.onAll;
var scanObject = exports.scanObject = function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref2) {
var object = _ref2.object,
_ref2$depth = _ref2.depth,
depth = _ref2$depth === undefined ? null : _ref2$depth,
onObject = _ref2.onObject,
onFunction = _ref2.onFunction,
onVariable = _ref2.onVariable,
onAll = _ref2.onAll;
if (object) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _ref3, _ref4, _key, _val, newDepth;
try {
for (var _iterator = Object.entries(object)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _ref2 = _step.value;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!object) {
_context.next = 22;
break;
}
var _ref3 = (0, _slicedToArray3.default)(_ref2, 2);
_iteratorNormalCompletion = true;
_didIteratorError = false;
_iteratorError = undefined;
_context.prev = 4;
var _key = _ref3[0];
var _val = _ref3[1];
for (_iterator = Object.entries(object)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
_ref3 = _step.value;
_ref4 = (0, _slicedToArray3.default)(_ref3, 2);
_key = _ref4[0];
_val = _ref4[1];
newDepth = depth ? depth + ("." + _key) : _key;
if (_val) {
var newDepth = depth ? depth + ("." + _key) : _key;
if (typeof _val === "function") {
onFunction && onFunction({
object: object,
depth: newDepth,
_key: _key,
_val: _val
});
} else if ((typeof _val === "undefined" ? "undefined" : (0, _typeof3.default)(_val)) === "object" && !Array.isArray(_val)) {
onObject && onObject({
object: object[_key],
depth: newDepth,
_key: _key,
_val: _val
});
} else {
onVariable && onVariable({
object: object,
depth: newDepth,
_key: _key,
_val: _val
});
}
onAll && onAll({ object: object, depth: depth, _key: _key, _val: _val });
if (_val) {
if (typeof _val === "function") {
onFunction && onFunction({
object: object,
depth: newDepth,
_key: _key,
_val: _val
});
} else if ((typeof _val === "undefined" ? "undefined" : (0, _typeof3.default)(_val)) === "object" && !Array.isArray(_val)) {
onObject && onObject({
object: object[_key],
depth: newDepth,
_key: _key,
_val: _val
});
} else {
onVariable && onVariable({
object: object,
depth: newDepth,
_key: _key,
_val: _val
});
}
} else {
onVariable && onVariable({ object: object, depth: newDepth, _key: _key, _val: _val });
}
onAll && onAll({ object: object, depth: depth, _key: _key, _val: _val });
}
_context.next = 12;
break;
case 8:
_context.prev = 8;
_context.t0 = _context["catch"](4);
_didIteratorError = true;
_iteratorError = _context.t0;
case 12:
_context.prev = 12;
_context.prev = 13;
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
case 15:
_context.prev = 15;
if (!_didIteratorError) {
_context.next = 18;
break;
}
throw _iteratorError;
case 18:
return _context.finish(15);
case 19:
return _context.finish(12);
case 20:
_context.next = 23;
break;
case 22:
console.warn("scanObject: object must be valid");
case 23:
case "end":
return _context.stop();
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
} else {
console.warn("scanObject: object must be valid");
}
};
}, _callee, undefined, [[4, 8, 12, 20], [13,, 15, 19]]);
}));
return function scanObject(_x) {
return _ref.apply(this, arguments);
};
}();
var getRootHookDepth = exports.getRootHookDepth = function getRootHookDepth(depth) {

@@ -90,0 +143,0 @@ return depth + "._";

{
"name": "menhera",
"version": "0.5.9-rc3",
"version": "0.6.0",
"main": "dist",

@@ -5,0 +5,0 @@ "files": [

@@ -56,11 +56,37 @@ # Menhera

![index](./assets/index.png)
```js
import { core } from "menhera";
const _ = new Menhera({
_hooks: {
foo: {
bar: {
$({ _key, _val }) {
console.log(`${_key}: ${_val}`);
}
}
}
}
});
class Foo {
constructor() {}
}
const Bar = parms => core({ _: new Foo(), parms });
_.$set({
foo: {
bar: {
test: 123
}
}
});
const _ = new Bar({});
_.$use(
_.$get({
foo: {
bar: {
test: 233,
test1: 456
}
}
})
);
```
![getset](./assets/getset.png)
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