Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

helper-js

Package Overview
Dependencies
Maintainers
1
Versions
143
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

helper-js - npm Package Compare versions

Comparing version 1.0.15 to 1.0.16

21

dist/helper-js.common.js

@@ -351,2 +351,21 @@ /*!

}
// dom event
function onDOM(el, name, handler) {
if (el.addEventListener) {
// 所有主流浏览器,除了 IE 8 及更早 IE版本
el.addEventListener(name, handler);
} else if (el.attachEvent) {
// IE 8 及更早 IE 版本
el.attachEvent('on' + name, handler);
}
}
function offDOM(el, name, handler) {
if (el.removeEventListener) {
// 所有主流浏览器,除了 IE 8 及更早 IE版本
el.removeEventListener(name, handler);
} else if (el.detachEvent) {
// IE 8 及更早 IE 版本
el.detachEvent('on' + name, handler);
}
}
// advance

@@ -520,2 +539,4 @@ // binarySearch 二分查找

exports.getBorder = getBorder;
exports.onDOM = onDOM;
exports.offDOM = offDOM;
exports.binarySearch = binarySearch;

@@ -522,0 +543,0 @@ exports.windowLoaded = windowLoaded;

21

dist/helper-js.esm.js

@@ -347,2 +347,21 @@ /*!

}
// dom event
function onDOM(el, name, handler) {
if (el.addEventListener) {
// 所有主流浏览器,除了 IE 8 及更早 IE版本
el.addEventListener(name, handler);
} else if (el.attachEvent) {
// IE 8 及更早 IE 版本
el.attachEvent('on' + name, handler);
}
}
function offDOM(el, name, handler) {
if (el.removeEventListener) {
// 所有主流浏览器,除了 IE 8 及更早 IE版本
el.removeEventListener(name, handler);
} else if (el.detachEvent) {
// IE 8 及更早 IE 版本
el.detachEvent('on' + name, handler);
}
}
// advance

@@ -472,2 +491,2 @@ // binarySearch 二分查找

export { store, isset, isArray, isBool, isNumber, isNumeric, isString, isObject, isFunction, isPromise, empty, numRand, numPad, studlyCase, snakeCase, camelCase, camelToWords, titleCase, strRand, replaceMultiple, arrayRemove, arrayFirst, arrayLast, arrayDiff, toArrayIfNot, assignIfDifferent, objectMerge, objectMap, objectOnly, objectExcept, objectGet, objectSet, unset, getUrlParam, uniqueId, isDescendantOf, getOffset, findParent, hasClass, addClass, removeClass, getElSize, isOffsetInEl, getBorder, binarySearch, windowLoaded, waitFor, retry };
export { store, isset, isArray, isBool, isNumber, isNumeric, isString, isObject, isFunction, isPromise, empty, numRand, numPad, studlyCase, snakeCase, camelCase, camelToWords, titleCase, strRand, replaceMultiple, arrayRemove, arrayFirst, arrayLast, arrayDiff, toArrayIfNot, assignIfDifferent, objectMerge, objectMap, objectOnly, objectExcept, objectGet, objectSet, unset, getUrlParam, uniqueId, isDescendantOf, getOffset, findParent, hasClass, addClass, removeClass, getElSize, isOffsetInEl, getBorder, onDOM, offDOM, binarySearch, windowLoaded, waitFor, retry };

@@ -353,2 +353,21 @@ /*!

}
// dom event
function onDOM(el, name, handler) {
if (el.addEventListener) {
// 所有主流浏览器,除了 IE 8 及更早 IE版本
el.addEventListener(name, handler);
} else if (el.attachEvent) {
// IE 8 及更早 IE 版本
el.attachEvent('on' + name, handler);
}
}
function offDOM(el, name, handler) {
if (el.removeEventListener) {
// 所有主流浏览器,除了 IE 8 及更早 IE版本
el.removeEventListener(name, handler);
} else if (el.detachEvent) {
// IE 8 及更早 IE 版本
el.detachEvent('on' + name, handler);
}
}
// advance

@@ -522,2 +541,4 @@ // binarySearch 二分查找

exports.getBorder = getBorder;
exports.onDOM = onDOM;
exports.offDOM = offDOM;
exports.binarySearch = binarySearch;

@@ -524,0 +545,0 @@ exports.windowLoaded = windowLoaded;

2

dist/helper-js.min.js

@@ -8,3 +8,3 @@ /*!

!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 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){for(var n=void 0,r=0;(n=t.indexOf(e))>-1;)t.splice(n,1),r++;return r}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){return n(t)?t:[t]}function S(t,e,n){t[e]!==n&&(t[e]=n)}function I(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 L(t,e){var n={};for(var r in t)n[r]=e(t[r],r,t);return n}function N(t,e){var n={};for(var r in t)e.indexOf(r)>-1&&(n[r]=t[r]);return n}function P(t,e){var n={};for(var r in t)-1===e.indexOf(r)&&(n[r]=t[r]);return n}function C(t,e){for(var n=e.split("."),r=t,o=0;o<n.length;o++){if(null==r[n[o]])return null;r=r[n[o]]}return r}function F(t,e,n){var r=e.lastIndexOf("."),o=void 0,i=void 0;-1===r?(o=t,i=e):(o=C(t,e.substring(0,r)),i=e.substr(r)),o[i]=n}function M(t,e){t[e]=void 0;try{delete t[e]}catch(t){}}function A(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();G.uniqueId||(G.uniqueId={});var n=G.uniqueId;return document.getElementById(e)||n.includes(e)?H(t):(n.push(e),e)}function R(t,e){for(;;){if(null==t.parentElement)return!1;if(t.parentElement===e)return!0;t=t.parentElement}}function k(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 q(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){B(t,e)||(t.classList?t.classList.add(e):t.className+=" "+e)}function W(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}function $(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=k(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=q(t,function(t){return B(t,"work-area")}),r=k(n);return{left:r.x,right:r.x+n.offsetWidth,top:r.y+50,bottom:e.offsetHeight<window.innerHeight?window.innerHeight:e.offsetHeight}}function J(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 T(){return new Promise(function(t,e){document&&"complete"===document.readyState?t():window.addEventListener("load",function e(){t(),window.removeEventListener("load",e)})})}function U(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),G.waitFor||(G.waitFor={});var u=G.waitFor;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()})}function z(t){function e(n,u,a){return t(n,u,a).then(function(t){return delete o[i],t}).catch(function(t){return o[i]++,o[i]>=r?(delete o[i],Promise.reject(t)):e(n,u,a)})}function n(){var t=Math.random()+"";return o[t]?n():t}var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;G.retry||(G.retry={});var o=z,i=n();return o[i]=0,e}var G={};t.store=G,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=y,t.strRand=m,t.replaceMultiple=b,t.arrayRemove=w,t.arrayFirst=j,t.arrayLast=O,t.arrayDiff=x,t.toArrayIfNot=E,t.assignIfDifferent=S,t.objectMerge=I,t.objectMap=L,t.objectOnly=N,t.objectExcept=P,t.objectGet=C,t.objectSet=F,t.unset=M,t.getUrlParam=A,t.uniqueId=H,t.isDescendantOf=R,t.getOffset=k,t.findParent=q,t.hasClass=B,t.addClass=D,t.removeClass=W,t.getElSize=$,t.isOffsetInEl=_,t.getBorder=Z,t.binarySearch=J,t.windowLoaded=T,t.waitFor=U,t.retry=z,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 s(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 l(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 v(t){return t&&t[0].toUpperCase()+t.substr(1)}function p(t){return t.replace(/ /g,"-").replace(/_/g,"-").replace(/([^A-Z])([A-Z])/g,"$1-$2").replace(/--+/g,"-").replace(/^-|-$|/g,"").toLowerCase()}function g(t){for(var e=t.toString().split(/[-_]/),n=1;n<e.length;n++)e[n]=v(e[n]);return e.join("")}function h(t){return t.toString().trim().split(/(?=[A-Z])/)}function y(t){return h(v(g(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[l(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){for(var n=void 0,r=0;(n=t.indexOf(e))>-1;)t.splice(n,1),r++;return r}function j(t){return t[0]}function E(t){return t[t.length-1]}function O(t,e){for(var n=t.length,r=[];n--;)e.indexOf(t[n])<0&&r.push(t[n]);return r}function x(t){return n(t)?t:[t]}function L(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 I(t,e){var n={};for(var r in t)n[r]=e(t[r],r,t);return n}function N(t,e){var n={};for(var r in t)e.indexOf(r)>-1&&(n[r]=t[r]);return n}function P(t,e){var n={};for(var r in t)-1===e.indexOf(r)&&(n[r]=t[r]);return n}function M(t,e){for(var n=e.split("."),r=t,o=0;o<n.length;o++){if(null==r[n[o]])return null;r=r[n[o]]}return r}function C(t,e,n){var r=e.lastIndexOf("."),o=void 0,i=void 0;-1===r?(o=t,i=e):(o=M(t,e.substring(0,r)),i=e.substr(r)),o[i]=n}function F(t,e){t[e]=void 0;try{delete t[e]}catch(t){}}function A(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 D(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id_",e=t+m();Q.uniqueId||(Q.uniqueId={});var n=Q.uniqueId;return document.getElementById(e)||n.includes(e)?D(t):(n.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 q(t,e){return t.classList?t.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(t.className)}function B(t,e){q(t,e)||(t.classList?t.classList.add(e):t.className+=" "+e)}function W(t,e){t.classList?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")}function $(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=R(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=k(t,function(t){return q(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 J(t,e,n){t.addEventListener?t.addEventListener(e,n):t.attachEvent&&t.attachEvent("on"+e,n)}function T(t,e,n){t.removeEventListener?t.removeEventListener(e,n):t.detachEvent&&t.detachEvent("on"+e,n)}function U(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 z(){return new Promise(function(t,e){document&&"complete"===document.readyState?t():window.addEventListener("load",function e(){t(),window.removeEventListener("load",e)})})}function G(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),Q.waitFor||(Q.waitFor={});var a=Q.waitFor;return t&&e(a[t])&&(window.clearInterval(a[t]),delete a[t]),new Promise(function(i,u){function c(e){s<=o?n()&&(f(e,t),i()):(f(e,t),u(new Error("waitFor: Limit is reached"))),s++}function f(t,n){t&&(n&&e(a[n])?(window.clearInterval(a[n]),delete a[n]):window.clearInterval(t))}var s=0,l=window.setInterval(function(){c(l)},r);t&&(a[t]=l),c()})}function K(t){function e(n,a,u){return t(n,a,u).then(function(t){return delete o[i],t}).catch(function(t){return o[i]++,o[i]>=r?(delete o[i],Promise.reject(t)):e(n,a,u)})}function n(){var t=Math.random()+"";return o[t]?n():t}var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;Q.retry||(Q.retry={});var o=K,i=n();return o[i]=0,e}var Q={};t.store=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=s,t.numRand=l,t.numPad=d,t.studlyCase=v,t.snakeCase=p,t.camelCase=g,t.camelToWords=h,t.titleCase=y,t.strRand=m,t.replaceMultiple=b,t.arrayRemove=w,t.arrayFirst=j,t.arrayLast=E,t.arrayDiff=O,t.toArrayIfNot=x,t.assignIfDifferent=L,t.objectMerge=S,t.objectMap=I,t.objectOnly=N,t.objectExcept=P,t.objectGet=M,t.objectSet=C,t.unset=F,t.getUrlParam=A,t.uniqueId=D,t.isDescendantOf=H,t.getOffset=R,t.findParent=k,t.hasClass=q,t.addClass=B,t.removeClass=W,t.getElSize=$,t.isOffsetInEl=_,t.getBorder=Z,t.onDOM=J,t.offDOM=T,t.binarySearch=U,t.windowLoaded=z,t.waitFor=G,t.retry=K,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=helper-js.min.js.map
{
"name": "helper-js",
"version": "1.0.15",
"version": "1.0.16",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/helper-js.common.js",

@@ -336,2 +336,17 @@ // local store

}
// dom event
export function onDOM(el, name, handler) {
if (el.addEventListener) { // 所有主流浏览器,除了 IE 8 及更早 IE版本
el.addEventListener(name, handler)
} else if (el.attachEvent) { // IE 8 及更早 IE 版本
el.attachEvent(`on${name}`, handler)
}
}
export function offDOM(el, name, handler) {
if (el.removeEventListener) { // 所有主流浏览器,除了 IE 8 及更早 IE版本
el.removeEventListener(name, handler)
} else if (el.detachEvent) { // IE 8 及更早 IE 版本
el.detachEvent(`on${name}`, handler)
}
}
// advance

@@ -338,0 +353,0 @@ // binarySearch 二分查找

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc