Comparing version 0.9.0 to 0.9.1-rc1
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
@@ -234,2 +236,84 @@ | ||
var inject = { | ||
injectVar: function injectVar(name) { | ||
return { | ||
$V: function $V(_ref) { | ||
var _key = _ref._key, | ||
_val = _ref._val; | ||
var key = "".concat(name, ".").concat(_key); | ||
set$1(core, key, _val); | ||
} | ||
}; | ||
}, | ||
injectFn: function injectFn(name) { | ||
return { | ||
$F: function $F(_ref2) { | ||
var _key = _ref2._key, | ||
_val = _ref2._val; | ||
var key = "".concat(name, ".").concat(_key); | ||
set$1(core, key, _val); | ||
} | ||
}; | ||
}, | ||
injectFunctionArray: function injectFunctionArray(name) { | ||
return { | ||
F: function F(_ref3) { | ||
var _val = _ref3._val; | ||
var target = get(core, name, []); | ||
set$1(core, name, _toConsumableArray(target).concat([_val])); | ||
} | ||
}; | ||
}, | ||
injectObject: function injectObject(name) { | ||
return { | ||
O: function O(_ref4) { | ||
var _val = _ref4._val; | ||
var target = get(core, name, {}); | ||
set$1(core, name, Object.assign({}, target, _val)); | ||
} | ||
}; | ||
}, | ||
injectObjectArray: function injectObjectArray(name) { | ||
return { | ||
$: function $$$1(_ref5) { | ||
var _key = _ref5._key, | ||
_val = _ref5._val; | ||
var key = "".concat(name, ".").concat(_key); | ||
var target = get(core, key, []); | ||
set$1(core, key, _toConsumableArray(target).concat(_toConsumableArray(_val))); | ||
} | ||
}; | ||
}, | ||
injectObjectDeep: function injectObjectDeep(name) { | ||
return { | ||
$O: function $O(_ref6) { | ||
var _key = _ref6._key, | ||
_val = _ref6._val; | ||
var key = "".concat(name, ".").concat(_key); | ||
var target = get(core, key, {}); | ||
set$1(core, key, Object.assign({}, target, _val)); | ||
} | ||
}; | ||
}, | ||
injectVariableDeep: function injectVariableDeep(name) { | ||
return { | ||
$V: function $V(_ref7) { | ||
var _key = _ref7._key, | ||
_val = _ref7._val; | ||
var key = "".concat(name, ".").concat(_key); | ||
set$1(core, key, _val); | ||
} | ||
}; | ||
}, | ||
injectArray: function injectArray(name) { | ||
return { | ||
_: function _(_ref8) { | ||
var _val = _ref8._val; | ||
var target = get(core, name, []); | ||
set$1(core, name, _toConsumableArray(target).concat(_toConsumableArray(_val))); | ||
} | ||
}; | ||
} | ||
}; | ||
var $str$$1 = JSON.stringify; | ||
@@ -255,7 +339,5 @@ var $compile$$1 = function $compile$$1(_, _object) { | ||
if (Array.isArray(_object)) { | ||
var cache = []; | ||
$(_object, function (key, val) { | ||
cache[key] = _method(_, val); | ||
return _object.map(function (val) { | ||
return _method(_, val); | ||
}); | ||
return cache; | ||
} | ||
@@ -321,3 +403,474 @@ | ||
}; | ||
var $unuse$$1 = function $unuse$$1(_, _object) { | ||
return $exec$$1(_unuse$$1, _, _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 _setSimple$$1 = function _setSimple$$1(_, _object) { | ||
var cache = {}; | ||
var onVariable = function onVariable(_ref2) { | ||
var object = _ref2.object, | ||
depth = _ref2.depth, | ||
_key = _ref2._key, | ||
_val = _ref2._val; | ||
if (matchPath.test(_val)) { | ||
var result = get(_, _val); | ||
set$1(_, depth, result); | ||
set$1(cache, depth, result); | ||
} else { | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
} | ||
return; | ||
}; | ||
var onFunction = function onFunction(_ref3) { | ||
var object = _ref3.object, | ||
depth = _ref3.depth, | ||
_key = _ref3._key, | ||
_val = _ref3._val; | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
return; | ||
}; | ||
var onObject = function onObject(_ref4) { | ||
var object = _ref4.object, | ||
depth = _ref4.depth, | ||
_key = _ref4._key, | ||
_val = _ref4._val; | ||
if (Object.keys(object).length === 0) { | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
return; | ||
} | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onVariable: onVariable, | ||
onFunction: onFunction, | ||
onArray: onVariable | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return cache; | ||
}; | ||
var _setAdvanced$$1 = function _setAdvanced$$1(_, _object) { | ||
var cache = {}; | ||
var onVariable = function onVariable(_ref5) { | ||
var object = _ref5.object, | ||
depth = _ref5.depth, | ||
_key = _ref5._key, | ||
_val = _ref5._val; | ||
if (matchPath.test(_val)) { | ||
var result = get(_, _val); | ||
set$1(_, depth, result); | ||
set$1(cache, depth, result); | ||
} else { | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
} | ||
return; | ||
}; | ||
var onFunction = function onFunction(_ref6) { | ||
var object = _ref6.object, | ||
depth = _ref6.depth, | ||
_key = _ref6._key, | ||
_val = _ref6._val; | ||
var tar = get(_, depth); | ||
var result = _val({ | ||
tar: tar | ||
}); | ||
set$1(_, depth, result); | ||
set$1(cache, depth, result); | ||
return; | ||
}; | ||
var onObject = function onObject(_ref7) { | ||
var object = _ref7.object, | ||
depth = _ref7.depth, | ||
_key = _ref7._key, | ||
_val = _ref7._val; | ||
if (Object.keys(object).length === 0) { | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
return; | ||
} | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onVariable: onVariable, | ||
onFunction: onFunction, | ||
onArray: onVariable | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return cache; | ||
}; | ||
var setMethods$$1 = { | ||
simple: _setSimple$$1, | ||
advanced: _setAdvanced$$1 | ||
}; | ||
var $set$$1 = function $set$$1(_, _object) { | ||
var _ref8 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref8$type = _ref8.type, | ||
type = _ref8$type === void 0 ? 'simple' : _ref8$type; | ||
return $exec$$1(setMethods$$1[type], _, _object); | ||
}; | ||
var $merge$$1 = function $merge$$1(_array, options) { | ||
var cache = {}; | ||
$(_array, function (key, val) { | ||
$set$$1(cache, val, options); | ||
}); | ||
return cache; | ||
}; | ||
var $get$$1 = function $get$$1(_, _object) { | ||
return $exec$$1(_get$$1, _, _object); | ||
}; | ||
var _get$$1 = function _get$$1(_, args) { | ||
var cache = {}; | ||
var onVariable = function onVariable(_ref9) { | ||
var object = _ref9.object, | ||
depth = _ref9.depth, | ||
_key = _ref9._key, | ||
_val = _ref9._val; | ||
var result; | ||
if (matchPath.test(_val)) { | ||
result = get(_, _val); | ||
result && set$1(cache, depth, result); | ||
} else { | ||
result = get(_, depth); | ||
result && set$1(cache, depth, result); | ||
!result && set$1(cache, depth, _val); | ||
} | ||
return; | ||
}; | ||
var onFunction = function onFunction(_ref10) { | ||
var object = _ref10.object, | ||
depth = _ref10.depth, | ||
_key = _ref10._key, | ||
_val = _ref10._val; | ||
var tar = get(_, depth); | ||
var result = _val({ | ||
tar: tar | ||
}); | ||
result && set$1(cache, depth, result); | ||
!result && set$1(cache, depth, _val); | ||
return; | ||
}; | ||
var onObject = function onObject(_ref11) { | ||
var object = _ref11.object, | ||
depth = _ref11.depth, | ||
_key = _ref11._key, | ||
_val = _ref11._val; | ||
if (Object.keys(object).length === 0) { | ||
var result = get(_, depth); | ||
result && set$1(cache, depth, result); | ||
!result && set$1(cache, depth, _val); | ||
return; | ||
} | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject, | ||
onFunction: onFunction, | ||
onVariable: onVariable, | ||
onArray: onVariable | ||
}); | ||
}; | ||
_typeof(args) === 'object' && onObject({ | ||
object: args, | ||
depth: '' | ||
}); | ||
_typeof(args) !== 'object' && onVariable({ | ||
depth: args | ||
}); | ||
return cache; | ||
}; | ||
var $diff$$1 = function $diff$$1(_, _object) { | ||
return $exec$$1(_diff$$1, _, _object); | ||
}; | ||
var _diff$$1 = function _diff$$1(_, _object) { | ||
var cache = {}; | ||
var onObject = function onObject(_ref12) { | ||
var object = _ref12.object, | ||
depth = _ref12.depth, | ||
_key = _ref12._key, | ||
_val = _ref12._val; | ||
var target = get(_, depth, {}); | ||
$(object, function (key, val) { | ||
if (_typeof(val) === 'object') { | ||
return; | ||
} | ||
var result = target[key]; | ||
if (result !== val) { | ||
var newDepth = "".concat(depth, ".").concat(key); | ||
set$1(cache, newDepth, val); | ||
} | ||
return; | ||
}); | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return cache; | ||
}; | ||
var $has$$1 = function $has$$1(_, _object) { | ||
return $exec$$1(_has$$1, _, _object); | ||
}; | ||
var _has$$1 = function _has$$1(_, _object) { | ||
var cache = {}; | ||
var onObject = function onObject(_ref13) { | ||
var object = _ref13.object, | ||
depth = _ref13.depth, | ||
_key = _ref13._key, | ||
_val = _ref13._val; | ||
var target = get(_, depth, {}); | ||
$(object, function (key, val) { | ||
if (_typeof(val) === 'object') { | ||
return; | ||
} | ||
var newDepth = "".concat(depth, ".").concat(key); | ||
var result = target[key]; | ||
result && set$1(cache, newDepth, true); | ||
!result && set$1(cache, newDepth, false); | ||
return; | ||
}); | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return cache; | ||
}; // | ||
var _matchSimple$$1 = function _matchSimple$$1(_, _array) { | ||
console.log(JSON.stringify(_array)); | ||
throw new Error('not implemented'); | ||
}; | ||
var _matchAdvanced$$1 = function _matchAdvanced$$1(_, _object) { | ||
$(_object, function (_key, _val) { | ||
var _JSON$parse = JSON.parse(_key), | ||
invalid = _JSON$parse.invalid, | ||
valid = _JSON$parse.valid, | ||
equal = _JSON$parse.equal, | ||
__get = _JSON$parse.get; | ||
var isinvalid = true; | ||
var isValid = true; | ||
var isEqual = true; | ||
var cache = {}; | ||
invalid && (isinvalid = $invalid$$1(_, invalid)); | ||
valid && (isValid = $valid$$1(_, valid)); | ||
equal && (isEqual = $equal$$1(_, equal)); | ||
if (!isEqual || !isValid || !isinvalid) { | ||
return; | ||
} | ||
__get && $set$$1(cache, $get$$1(_, __get)); | ||
_val(cache); | ||
}); | ||
}; | ||
var matchMethods$$1 = { | ||
simple: _matchSimple$$1, | ||
advanced: _matchAdvanced$$1 | ||
}; | ||
var $match$$1 = function $match$$1(target, _object) { | ||
var _ref14 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}, | ||
_ref14$type = _ref14.type, | ||
type = _ref14$type === void 0 ? 'simple' : _ref14$type; | ||
return $exec$$1(matchMethods$$1[type], target, _object); | ||
}; | ||
var $invalid$$1 = function $invalid$$1(_, _object) { | ||
return $exec$$1(_invalid$$1, _, _object); | ||
}; | ||
var _invalid$$1 = function _invalid$$1(_, _object) { | ||
var isinValid = true; | ||
var onObject = function onObject(_ref15) { | ||
var object = _ref15.object, | ||
depth = _ref15.depth, | ||
_key = _ref15._key, | ||
_val = _ref15._val; | ||
$(object, function (key, val) { | ||
if (_typeof(val) === 'object' || !isinValid) { | ||
return; | ||
} | ||
var newDepth = depth ? "".concat(depth, ".").concat(key) : key; | ||
var target = get(_, newDepth); | ||
if (target) { | ||
isinValid = false; | ||
return; | ||
} | ||
}); | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return isinValid; | ||
}; | ||
var $valid$$1 = function $valid$$1(_, _object) { | ||
return $exec$$1(_valid$$1, _, _object); | ||
}; | ||
var _valid$$1 = function _valid$$1(_, _object) { | ||
var isValid = true; | ||
var onObject = function onObject(_ref16) { | ||
var object = _ref16.object, | ||
depth = _ref16.depth, | ||
_key = _ref16._key, | ||
_val = _ref16._val; | ||
$(object, function (key, val) { | ||
if (_typeof(val) === 'object' || !isValid) { | ||
return; | ||
} | ||
var newDepth = depth ? "".concat(depth, ".").concat(key) : key; | ||
var target = get(_, newDepth); | ||
if (!target) { | ||
isValid = false; | ||
return; | ||
} | ||
}); | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return isValid; | ||
}; | ||
var $equal$$1 = function $equal$$1(_, _object) { | ||
return $exec$$1(_equal$$1, _, _object); | ||
}; | ||
var _equal$$1 = function _equal$$1(_, _object) { | ||
var isEqual = true; | ||
var onObject = function onObject(_ref17) { | ||
var object = _ref17.object, | ||
depth = _ref17.depth, | ||
_key = _ref17._key, | ||
_val = _ref17._val; | ||
$(object, function (key, val) { | ||
if (_typeof(val) === 'object' || isEqual) { | ||
return; | ||
} | ||
var newDepth = depth ? "".concat(depth, ".").concat(key) : key; | ||
var target = get(_, newDepth); | ||
if (val !== target) { | ||
isEqual = false; | ||
return; | ||
} | ||
}); | ||
scanObject({ | ||
object: object, | ||
depth: depth, | ||
onObject: onObject | ||
}); | ||
}; | ||
onObject({ | ||
object: _object, | ||
depth: '' | ||
}); | ||
return isEqual; | ||
}; | ||
var _compilers = { | ||
hooks: function hooks(ctx) { | ||
var keys = ctx._keys; | ||
keys = keys.filter(function (key) { | ||
return key.startsWith('$'); | ||
}); | ||
if (keys.length > 0) { | ||
ctx._hooks = {}; | ||
keys.forEach(function (key) { | ||
var newKey = key.replace(/\$/, ''); | ||
ctx._hooks[newKey] = ctx._object[key]; | ||
}); | ||
} | ||
} | ||
}; | ||
// const compose = middleware => { | ||
@@ -513,5 +1066,4 @@ // return (ctx, next) => { | ||
}, | ||
A$: function A$(_ref10) { | ||
$: function $$$1(_ref10) { | ||
var object = _ref10.object, | ||
parentDepth = _ref10.parentDepth, | ||
depth = _ref10.depth, | ||
@@ -521,3 +1073,3 @@ _key = _ref10._key, | ||
_object = _ref10._object; | ||
var key = "".concat(depth, ".A$"); | ||
var key = "".concat(depth, ".$"); | ||
handleEachHooks({ | ||
@@ -531,4 +1083,5 @@ object: object, | ||
}, | ||
$: function $$$1(_ref11) { | ||
A$: function A$(_ref11) { | ||
var object = _ref11.object, | ||
parentDepth = _ref11.parentDepth, | ||
depth = _ref11.depth, | ||
@@ -538,3 +1091,3 @@ _key = _ref11._key, | ||
_object = _ref11._object; | ||
var key = "".concat(depth, ".$"); | ||
var key = "".concat(depth, ".A$"); | ||
handleEachHooks({ | ||
@@ -803,18 +1356,3 @@ object: object, | ||
var _core; | ||
var core = (_core = {}, _defineProperty(_core, HOOKS, initHooks()), _defineProperty(_core, "_scanHooks", _scanHooks$$1), _defineProperty(_core, "_compilers", { | ||
hooks: function hooks(ctx) { | ||
var keys = ctx._keys; | ||
keys = keys.filter(function (key) { | ||
return key.startsWith('$'); | ||
}); | ||
if (keys.length > 0) { | ||
ctx._hooks = {}; | ||
keys.forEach(function (key) { | ||
var newKey = key.replace(/\$/, ''); | ||
ctx._hooks[newKey] = ctx._object[key]; | ||
}); | ||
} | ||
} | ||
}), _defineProperty(_core, "$compile", $compile$$1), _defineProperty(_core, "$use", function $use$$2(data) { | ||
var core = (_core = {}, _defineProperty(_core, HOOKS, initHooks()), _defineProperty(_core, "_scanHooks", _scanHooks$$1), _defineProperty(_core, "_compilers", _compilers), _defineProperty(_core, "$compile", $compile$$1), _defineProperty(_core, "$use", function $use$$2(data) { | ||
$use$$1(core, core.$compile(core, data)); | ||
@@ -824,3 +1362,50 @@ | ||
}), _core); | ||
core.$use({ | ||
$compilers: inject.injectObject('_compilers'), | ||
$scanHooks: inject.injectObjectDeep('_scanHooks') | ||
}); | ||
module.exports = core; | ||
exports.uuid = uuid; | ||
exports.default = core; | ||
exports.inject = inject; | ||
exports.HOOKS = HOOKS; | ||
exports.matchSlashPath = matchSlashPath; | ||
exports.matchPath = matchPath; | ||
exports.initHooks = initHooks; | ||
exports.get = get; | ||
exports.set = set$1; | ||
exports.has = has; | ||
exports.$ = $; | ||
exports.$M = $M; | ||
exports.scanObject = scanObject; | ||
exports.$str = $str$$1; | ||
exports.$compile = $compile$$1; | ||
exports._compile = _compile$$1; | ||
exports.$exec = $exec$$1; | ||
exports.$use = $use$$1; | ||
exports._use = _use$$1; | ||
exports.$unuse = $unuse$$1; | ||
exports._unuse = _unuse$$1; | ||
exports._setSimple = _setSimple$$1; | ||
exports._setAdvanced = _setAdvanced$$1; | ||
exports.setMethods = setMethods$$1; | ||
exports.$set = $set$$1; | ||
exports.$merge = $merge$$1; | ||
exports.$get = $get$$1; | ||
exports._get = _get$$1; | ||
exports.$diff = $diff$$1; | ||
exports._diff = _diff$$1; | ||
exports.$has = $has$$1; | ||
exports._has = _has$$1; | ||
exports._matchSimple = _matchSimple$$1; | ||
exports._matchAdvanced = _matchAdvanced$$1; | ||
exports.matchMethods = matchMethods$$1; | ||
exports.$match = $match$$1; | ||
exports.$invalid = $invalid$$1; | ||
exports._invalid = _invalid$$1; | ||
exports.$valid = $valid$$1; | ||
exports._valid = _valid$$1; | ||
exports.$equal = $equal$$1; | ||
exports._equal = _equal$$1; | ||
exports._compilers = _compilers; | ||
exports._scanHooks = _scanHooks$$1; |
{ | ||
"name": "menhera", | ||
"version": "0.9.0", | ||
"version": "0.9.1-rc1", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35040
1280