UNPKG

@yuanjili/js-es-c

Version:

js工具包

1 lines 1.57 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _slicedToArray=function(){function a(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{!d&&h["return"]&&h["return"]()}finally{if(e)throw f}}return c}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a};exports.removeEmptyProperties=removeEmptyProperties,exports.arrayDiff=arrayDiff,exports.checkPermission=checkPermission;function removeEmptyProperties(a){if("object"!==("undefined"==typeof a?"undefined":_typeof(a))||null===a)throw new Error("Input must be an object");var b=Object.entries(a).reduce(function(a,b){var c=_slicedToArray(b,2),d=c[0],e=c[1];return"string"==typeof e&&(e=e.trim()),null!==e&&void 0!==e&&""!==e&&(a[d]=e),a},{});return b}function arrayDiff(c,a){var b=[];return c.map(function(c){a.includes(c)||b.push(c)}),b}function checkPermission(a,b){if(a&&a instanceof Array&&0<a.length){var c=b.some(function(b){return a.includes(b)});return!!c}return!1}var dictToCreateFormOptions=exports.dictToCreateFormOptions=function(a){var b=[];for(var c in a)b.push({subType:"el-option",value:isNaN(+c)?c:+c,label:a[c],text:a[c]});return b};