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.7.5 to 0.7.6-rc1

702

dist/index.js

@@ -10,2 +10,3 @@ 'use strict';

var lhas = _interopDefault(require('lodash.has'));
var uuid = _interopDefault(require('uuid'));
var events = require('events');

@@ -31,2 +32,14 @@

function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}
function _arrayWithHoles(arr) {

@@ -36,2 +49,6 @@ if (Array.isArray(arr)) return arr;

function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _iterableToArrayLimit(arr, i) {

@@ -63,2 +80,6 @@ var _arr = [];

function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
function _nonIterableRest() {

@@ -68,45 +89,211 @@ throw new TypeError("Invalid attempt to destructure non-iterable instance");

var useHooks = function useHooks(_2) {
return {
onAny: {
any: function any(_ref) {
var object = _ref.object,
parentDepth = _ref.parentDepth,
depth = _ref.depth,
_key = _ref._key,
_val = _ref._val,
_object = _ref._object;
var key = "".concat(depth);
var hooks = get(_2[HOOKS], key, []);
hooks.length > 0 && hooks.forEach(function (h) {
return h({
_: _2,
_key: _key,
_val: _val,
cp: _object
});
var _hooks = {
_: function _(_ref) {
var _2 = _ref._,
_val = _ref._val,
cp = _ref.cp;
var uuid$$1 = cp.uuid;
if (_typeof(_val) === 'object') {
var onFunction = function onFunction(_ref2) {
var depth = _ref2.depth,
_val = _ref2._val;
var target = get(_2[HOOKS], depth);
if (!target) {
target = new Map([[uuid$$1, _val.bind(cp)]]);
set$1(_2[HOOKS], depth, target);
} else {
target.set(uuid$$1, _val.bind(cp));
}
};
var onArray = function onArray(_ref3) {
var depth = _ref3.depth,
_val = _ref3._val;
var target = get(_2[HOOKS], depth);
_val = new Set(_val.map(function (v) {
return v.bind(cp);
}));
if (!target) {
target = new Map([[uuid$$1, _val]]);
set$1(_2[HOOKS], depth, target);
} else {
target.set(uuid$$1, _val);
}
};
var onObject = function onObject(_ref4) {
var object = _ref4.object,
depth = _ref4.depth,
_key = _ref4._key,
_val = _ref4._val;
scanObject({
object: object,
depth: depth,
onObject: onObject,
onFunction: onFunction,
onArray: onArray
});
},
_: function _(_ref2) {
var object = _ref2.object,
depth = _ref2.depth,
_key = _ref2._key,
_val = _ref2._val,
_object = _ref2._object;
};
var __ = "".concat(depth, "._");
onObject({
object: _val,
depth: ''
});
}
}
};
var _unhooks = {
_: function _(_ref5) {
var _3 = _ref5._,
_val = _ref5._val,
cp = _ref5.cp;
var uuid$$1 = cp.uuid;
var hooks = get(_2[HOOKS], __, []);
hooks.length > 0 && hooks.forEach(function (h) {
return h({
_: _2,
_key: _key,
_val: _val,
cp: _object
});
if (_typeof(_val) === 'object') {
var onFunction = function onFunction(_ref6) {
var depth = _ref6.depth,
_val = _ref6._val;
var target = get(_3[HOOKS], depth);
if (!target) return;
target.delete(uuid$$1);
};
var onObject = function onObject(_ref7) {
var object = _ref7.object,
depth = _ref7.depth,
_key = _ref7._key,
_val = _ref7._val;
scanObject({
object: object,
depth: depth,
onObject: onObject,
onFunction: onFunction
});
};
onObject({
object: _val,
depth: ''
});
}
}
};
var _mount = {
$: function $$$1(_ref8) {
var _ = _ref8._,
_val = _ref8._val,
cp = _ref8.cp;
var cps = Array.isArray(_val) ? _val : [_val];
$(cps, function (key, component) {
var cp = typeof component === 'function' ? component({
_: _
}) : component;
var name = cp.name;
if (_[name]) {
console.log("_mount: name \"".concat(name, "\" exists"));
return;
}
},
onObject: {
O: function O(_ref3) {
_.$use(cp);
_[name] = cp;
});
}
};
var hooks = /*#__PURE__*/Object.freeze({
_hooks: _hooks,
_unhooks: _unhooks,
_mount: _mount
});
var compose = function compose(middleware) {
return function (ctx, next) {
var index = -1;
return dispatch(0);
function dispatch(i) {
if (i <= index) return Promise.reject(new Error('next() called multiple times'));
index = i;
var fn = middleware[i];
if (i === middleware.length) fn = next;
if (!fn) return Promise.resolve();
try {
return Promise.resolve(fn(ctx, function () {
return dispatch(i + 1);
}));
} catch (e) {
return Promise.reject(e);
}
}
};
};
var handleHooks = function handleHooks(_ref) {
var object = _ref.object,
depth = _ref.depth,
key = _ref.key,
_key = _ref._key,
_ = _ref._,
_val = _ref._val,
_object = _ref._object;
var hooks = get(_[HOOKS], key);
hooks && $M(hooks, function (uuid$$1, h) {
if (h instanceof Set) {
var fns = compose(_toConsumableArray(h));
console.log(fns);
fns({
depth: depth,
_: _,
_key: _key,
_val: _val,
cp: _object
});
return;
}
h({
depth: depth,
_: _,
_key: _key,
_val: _val,
cp: _object,
parent: object
});
});
};
var handleEachHooks = function handleEachHooks(_ref2) {
var object = _ref2.object,
depth = _ref2.depth,
_ = _ref2._,
key = _ref2.key,
_key = _ref2._key,
_val = _ref2._val,
_object = _ref2._object;
var hooks = get(_[HOOKS], key);
hooks && $(_val, function (key, val) {
$M(hooks, function (uuid$$1, h) {
return h({
depth: depth,
_: _,
_key: key,
_val: val,
cp: _object,
parent: object
});
});
});
};
var useHooks = function useHooks(_2) {
return {
onAny: {
any: function any(_ref3) {
var object = _ref3.object,

@@ -118,14 +305,15 @@ parentDepth = _ref3.parentDepth,

_object = _ref3._object;
var key = "".concat(depth, ".O");
var hooks = get(_2[HOOKS], key, []);
hooks.length > 0 && hooks.forEach(function (h) {
return h({
_: _2,
_key: _key,
_val: _val,
cp: _object
});
if (_typeof(_val) === 'object') return;
var key = "".concat(depth);
handleHooks({
object: object,
depth: depth,
key: key,
_: _2,
_key: _key,
_val: _val,
_object: _object
});
},
$: function $$$1(_ref4) {
_: function _(_ref4) {
var object = _ref4.object,

@@ -136,17 +324,18 @@ depth = _ref4.depth,

_object = _ref4._object;
var key = "".concat(depth, ".$");
var hooks = get(_2[HOOKS], key, []);
hooks.length > 0 && $(_val, function (key, val) {
hooks.forEach(function (h) {
return h({
_: _2,
_key: key,
_val: val,
cp: _object
});
});
var key = "".concat(depth, "._");
handleHooks({
object: object,
depth: depth,
key: key,
_: _2,
_key: _key,
_val: _val,
_object: _object
});
},
O$: function O$(_ref5) {
}
},
onObject: {
O: function O(_ref5) {
var object = _ref5.object,
parentDepth = _ref5.parentDepth,
depth = _ref5.depth,

@@ -156,18 +345,15 @@ _key = _ref5._key,

_object = _ref5._object;
var key = "".concat(depth, ".O$");
var hooks = get(_2[HOOKS], key, []);
hooks.length > 0 && $(_val, function (key, val) {
hooks.forEach(function (h) {
return h({
_: _2,
_key: key,
_val: val,
cp: _object
});
});
var key = "".concat(depth, ".O");
handleHooks({
object: object,
depth: depth,
key: key,
_: _2,
_key: _key,
_val: _val,
_object: _object
});
},
$O: function $O(_ref6) {
$: function $$$1(_ref6) {
var object = _ref6.object,
parentDepth = _ref6.parentDepth,
depth = _ref6.depth,

@@ -177,18 +363,14 @@ _key = _ref6._key,

_object = _ref6._object;
var key = "".concat(parentDepth, ".$O");
var $hooks = get(_2[HOOKS], key, []);
$hooks.length > 0 && $hooks.forEach(function (h) {
return h({
_: _2,
_key: _key,
_val: _val,
cp: _object
});
var key = "".concat(depth, ".$");
handleEachHooks({
object: object,
depth: depth,
key: key,
_: _2,
_val: _val,
_object: _object
});
}
},
onArray: {
A: function A(_ref7) {
},
O$: function O$(_ref7) {
var object = _ref7.object,
parentDepth = _ref7.parentDepth,
depth = _ref7.depth,

@@ -198,14 +380,13 @@ _key = _ref7._key,

_object = _ref7._object;
var key = "".concat(depth, ".A");
var hooks = get(_2[HOOKS], key, []);
hooks.length > 0 && hooks.forEach(function (h) {
return h({
_: _2,
_key: _key,
_val: _val,
cp: _object
});
var key = "".concat(depth, ".O$");
handleEachHooks({
object: object,
depth: depth,
key: key,
_: _2,
_val: _val,
_object: _object
});
},
A$: function A$(_ref8) {
$O: function $O(_ref8) {
var object = _ref8.object,

@@ -217,16 +398,16 @@ parentDepth = _ref8.parentDepth,

_object = _ref8._object;
var key = "".concat(depth, ".A$");
var hooks = get(_2[HOOKS], key, []);
hooks.length > 0 && $(_val, function (key, val) {
hooks.forEach(function (h) {
return h({
_: _2,
_key: key,
_val: val,
cp: _object
});
});
var key = "".concat(parentDepth, ".$O");
handleHooks({
object: object,
depth: depth,
key: key,
_: _2,
_key: _key,
_val: _val,
_object: _object
});
},
$A: function $A(_ref9) {
}
},
onArray: {
A: function A(_ref9) {
var object = _ref9.object,

@@ -238,16 +419,14 @@ parentDepth = _ref9.parentDepth,

_object = _ref9._object;
var key = "".concat(parentDepth, ".$A");
var $hooks = get(_2[HOOKS], key, []);
$hooks.length > 0 && $hooks.forEach(function (h) {
return h({
_: _2,
_key: _key,
_val: _val,
cp: _object
});
var key = "".concat(depth, ".A");
handleHooks({
object: object,
depth: depth,
key: key,
_: _2,
_key: _key,
_val: _val,
_object: _object
});
}
},
onFunction: {
F: function F(_ref10) {
},
A$: function A$(_ref10) {
var object = _ref10.object,

@@ -259,14 +438,13 @@ parentDepth = _ref10.parentDepth,

_object = _ref10._object;
var key = "".concat(depth, ".F");
var hooks = get(_2[HOOKS], key, []);
hooks.length > 0 && hooks.forEach(function (h) {
return h({
_: _2,
_key: _key,
_val: _val,
cp: _object
});
var key = "".concat(depth, ".A$");
handleEachHooks({
object: object,
depth: depth,
key: key,
_: _2,
_val: _val,
_object: _object
});
},
$F: function $F(_ref11) {
$A: function $A(_ref11) {
var object = _ref11.object,

@@ -278,16 +456,16 @@ parentDepth = _ref11.parentDepth,

_object = _ref11._object;
var key = "".concat(parentDepth, ".$F");
var $hooks = get(_2[HOOKS], key, []);
$hooks.length > 0 && $hooks.forEach(function (h) {
return h({
_: _2,
_key: _key,
_val: _val,
cp: _object
});
var key = "".concat(parentDepth, ".$A");
handleHooks({
object: object,
depth: depth,
key: key,
_: _2,
_key: _key,
_val: _val,
_object: _object
});
}
},
onVariable: {
V: function V(_ref12) {
onFunction: {
F: function F(_ref12) {
var object = _ref12.object,

@@ -299,14 +477,14 @@ parentDepth = _ref12.parentDepth,

_object = _ref12._object;
var key = "".concat(depth, ".V");
var hooks = get(_2[HOOKS], key, []);
hooks.length > 0 && hooks.forEach(function (h) {
return h({
_: _2,
_key: _key,
_val: _val,
cp: _object
});
var key = "".concat(depth, ".F");
handleHooks({
object: object,
depth: depth,
key: key,
_: _2,
_key: _key,
_val: _val,
_object: _object
});
},
$V: function $V(_ref13) {
$F: function $F(_ref13) {
var object = _ref13.object,

@@ -318,11 +496,49 @@ parentDepth = _ref13.parentDepth,

_object = _ref13._object;
var key = "".concat(parentDepth, ".$F");
handleHooks({
object: object,
depth: depth,
key: key,
_: _2,
_key: _key,
_val: _val,
_object: _object
});
}
},
onVariable: {
V: function V(_ref14) {
var object = _ref14.object,
parentDepth = _ref14.parentDepth,
depth = _ref14.depth,
_key = _ref14._key,
_val = _ref14._val,
_object = _ref14._object;
var key = "".concat(depth, ".V");
handleHooks({
object: object,
depth: depth,
key: key,
_: _2,
_key: _key,
_val: _val,
_object: _object
});
},
$V: function $V(_ref15) {
var object = _ref15.object,
parentDepth = _ref15.parentDepth,
depth = _ref15.depth,
_key = _ref15._key,
_val = _ref15._val,
_object = _ref15._object;
var key = "".concat(parentDepth, ".$V");
var $hooks = get(_2[HOOKS], key, []);
$hooks.length > 0 && $hooks.forEach(function (h) {
return h({
_: _2,
_key: _key,
_val: _val,
cp: _object
});
handleHooks({
object: object,
depth: depth,
key: key,
_: _2,
_key: _key,
_val: _val,
_object: _object
});

@@ -336,2 +552,3 @@ }

var $use$$1 = function $use$$1(_, _object) {
!_object.uuid && (_object.uuid = uuid.v1());
var hooks = useHooks(_);

@@ -348,5 +565,5 @@

if (depth != "" && !validHook) return;
var _hooks$$1 = hooks[hook];
_hooks$$1 && $(_hooks$$1, function (key, hook) {
hook({
var _hooks = hooks[hook];
_hooks && $(_hooks, function (key, shook) {
shook({
hook: hook,

@@ -397,2 +614,11 @@ object: object,

};
var $unuse$$1 = function $unuse$$1(_, _object) {
var uuid$$1 = _object.uuid,
_hooks = _object._hooks;
$use$$1(_, {
uuid: uuid$$1,
_unhooks: _hooks
});
return _;
};
var $run$$1 = function $run$$1(_method, _, _object) {

@@ -702,3 +928,4 @@ if (!_method) {

return cache;
};
}; //
var _matchSimple$$1 = function _matchSimple$$1(_, _array) {

@@ -865,92 +1092,18 @@ console.log(JSON.stringify(_array));

var initHooks$$1 = function initHooks$$1() {
var matchSlashPath = /\//g;
var matchPath = /\/|\./;
var initHooks = function initHooks() {
var cache = {};
cache._hooks = {
_: [_hooks$$1._]
};
cache._mount = {
$: [_mount$$1.$]
};
return cache;
};
var _hooks$$1 = {
_: function _(_ref) {
var _2 = _ref._,
_val = _ref._val,
cp = _ref.cp;
if (_typeof(_val) === "object") {
var onFunction = function onFunction(_ref2) {
var depth = _ref2.depth,
_val = _ref2._val;
var target = get(_2[HOOKS], depth, []); // if (!target.includes(_val.bind(cp))) {
var _uuid = uuid.v1();
target.push(_val.bind(cp));
set$1(_2[HOOKS], depth, target); // }
};
$(hooks, function (key, val) {
$(val, function (hookKey, hookVal) {
var _val = new Map().set(_uuid, hookVal);
var onVariable = function onVariable(_ref3) {
var depth = _ref3.depth,
_val = _ref3._val;
if (Array.isArray(_val)) {
$(_val, function (key, 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;
scanObject({
object: object,
depth: depth,
onObject: onObject,
onFunction: onFunction,
onVariable: onVariable
});
};
onObject({
object: _val,
depth: ""
});
}
}
};
var _mount$$1 = {
$: function $$$1(_ref5) {
var _ = _ref5._,
_val = _ref5._val,
cp = _ref5.cp;
var cps = Array.isArray(_val) ? _val : [_val];
$(cps, function (key, component) {
var cp = typeof component === "function" ? component({
_: _
}) : component;
var name = cp.name;
if (_[name]) {
console.log("_mount: name \"".concat(name, "\" exists"));
return;
}
_.$use(cp);
_[name] = cp;
set$1(cache, "".concat(key, ".").concat(hookKey), _val);
});
}
});
return cache;
};
var matchSlashPath = /\//g;
var matchPath = /\/|\./;
var get = function get(obj, path, def) {

@@ -995,2 +1148,30 @@ if (matchSlashPath.test(path)) {

};
var $M = function $M(map, cb) {
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = map[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var _step$value = _slicedToArray(_step.value, 2),
key = _step$value[0],
val = _step$value[1];
cb(key, val);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return != null) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
};
var scanObject = function scanObject(_ref) {

@@ -1076,3 +1257,3 @@ var object = _ref.object,

var $core = function $core(_, _object) {
_[HOOKS] = initHooks$$1(_);
_[HOOKS] = initHooks(_);
_._events = new events.EventEmitter();

@@ -1090,2 +1271,12 @@

_._events.on("$unuse", function (_object) {
return $unuse$$1(_, _object);
});
_.$unuse = function (_object) {
_._events.emit("$unuse", _object);
return _;
};
_.$use(_object);

@@ -1099,2 +1290,3 @@

exports.uuid = uuid;
exports.$core = $core;

@@ -1104,2 +1296,3 @@ exports.default = index;

exports.matchPath = matchPath;
exports.initHooks = initHooks;
exports.get = get;

@@ -1110,5 +1303,7 @@ exports.set = set$1;

exports.$ = $;
exports.$M = $M;
exports.scanObject = scanObject;
exports.$str = $str$$1;
exports.$use = $use$$1;
exports.$unuse = $unuse$$1;
exports.$run = $run$$1;

@@ -1138,4 +1333,1 @@ exports._setSimple = _setSimple$$1;

exports._scanSimple = _scanSimple$$1;
exports.initHooks = initHooks$$1;
exports._hooks = _hooks$$1;
exports._mount = _mount$$1;
{
"name": "menhera",
"version": "0.7.5",
"version": "0.7.6-rc1",
"main": "dist/index.js",

@@ -14,4 +14,5 @@ "license": "MIT",

"devDependencies": {
"@types/uuid": "^3.4.3",
"bili": "^3.1.0",
"menhera": "^0.7.4-rc1",
"menhera": "^0.7.5-rc4",
"menhera-cli": "^0.3.1-rc2"

@@ -22,4 +23,5 @@ },

"lodash.has": "^4.5.2",
"lodash.set": "^4.3.2"
"lodash.set": "^4.3.2",
"uuid": "^3.2.1"
}
}

@@ -20,12 +20,8 @@ # Menhera

bar: {
foo1: {
bar1: {
test: ({ _val }) => console.log(_val),
testFn: ({ _val }) => console.log(_val())
}
}
test: ({ _val }) => console.log(_val),
testFn: ({ _val }) => console.log(_val())
}
}
},
"foo.bar.foo1.bar1": {
"foo.bar": {
test: "foo bar",

@@ -32,0 +28,0 @@ testFn: () => "foo bar"

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