commonly-used-utils
Advanced tools
Comparing version 1.0.0-beat5 to 1.0.0-beat6
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(self,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{NotRepeatedArray:()=>j,addItem:()=>g,deleteRecursively:()=>u,deleteRecursivelyReverse:()=>h,findArrayAttr:()=>b,isArray:()=>l,isFunction:()=>i,isNil:()=>c,isObject:()=>o,oneDimensional:()=>s,removeItem:()=>y,setTreeAttr:()=>f,sleep:()=>m,treeFindParents:()=>a});const r=new Map([["[object Boolean]","boolean"],["[object Number]","number"],["[object String]","string"],["[object Function]","function"],["[object Array]","array"],["[object Date]","date"],["[object RegExp]","regExp"],["[object Object]","object"],["[object Error]","error"]]),n=e=>null==e?e+"":"object"==typeof e||"function"==typeof e?r.get(Object.prototype.toString.call(e))||"object":typeof e,o=e=>"object"===n(e),i=e=>"function"===n(e),l=e=>"array"===n(e),c=e=>null==e,s=(e=[],t="children")=>e&&e.length?e.reduce(((e,r)=>e.concat(r,r?.[t]?.length?s(r[t],t):[])),[]):[],a=(e=[],t,r="id",n="children",i=!0,l=!0,c=!0)=>{if(!e.length)return[];for(let s=0,f=e.length;s<f;s++){const f=e[s];if(f[r]===t)return l?[f]:c?[]:f;const u=f?.[n]?.length&&a(f[n],t,r,n,i,l,!1);if(o(u))return[f];if(u?.length)return i?[f].concat(u):u.concat(f)}},f=(e=[],t,r="children",n=[])=>{for(let o=0,i=e.length;o<i;o++){let i=e[o];t(i,n),i?.[r]?.length&&f(i[r],t,r,[...n,i])}},u=(e=[],t,r="children")=>{for(let o=0,i=e.length;o<i;o++){let l=e[o],c=t(l);if("boolean"!==n(c)){new Error(`callback返回值:${c}(返回值只能是布尔值)`);break}c?l?.[r]?.length&&u(l[r],t,r):(e.splice(o,1),i--,o--)}},h=(e=[],t,r="children")=>{for(let o=e.length-1;o>=0;o--){let i=e[o],l=t(i);if("boolean"!==n(l)){new Error(`callback返回值:${l}(返回值只能是布尔值)`);break}l?i?.[r]?.length&&u(i[r],t,r):e.splice(o,1)}},b=(e,t,r,n,i=!1)=>{if(!l(e)||!r||c(t)||i&&!e.length)throw new Error("请检查参数");const s=e.find((e=>!!o(e)&&(i?e[r]===t:""+e[r]==""+t)));if("{}"===n||"string"==typeof n&&"object"===n.toLowerCase()||o(n)){if(i&&!o(s))throw new Error(`严格模式(对象)未找到, value: ${t}, attr:${r}, url: ${location.href}`);return s}if(i&&(!o(s)||!(n in s)||c(s[n])))throw new Error(`严格模式(属性)未找到, value: ${t}, attr:${r}, url: ${location.href}`);return s?.[n]};function d(e){if("number"!==n(e)&&"string"!==n(e))throw new Error("只支持string、number类型的数据");!l(this)||this.includes(e)?this instanceof Set&&this.add(e):this.push(e)}function p(e){if("number"!==n(e)&&"string"!==n(e))throw new Error("只支持string、number类型的数据");if(l(this)){const t=this.indexOf(e);-1!==t&&this.splice(t,1)}else this instanceof Set&&this.delete(e)}const g=function(...e){for(let t in e){const r=e[t];l(r)?r.forEach((e=>{d.call(this,e)})):d.call(this,r)}return this},y=function(...e){for(let t in e){const r=e[t];l(r)?r.forEach((e=>{p.call(this,e)})):p.call(this,r)}return this};class j extends Array{constructor(e){e?.length?super(...e):super()}addItem(...e){return g.call(this,e),this}removeItem(...e){return y.call(this,e),this}}const m=e=>new Promise((t=>setTimeout(t,e)));return t})())); | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(self,(()=>(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{NotRepeatedArray:()=>w,addItem:()=>j,deleteRecursively:()=>d,deleteRecursivelyReverse:()=>h,findArrayAttr:()=>b,isArray:()=>l,isFunction:()=>c,isNil:()=>a,isObject:()=>i,oneDimensional:()=>f,removeItem:()=>m,setTreeAttr:()=>s,sleep:()=>O,treeFindParents:()=>v});var r,n=new Map([["[object Boolean]","boolean"],["[object Number]","number"],["[object String]","string"],["[object Function]","function"],["[object Array]","array"],["[object Date]","date"],["[object RegExp]","regExp"],["[object Object]","object"],["[object Error]","error"]]),o=function(t){return null==t?t+"":"object"==typeof t||"function"==typeof t?n.get(Object.prototype.toString.call(t))||"object":typeof t},i=function(t){return"object"===o(t)},c=function(t){return"function"===o(t)},l=function(t){return"array"===o(t)},a=function(t){return null==t},u=function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))},f=function(t,e){return void 0===t&&(t=[]),void 0===e&&(e="children"),t&&t.length?t.reduce((function(t,r){var n;return t.concat(r,(null===(n=null==r?void 0:r[e])||void 0===n?void 0:n.length)?f(r[e],e):[])}),[]):[]},v=function(t,e,r,n,o,c,l){var a;if(void 0===t&&(t=[]),void 0===r&&(r="id"),void 0===n&&(n="children"),void 0===o&&(o=!0),void 0===c&&(c=!0),void 0===l&&(l=!0),!t.length)return[];for(var u=0,f=t.length;u<f;u++){var s=t[u];if(s[r]===e)return c?[s]:l?[]:s;var d=(null===(a=null==s?void 0:s[n])||void 0===a?void 0:a.length)&&v(s[n],e,r,n,o,c,!1);if(i(d))return[s];if(null==d?void 0:d.length)return o?[s].concat(d):d.concat(s)}},s=function(t,e,r,n){var o;void 0===t&&(t=[]),void 0===r&&(r="children"),void 0===n&&(n=[]);for(var i=0,c=t.length;i<c;i++){var l=t[i];e(l,n),(null===(o=null==l?void 0:l[r])||void 0===o?void 0:o.length)&&s(l[r],e,r,u(u([],n,!0),[l],!1))}},d=function(t,e,r){var n;void 0===t&&(t=[]),void 0===r&&(r="children");for(var i=0,c=t.length;i<c;i++){var l=t[i],a=e(l);if("boolean"!==o(a)){new Error("callback返回值:".concat(a,"(返回值只能是布尔值)"));break}a?(null===(n=null==l?void 0:l[r])||void 0===n?void 0:n.length)&&d(l[r],e,r):(t.splice(i,1),c--,i--)}},h=function(t,e,r){var n;void 0===t&&(t=[]),void 0===r&&(r="children");for(var i=t.length-1;i>=0;i--){var c=t[i],l=e(c);if("boolean"!==o(l)){new Error("callback返回值:".concat(l,"(返回值只能是布尔值)"));break}l?(null===(n=null==c?void 0:c[r])||void 0===n?void 0:n.length)&&d(c[r],e,r):t.splice(i,1)}},p=(r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),b=function(t,e,r,n,o){if(void 0===o&&(o=!1),!l(t)||!r||a(e)||o&&!t.length)throw new Error("请检查参数");var c=t.find((function(t){return!!i(t)&&(o?t[r]===e:""+t[r]==""+e)}));if("{}"===n||"string"==typeof n&&"object"===n.toLowerCase()||i(n)){if(o&&!i(c))throw new Error("严格模式(对象)未找到, value: ".concat(e,", attr:").concat(r,", url: ").concat(location.href));return c}if(o&&(!i(c)||!(n in c)||a(c[n])))throw new Error("严格模式(属性)未找到, value: ".concat(e,", attr:").concat(r,", url: ").concat(location.href));return null==c?void 0:c[n]};function y(t){if("number"!==o(t)&&"string"!==o(t))throw new Error("只支持string、number类型的数据");!l(this)||this.includes(t)?this instanceof Set&&this.add(t):this.push(t)}function g(t){if("number"!==o(t)&&"string"!==o(t))throw new Error("只支持string、number类型的数据");if(l(this)){var e=this.indexOf(t);-1!==e&&this.splice(e,1)}else this instanceof Set&&this.delete(t)}var j=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];for(var n in e){var o=e[n];l(o)?o.forEach((function(e){y.call(t,e)})):y.call(this,o)}return this},m=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];for(var n in e){var o=e[n];l(o)?o.forEach((function(e){g.call(t,e)})):g.call(this,o)}return this},w=function(t){function e(e){return(null==e?void 0:e.length)?t.apply(this,e)||this:t.call(this)||this}return p(e,t),e.prototype.addItem=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return j.call(this,t),this},e.prototype.removeItem=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return m.call(this,t),this},e}(Array),O=function(t){return new Promise((function(e){return setTimeout(e,t)}))};return e})())); |
{ | ||
"name": "commonly-used-utils", | ||
"version": "1.0.0-beat5", | ||
"version": "1.0.0-beat6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"target": "ES5", | ||
"module": "esnext", | ||
@@ -5,0 +5,0 @@ "lib": [ |
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
15691