Comparing version 0.7.2 to 0.7.3
@@ -7,5 +7,5 @@ 'use strict'; | ||
var get = _interopDefault(require('lodash.get')); | ||
var set = _interopDefault(require('lodash.set')); | ||
var has = _interopDefault(require('lodash.has')); | ||
var lget = _interopDefault(require('lodash.get')); | ||
var lset = _interopDefault(require('lodash.set')); | ||
var lhas = _interopDefault(require('lodash.has')); | ||
var events = require('events'); | ||
@@ -319,3 +319,2 @@ | ||
var matchPath = /\./; | ||
var $str$$1 = JSON.stringify; | ||
@@ -410,7 +409,7 @@ var $use$$1 = function $use$$1(_, _object) { | ||
var result = get(_, _val); | ||
set(_, depth, result); | ||
set(cache, depth, result); | ||
set$1(_, depth, result); | ||
set$1(cache, depth, result); | ||
} else { | ||
set(_, depth, _val); | ||
set(cache, depth, _val); | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
} | ||
@@ -426,4 +425,4 @@ | ||
_val = _ref3._val; | ||
set(_, depth, _val); | ||
set(cache, depth, _val); | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
return; | ||
@@ -439,4 +438,4 @@ }; | ||
if (Object.keys(object).length === 0) { | ||
set(_, depth, _val); | ||
set(cache, depth, _val); | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
return; | ||
@@ -472,7 +471,7 @@ } | ||
var result = get(_, _val); | ||
set(_, depth, result); | ||
set(cache, depth, result); | ||
set$1(_, depth, result); | ||
set$1(cache, depth, result); | ||
} else { | ||
set(_, depth, _val); | ||
set(cache, depth, _val); | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
} | ||
@@ -494,4 +493,4 @@ | ||
set(_, depth, result); | ||
set(cache, depth, result); | ||
set$1(_, depth, result); | ||
set$1(cache, depth, result); | ||
return; | ||
@@ -507,4 +506,4 @@ }; | ||
if (Object.keys(object).length === 0) { | ||
set(_, depth, _val); | ||
set(cache, depth, _val); | ||
set$1(_, depth, _val); | ||
set$1(cache, depth, _val); | ||
return; | ||
@@ -562,7 +561,7 @@ } | ||
result = get(_, _val); | ||
result && set(cache, depth, result); | ||
result && set$1(cache, depth, result); | ||
} else { | ||
result = get(_, depth); | ||
result && set(cache, depth, result); | ||
!result && set(cache, depth, _val); | ||
result && set$1(cache, depth, result); | ||
!result && set$1(cache, depth, _val); | ||
} | ||
@@ -584,4 +583,4 @@ | ||
result && set(cache, depth, result); | ||
!result && set(cache, depth, _val); | ||
result && set$1(cache, depth, result); | ||
!result && set$1(cache, depth, _val); | ||
return; | ||
@@ -598,4 +597,4 @@ }; | ||
var result = get(_, depth); | ||
result && set(cache, depth, result); | ||
!result && set(cache, depth, _val); | ||
result && set$1(cache, depth, result); | ||
!result && set$1(cache, depth, _val); | ||
return; | ||
@@ -641,3 +640,3 @@ } | ||
var newDepth = "".concat(depth, ".").concat(key); | ||
set(cache, newDepth, val); | ||
set$1(cache, newDepth, val); | ||
} | ||
@@ -679,4 +678,4 @@ | ||
var result = target[key]; | ||
result && set(cache, newDepth, true); | ||
!result && set(cache, newDepth, false); | ||
result && set$1(cache, newDepth, true); | ||
!result && set$1(cache, newDepth, false); | ||
return; | ||
@@ -878,8 +877,6 @@ }); | ||
_val = _ref2._val; | ||
var target = get(_2[HOOKS], depth, []); | ||
var target = get(_2[HOOKS], depth, []); // if (!target.includes(_val.bind(cp))) { | ||
if (!target.includes(_val.bind(cp))) { | ||
target.push(_val.bind(cp)); | ||
set(_2[HOOKS], depth, target); | ||
} | ||
target.push(_val.bind(cp)); | ||
set$1(_2[HOOKS], depth, target); // } | ||
}; | ||
@@ -949,2 +946,31 @@ | ||
var matchSlashPath = /\//g; | ||
var matchPath = /\/|\./g; | ||
var get = function get(obj, path, def) { | ||
if (matchSlashPath.test(path)) { | ||
path = path.replace(matchSlashPath, "."); | ||
} | ||
var result = lget(obj, path, def); | ||
if (typeof result === "string" && matchPath.test(result)) { | ||
return get(obj, result, def); | ||
} else { | ||
return result; | ||
} | ||
}; | ||
var set$1 = function set(obj, path, def) { | ||
if (matchSlashPath.test(path)) { | ||
path = path.replace(matchSlashPath, "."); | ||
} | ||
return lset(obj, path, def); | ||
}; | ||
var has = function has(obj, path, def) { | ||
if (matchSlashPath.test(path)) { | ||
path = path.replace(matchSlashPath, "."); | ||
} | ||
return lhas(obj, path, def); | ||
}; | ||
var HOOKS = Symbol("hooks"); | ||
@@ -1061,7 +1087,9 @@ var $ = function $(obj, cb) { | ||
exports.$core = $core; | ||
exports.default = index; | ||
exports.matchSlashPath = matchSlashPath; | ||
exports.matchPath = matchPath; | ||
exports.get = get; | ||
exports.set = set; | ||
exports.set = set$1; | ||
exports.has = has; | ||
exports.$core = $core; | ||
exports.default = index; | ||
exports.HOOKS = HOOKS; | ||
@@ -1068,0 +1096,0 @@ exports.$ = $; |
{ | ||
"name": "menhera", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -16,14 +16,2 @@ # Menhera | ||
const test = ({ _val }) => console.log(_val); | ||
const testFn = ({ _val }) => console.log(_val()); | ||
const testEach = ({ _val }) => { | ||
typeof _val === "function" && testFn({ _val }); | ||
typeof _val !== "function" && test({ _val }); | ||
}; | ||
const testRoot = ({ _val }) => { | ||
for (let [key, val] of Object.entries(_val)) { | ||
testEach({ _val: val }); | ||
} | ||
}; | ||
Mhr.$use({ | ||
@@ -35,6 +23,4 @@ _hooks: { | ||
bar1: { | ||
$: testEach, | ||
_: testRoot, | ||
test, | ||
testFn | ||
test: ({ _val }) => console.log(_val), | ||
testFn: ({ _val }) => console.log(_val()) | ||
} | ||
@@ -41,0 +27,0 @@ } |
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
28147
1007
35