helper-js
Advanced tools
Comparing version 1.0.8 to 1.0.10
/*! | ||
* helper-js v1.0.8 | ||
* helper-js v1.0.10 | ||
* phphe <phphe@outlook.com> (https://github.com/phphe) | ||
@@ -285,2 +285,21 @@ * https://github.com/phphe/helper-js.git | ||
} | ||
function addClass(el, className) { | ||
if (!hasClass(el, className)) { | ||
if (el.classList) { | ||
el.classList.add(className); | ||
} else { | ||
el.className += ' ' + className; | ||
} | ||
} | ||
} | ||
function getElSize(el) { | ||
var originDisplay = el.style.display; | ||
el.style.display = 'block'; | ||
var size = { | ||
width: el.offsetWidth, | ||
height: el.offsetHeight | ||
}; | ||
el.style.display = originDisplay; | ||
return size; | ||
} | ||
/** | ||
@@ -439,2 +458,4 @@ * [isOffsetInEl] | ||
exports.hasClass = hasClass; | ||
exports.addClass = addClass; | ||
exports.getElSize = getElSize; | ||
exports.isOffsetInEl = isOffsetInEl; | ||
@@ -441,0 +462,0 @@ exports.getBorder = getBorder; |
/*! | ||
* helper-js v1.0.8 | ||
* helper-js v1.0.10 | ||
* phphe <phphe@outlook.com> (https://github.com/phphe) | ||
@@ -281,2 +281,21 @@ * https://github.com/phphe/helper-js.git | ||
} | ||
function addClass(el, className) { | ||
if (!hasClass(el, className)) { | ||
if (el.classList) { | ||
el.classList.add(className); | ||
} else { | ||
el.className += ' ' + className; | ||
} | ||
} | ||
} | ||
function getElSize(el) { | ||
var originDisplay = el.style.display; | ||
el.style.display = 'block'; | ||
var size = { | ||
width: el.offsetWidth, | ||
height: el.offsetHeight | ||
}; | ||
el.style.display = originDisplay; | ||
return size; | ||
} | ||
/** | ||
@@ -398,2 +417,2 @@ * [isOffsetInEl] | ||
export { isset, isArray, isBool, isNumber, isNumeric, isString, isObject, isFunction, isPromise, empty, numRand, numPad, studlyCase, snakeCase, camelCase, camelToWords, titleCase, strRand, replaceMultiple, arrayRemove, arrayFirst, arrayLast, arrayDiff, assignIfDifferent, objectMerge, objectMap, objectOnly, objectExcept, objectGet, objectSet, unset, getUrlParam, uniqueId, isDescendantOf, getOffset, findParent, hasClass, isOffsetInEl, getBorder, binarySearch, windowLoaded, storeOfWaitFor, waitFor }; | ||
export { isset, isArray, isBool, isNumber, isNumeric, isString, isObject, isFunction, isPromise, empty, numRand, numPad, studlyCase, snakeCase, camelCase, camelToWords, titleCase, strRand, replaceMultiple, arrayRemove, arrayFirst, arrayLast, arrayDiff, assignIfDifferent, objectMerge, objectMap, objectOnly, objectExcept, objectGet, objectSet, unset, getUrlParam, uniqueId, isDescendantOf, getOffset, findParent, hasClass, addClass, getElSize, isOffsetInEl, getBorder, binarySearch, windowLoaded, storeOfWaitFor, waitFor }; |
/*! | ||
* helper-js v1.0.8 | ||
* helper-js v1.0.10 | ||
* phphe <phphe@outlook.com> (https://github.com/phphe) | ||
@@ -287,2 +287,21 @@ * https://github.com/phphe/helper-js.git | ||
} | ||
function addClass(el, className) { | ||
if (!hasClass(el, className)) { | ||
if (el.classList) { | ||
el.classList.add(className); | ||
} else { | ||
el.className += ' ' + className; | ||
} | ||
} | ||
} | ||
function getElSize(el) { | ||
var originDisplay = el.style.display; | ||
el.style.display = 'block'; | ||
var size = { | ||
width: el.offsetWidth, | ||
height: el.offsetHeight | ||
}; | ||
el.style.display = originDisplay; | ||
return size; | ||
} | ||
/** | ||
@@ -441,2 +460,4 @@ * [isOffsetInEl] | ||
exports.hasClass = hasClass; | ||
exports.addClass = addClass; | ||
exports.getElSize = getElSize; | ||
exports.isOffsetInEl = isOffsetInEl; | ||
@@ -443,0 +464,0 @@ exports.getBorder = getBorder; |
/*! | ||
* helper-js v1.0.8 | ||
* helper-js v1.0.10 | ||
* phphe <phphe@outlook.com> (https://github.com/phphe) | ||
@@ -8,3 +8,3 @@ * https://github.com/phphe/helper-js.git | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.helperJs=t.helperJs||{})}(this,function(t){"use strict";function e(t){return void 0!==t}function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function r(t){return"[object Boolean]"===Object.prototype.toString.call(t)}function o(t){return"[object Number]"===Object.prototype.toString.call(t)}function i(t){var e=parseFloat(t);return!isNaN(e)&&o(e)}function u(t){return"[object String]"===Object.prototype.toString.call(t)}function a(t){return"[object Object]"===Object.prototype.toString.call(t)}function c(t){return"function"==typeof t}function f(t){return"[object Promise]"===Object.prototype.toString.call(t)}function l(t){return null==t||(null!=t.length?0===t.length:!r(t)&&(o(t)?isNaN(t):a(t)?0===Object.keys(t).length:void 0))}function s(t,e){return 1===arguments.length&&(e=t,t=0),Math.floor(Math.random()*(e-t+1)+t)}function d(t,e){for(var n=t.toString().length;n<e;)t="0"+t,n++;return t}function p(t){return t&&t[0].toUpperCase()+t.substr(1)}function g(t){return t.replace(/ /g,"-").replace(/_/g,"-").replace(/([^A-Z])([A-Z])/g,"$1-$2").replace(/--+/g,"-").replace(/^-|-$|/g,"").toLowerCase()}function v(t){for(var e=t.toString().split(/[-_]/),n=1;n<e.length;n++)e[n]=p(e[n]);return e.join("")}function h(t){return t.toString().trim().split(/(?=[A-Z])/)}function m(t){return h(p(v(t))).join(" ").replace(/\bid\b/gi,"ID")}function y(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=0;o<t;o++)n+=r[s(r.length-1)];return e+n}function b(t,e){var n=new RegExp(Object.keys(t).join("|"),"g");return e.replace(n,function(e){return t[e]})}function w(t,e){var n=t.indexOf(e);return n>-1&&t.splice(n,1),t}function j(t){return t[0]}function O(t){return t[t.length-1]}function x(t,e){for(var n=t.length,r=[];n--;)e.indexOf(t[n])<0&&r.push(t[n]);return r}function E(t,e,n){t[e]!==n&&(t[e]=n)}function S(t,e){for(var n in e)t.hasOwnProperty(n)&&a(t[n])&&a(e[n])?Object.assign(t[n],e[n]):t[n]=e[n];return t}function P(t,e){var n={};for(var r in t)n[r]=e(t[r],r,t);return n}function I(t,e){var n={};for(var r in t)e.indexOf(r)>-1&&(n[r]=t[r]);return n}function L(t,e){var n={};for(var r in t)-1===e.indexOf(r)&&(n[r]=t[r]);return n}function N(t,e){for(var n=e.split("."),r=t,o=0;o<n.length;o++){if(void 0===r[n[o]])return;r=r[n[o]]}return r}function C(t,e,n){for(var r=e.split("."),o=r.length-1,i=0;i<o;i++)null==t[r[i]]&&(t[r[i]]={}),t=t[r[i]];t[r[o]]=n}function M(t,e){t[e]=void 0;try{delete t[e]}catch(t){}}function F(t){var e=document.location.href,n=e.indexOf(t+"=");if(-1==n)return!1;var r=e.slice(t.length+n+1),o=r.indexOf("&");return-1!=o&&(r=r.slice(0,o)),r}function A(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id_",e=t+y();return document.getElementById(e)||J.includes(e)?A(t):(J.push(e),e)}function H(t,e){for(;;){if(null==t.parentElement)return!1;if(t.parentElement===e)return!0;t=t.parentElement}}function R(t){function e(t){var n={x:t.offsetLeft,y:t.offsetTop},r={x:0,y:0};return null!=t.offsetParent&&(r=e(t.offsetParent)),{x:n.x+r.x,y:n.y+r.y}}return e(t)}function k(t,e){function n(t,e){if(t.parentElement)return e(t.parentElement)?t.parentElement:n(t.parentElement,e)}return n(t,e)}function B(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className)}function D(t,e,n){var r=R(n);return r.x<=t&&r.x+n.offsetWidth>=t&&r.y<=e&&r.y+n.offsetHeight>=e}function W(t){var e=document.body,n=k(t,function(t){return B(t,"work-area")}),r=R(n);return{left:r.x,right:r.x+n.offsetWidth,top:r.y+50,bottom:e.offsetHeight<window.innerHeight?window.innerHeight:e.offsetHeight}}function _(t,e){for(var n,r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=0,u=t.length-1,a=0;i>=0&&i<=u;){if(a>=o)throw Error("binarySearch: loop times is over "+o+", you can increase the limit.");n=Math.floor((u-i)/2+i),r=t[n];var c=e(r,t,a);if(c<0)u=n-1;else{if(!(c>0))return r;i=n+1}a++}return null}function Z(){return new Promise(function(t,e){document&&"complete"===document.readyState?t():window.addEventListener("load",function e(){t(),window.removeEventListener("load",e)})})}function $(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:100,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e3;c(t)&&(o=r,r=i(n)?n:100,n=t,t=null);var u=T;return t&&e(u[t])&&(window.clearInterval(u[t]),delete u[t]),new Promise(function(i,a){function c(e){l<=o?n()&&(f(e,t),i()):(f(e,t),a(new Error("waitFor: Limit is reached"))),l++}function f(t,n){t&&(n&&e(u[n])?(window.clearInterval(u[n]),delete u[n]):window.clearInterval(t))}var l=0,s=window.setInterval(function(){c(s)},r);t&&(u[t]=s),c()})}var J=[],T={};t.isset=e,t.isArray=n,t.isBool=r,t.isNumber=o,t.isNumeric=i,t.isString=u,t.isObject=a,t.isFunction=c,t.isPromise=f,t.empty=l,t.numRand=s,t.numPad=d,t.studlyCase=p,t.snakeCase=g,t.camelCase=v,t.camelToWords=h,t.titleCase=m,t.strRand=y,t.replaceMultiple=b,t.arrayRemove=w,t.arrayFirst=j,t.arrayLast=O,t.arrayDiff=x,t.assignIfDifferent=E,t.objectMerge=S,t.objectMap=P,t.objectOnly=I,t.objectExcept=L,t.objectGet=N,t.objectSet=C,t.unset=M,t.getUrlParam=F,t.uniqueId=A,t.isDescendantOf=H,t.getOffset=R,t.findParent=k,t.hasClass=B,t.isOffsetInEl=D,t.getBorder=W,t.binarySearch=_,t.windowLoaded=Z,t.storeOfWaitFor=T,t.waitFor=$,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.helperJs=t.helperJs||{})}(this,function(t){"use strict";function e(t){return void 0!==t}function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function r(t){return"[object Boolean]"===Object.prototype.toString.call(t)}function o(t){return"[object Number]"===Object.prototype.toString.call(t)}function i(t){var e=parseFloat(t);return!isNaN(e)&&o(e)}function a(t){return"[object String]"===Object.prototype.toString.call(t)}function u(t){return"[object Object]"===Object.prototype.toString.call(t)}function c(t){return"function"==typeof t}function f(t){return"[object Promise]"===Object.prototype.toString.call(t)}function l(t){return null==t||(null!=t.length?0===t.length:!r(t)&&(o(t)?isNaN(t):u(t)?0===Object.keys(t).length:void 0))}function s(t,e){return 1===arguments.length&&(e=t,t=0),Math.floor(Math.random()*(e-t+1)+t)}function d(t,e){for(var n=t.toString().length;n<e;)t="0"+t,n++;return t}function p(t){return t&&t[0].toUpperCase()+t.substr(1)}function g(t){return t.replace(/ /g,"-").replace(/_/g,"-").replace(/([^A-Z])([A-Z])/g,"$1-$2").replace(/--+/g,"-").replace(/^-|-$|/g,"").toLowerCase()}function v(t){for(var e=t.toString().split(/[-_]/),n=1;n<e.length;n++)e[n]=p(e[n]);return e.join("")}function h(t){return t.toString().trim().split(/(?=[A-Z])/)}function y(t){return h(p(v(t))).join(" ").replace(/\bid\b/gi,"ID")}function m(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n="",r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",o=0;o<t;o++)n+=r[s(r.length-1)];return e+n}function b(t,e){var n=new RegExp(Object.keys(t).join("|"),"g");return e.replace(n,function(e){return t[e]})}function w(t,e){var n=t.indexOf(e);return n>-1&&t.splice(n,1),t}function j(t){return t[0]}function O(t){return t[t.length-1]}function x(t,e){for(var n=t.length,r=[];n--;)e.indexOf(t[n])<0&&r.push(t[n]);return r}function E(t,e,n){t[e]!==n&&(t[e]=n)}function S(t,e){for(var n in e)t.hasOwnProperty(n)&&u(t[n])&&u(e[n])?Object.assign(t[n],e[n]):t[n]=e[n];return t}function L(t,e){var n={};for(var r in t)n[r]=e(t[r],r,t);return n}function P(t,e){var n={};for(var r in t)e.indexOf(r)>-1&&(n[r]=t[r]);return n}function I(t,e){var n={};for(var r in t)-1===e.indexOf(r)&&(n[r]=t[r]);return n}function N(t,e){for(var n=e.split("."),r=t,o=0;o<n.length;o++){if(void 0===r[n[o]])return;r=r[n[o]]}return r}function C(t,e,n){for(var r=e.split("."),o=r.length-1,i=0;i<o;i++)null==t[r[i]]&&(t[r[i]]={}),t=t[r[i]];t[r[o]]=n}function M(t,e){t[e]=void 0;try{delete t[e]}catch(t){}}function F(t){var e=document.location.href,n=e.indexOf(t+"=");if(-1==n)return!1;var r=e.slice(t.length+n+1),o=r.indexOf("&");return-1!=o&&(r=r.slice(0,o)),r}function H(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id_",e=t+m();return document.getElementById(e)||U.includes(e)?H(t):(U.push(e),e)}function k(t,e){for(;;){if(null==t.parentElement)return!1;if(t.parentElement===e)return!0;t=t.parentElement}}function A(t){function e(t){var n={x:t.offsetLeft,y:t.offsetTop},r={x:0,y:0};return null!=t.offsetParent&&(r=e(t.offsetParent)),{x:n.x+r.x,y:n.y+r.y}}return e(t)}function R(t,e){function n(t,e){if(t.parentElement)return e(t.parentElement)?t.parentElement:n(t.parentElement,e)}return n(t,e)}function W(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className)}function B(t,e){W(t,e)||(t.classList?t.classList.add(e):t.className+=" "+e)}function D(t){var e=t.style.display;t.style.display="block";var n={width:t.offsetWidth,height:t.offsetHeight};return t.style.display=e,n}function _(t,e,n){var r=A(n);return r.x<=t&&r.x+n.offsetWidth>=t&&r.y<=e&&r.y+n.offsetHeight>=e}function Z(t){var e=document.body,n=R(t,function(t){return W(t,"work-area")}),r=A(n);return{left:r.x,right:r.x+n.offsetWidth,top:r.y+50,bottom:e.offsetHeight<window.innerHeight?window.innerHeight:e.offsetHeight}}function $(t,e){for(var n,r,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=0,a=t.length-1,u=0;i>=0&&i<=a;){if(u>=o)throw Error("binarySearch: loop times is over "+o+", you can increase the limit.");n=Math.floor((a-i)/2+i),r=t[n];var c=e(r,t,u);if(c<0)a=n-1;else{if(!(c>0))return r;i=n+1}u++}return null}function J(){return new Promise(function(t,e){document&&"complete"===document.readyState?t():window.addEventListener("load",function e(){t(),window.removeEventListener("load",e)})})}function T(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:100,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e3;c(t)&&(o=r,r=i(n)?n:100,n=t,t=null);var a=q;return t&&e(a[t])&&(window.clearInterval(a[t]),delete a[t]),new Promise(function(i,u){function c(e){l<=o?n()&&(f(e,t),i()):(f(e,t),u(new Error("waitFor: Limit is reached"))),l++}function f(t,n){t&&(n&&e(a[n])?(window.clearInterval(a[n]),delete a[n]):window.clearInterval(t))}var l=0,s=window.setInterval(function(){c(s)},r);t&&(a[t]=s),c()})}var U=[],q={};t.isset=e,t.isArray=n,t.isBool=r,t.isNumber=o,t.isNumeric=i,t.isString=a,t.isObject=u,t.isFunction=c,t.isPromise=f,t.empty=l,t.numRand=s,t.numPad=d,t.studlyCase=p,t.snakeCase=g,t.camelCase=v,t.camelToWords=h,t.titleCase=y,t.strRand=m,t.replaceMultiple=b,t.arrayRemove=w,t.arrayFirst=j,t.arrayLast=O,t.arrayDiff=x,t.assignIfDifferent=E,t.objectMerge=S,t.objectMap=L,t.objectOnly=P,t.objectExcept=I,t.objectGet=N,t.objectSet=C,t.unset=M,t.getUrlParam=F,t.uniqueId=H,t.isDescendantOf=k,t.getOffset=A,t.findParent=R,t.hasClass=W,t.addClass=B,t.getElSize=D,t.isOffsetInEl=_,t.getBorder=Z,t.binarySearch=$,t.windowLoaded=J,t.storeOfWaitFor=q,t.waitFor=T,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=helper-js.min.js.map |
{ | ||
"name": "helper-js", | ||
"version": "1.0.8", | ||
"version": "1.0.10", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/helper-js.common.js", |
@@ -275,2 +275,20 @@ // is 各种判断 | ||
} | ||
export function addClass(el, className) { | ||
if (!hasClass(el, className)) { | ||
if (el.classList) | ||
{ el.classList.add(className) } | ||
else | ||
{ el.className += ' ' + className } | ||
} | ||
} | ||
export function getElSize(el) { | ||
const originDisplay = el.style.display | ||
el.style.display = 'block' | ||
const size = { | ||
width: el.offsetWidth, | ||
height: el.offsetHeight | ||
} | ||
el.style.display = originDisplay | ||
return size | ||
} | ||
/** | ||
@@ -277,0 +295,0 @@ * [isOffsetInEl] |
Sorry, the diff of this file is not supported yet
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
61398
1752