Skip to content

Commit

Permalink
update 0.0.3:增加对functon的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
YuChenLi923 committed Jul 25, 2019
1 parent d554174 commit d31be34
Show file tree
Hide file tree
Showing 6 changed files with 340 additions and 38 deletions.
289 changes: 264 additions & 25 deletions dist/condition-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,32 +91,99 @@ return /******/ (function(modules) { // webpackBootstrap
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {

/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(_.noop);
* // => true
*
* _.isObject(null);
* // => false
*/
function isObject(value) {
var type = typeof value;
return value != null && (type == 'object' || type == 'function');
}

module.exports = isObject;


/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {

var root = __webpack_require__(6);

/** Built-in value references. */
var Symbol = root.Symbol;

module.exports = Symbol;


/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";


var _expressionParser = __webpack_require__(1);
var _expressionParser = __webpack_require__(3);

var _expressionParser2 = _interopRequireDefault(_expressionParser);

var _isObject = __webpack_require__(2);
var _isObject = __webpack_require__(0);

var _isObject2 = _interopRequireDefault(_isObject);

var _extendAssign = __webpack_require__(3);
var _isFunction = __webpack_require__(4);

var _isFunction2 = _interopRequireDefault(_isFunction);

var _extendAssign = __webpack_require__(11);

var _extendAssign2 = _interopRequireDefault(_extendAssign);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var expressionWithKeyReg = /^\{(.*)\}:(.+)/;

function handleValue(value, scope) {
if ((0, _isFunction2.default)(value)) {
try {
return value(scope);
} catch (e) {
return {};
}
} else if ((0, _isObject2.default)(value)) {
return convert(value, scope);
} else {
return value;
}
}

function isExpression(key) {
return key[0] === '{' && key[key.length - 1] === '}';
}
Expand All @@ -143,12 +210,12 @@ function convert(json, scope) {
var parseRes = parseExpressionWithKey(key);
var _result = (0, _expressionParser2.default)(parseRes.expression, scope);
if (_result) {
newJson[parseRes.key] = (0, _isObject2.default)(value) ? convert(value, scope) : value;
newJson[parseRes.key] = handleValue(value, scope);
}
return;
}
if (!isExpression(key)) {
newJson[key] = (0, _isObject2.default)(value) ? convert(value, scope) : value;
newJson[key] = handleValue(value, scope);
return;
}
key = key.slice(1, key.length - 1);
Expand All @@ -165,7 +232,7 @@ function convert(json, scope) {
module.exports = convert;

/***/ }),
/* 1 */
/* 3 */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
Expand Down Expand Up @@ -244,44 +311,216 @@ function parseExpression(exp, scope) {
module.exports = parseExpression;

/***/ }),
/* 2 */
/***/ (function(module, exports) {
/* 4 */
/***/ (function(module, exports, __webpack_require__) {

var baseGetTag = __webpack_require__(5),
isObject = __webpack_require__(0);

/** `Object#toString` result references. */
var asyncTag = '[object AsyncFunction]',
funcTag = '[object Function]',
genTag = '[object GeneratorFunction]',
proxyTag = '[object Proxy]';

/**
* Checks if `value` is the
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
* Checks if `value` is classified as a `Function` object.
*
* @static
* @memberOf _
* @since 0.1.0
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
* @example
*
* _.isObject({});
* _.isFunction(_);
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
* _.isFunction(/abc/);
* // => false
*/
function isFunction(value) {
if (!isObject(value)) {
return false;
}
// The use of `Object#toString` avoids issues with the `typeof` operator
// in Safari 9 which returns 'object' for typed arrays and other constructors.
var tag = baseGetTag(value);
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
}

module.exports = isFunction;


/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {

var Symbol = __webpack_require__(1),
getRawTag = __webpack_require__(9),
objectToString = __webpack_require__(10);

/** `Object#toString` result references. */
var nullTag = '[object Null]',
undefinedTag = '[object Undefined]';

/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;

/**
* The base implementation of `getTag` without fallbacks for buggy environments.
*
* _.isObject(_.noop);
* // => true
* @private
* @param {*} value The value to query.
* @returns {string} Returns the `toStringTag`.
*/
function baseGetTag(value) {
if (value == null) {
return value === undefined ? undefinedTag : nullTag;
}
return (symToStringTag && symToStringTag in Object(value))
? getRawTag(value)
: objectToString(value);
}

module.exports = baseGetTag;


/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {

var freeGlobal = __webpack_require__(7);

/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;

/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();

module.exports = root;


/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {

/* WEBPACK VAR INJECTION */(function(global) {/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;

module.exports = freeGlobal;

/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(8)))

/***/ }),
/* 8 */
/***/ (function(module, exports) {

var g;

// This works in non-strict mode
g = (function() {
return this;
})();

try {
// This works if eval is allowed (see CSP)
g = g || new Function("return this")();
} catch (e) {
// This works if the window reference is available
if (typeof window === "object") g = window;
}

// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}

module.exports = g;


/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {

var Symbol = __webpack_require__(1);

/** Used for built-in method references. */
var objectProto = Object.prototype;

/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;

/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;

/** Built-in value references. */
var symToStringTag = Symbol ? Symbol.toStringTag : undefined;

/**
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
*
* _.isObject(null);
* // => false
* @private
* @param {*} value The value to query.
* @returns {string} Returns the raw `toStringTag`.
*/
function isObject(value) {
var type = typeof value;
return value != null && (type == 'object' || type == 'function');
function getRawTag(value) {
var isOwn = hasOwnProperty.call(value, symToStringTag),
tag = value[symToStringTag];

try {
value[symToStringTag] = undefined;
var unmasked = true;
} catch (e) {}

var result = nativeObjectToString.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag] = tag;
} else {
delete value[symToStringTag];
}
}
return result;
}

module.exports = isObject;
module.exports = getRawTag;


/***/ }),
/* 3 */
/* 10 */
/***/ (function(module, exports) {

/** Used for built-in method references. */
var objectProto = Object.prototype;

/**
* Used to resolve the
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeObjectToString = objectProto.toString;

/**
* Converts `value` to a string using `Object.prototype.toString`.
*
* @private
* @param {*} value The value to convert.
* @returns {string} Returns the converted string.
*/
function objectToString(value) {
return nativeObjectToString.call(value);
}

module.exports = objectToString;


/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {

!function(t,e){ true?module.exports=e():undefined}(this,function(){return function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var o=r(1),n=r(2);function i(t,e){Object.defineProperty(t,e,{enumerable:!1,writable:!1})}function u(t,e,r,o,u){t&&(e&&(n(t,"array")&&t.includes(r)||n(t,"function")&&t(r))?i(o,r):!e&&(n(t,"array")&&t.includes(u.parent?u.parent+"."+r:r)||n(t,"function")&&t(u.parent?u.parent+"."+r:r))&&i(o,r))}t.exports=function t(){for(var e=arguments.length,r=Array(e),i=0;i<e;i++)r[i]=arguments[i];var c=r.shift(),f=r,a=f.length,l=r[a-1],p={parent:""},d=void 0,s=void 0,y=void 0,b=void 0,v=void 0,j=void 0,m=void 0,w=void 0;if(!n(c,"object")&&!n(c,"array")&&!n(c,"function"))throw new Error("the target is not Object, Array or Function");if(!n(l,"object")||!0!==r[a-2]&&!1!==r[a-2])!0===l&&(--a,f.pop());else{p=l,l=r[a-2];var O=p;d=O.filter,b=O.protect,s=O.filterGlobal,y=O.protectGlobal,a-=2}for(v=0;v<a;v++)for(j in w=f[v]){if(d){if(s&&(n(d,"array")&&d.includes(j)||n(d,"function")&&!d(j)))continue;if(!s&&(n(d,"array")&&d.includes(p.parent?p.parent+"."+j:j)||n(d,"function")&&!d(p.parent?p.parent+"."+j:j)))continue}!0===l&&(n(w[j],"object")||n(w[j],"array"))?(m=n(w[j],"object")?c[j]&&o(c[j])?c[j]:{}:c[j]&&Array.isArray(c[j])?c[j]:[],c[j]=t(m,w[j],l,{parent:p.parent?p.parent+"."+j:j,filter:d,protect:b,filterGlobal:s,protectGlobal:y}),u(b,y,j,c,p)):void 0!==w[j]&&(c[j]=w[j],u(b,y,j,c,p))}return c}},function(t,e,r){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};t.exports=function(t){var e=Object.prototype.hasOwnProperty;if(!t||"object"!==(void 0===t?"undefined":o(t))||"undefined"!=typeof window&&window.window===window&&t===window)return!1;try{if(t.constructor&&!e.call(t,"constructor")&&!e.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}var r=void 0;for(r in t);return void 0===r||e.call(t,r)}},function(t,e,r){"use strict";t.exports=function(t,e){return Object.prototype.toString.call(t).replace("]","").split(" ")[1].toLowerCase()===e.toLowerCase()}}])});
Expand Down

0 comments on commit d31be34

Please sign in to comment.