New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@i.un/libs

Package Overview
Dependencies
Maintainers
0
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@i.un/libs - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

dist/browser/scroll.d.ts

44

dist/browser/dom.d.ts
/**
* 表示 DOM 中可能的子元素类型。
*/
export type ChildrenType = DomOptionsType | HTMLElement | Text | string;
export type ChildrenType = DomOptionsType | HTMLElement | SVGElement | Text | string;
/**

@@ -52,1 +52,43 @@ * 表示创建 DOM 元素的选项类型。

export declare function createElement({ tag, children, props, attrs, styles, }?: DomOptionsType): HTMLElement;
type SvgElement = {
tag: string;
attributes?: Record<string, string>;
children?: SvgElement | SvgElement[] | string;
};
type SvgOptions = {
width?: number;
height?: number;
};
/**
* 创建一个 SVG 元素。
*
* @param {SvgElement[] | SvgElement | string} elements - 要创建的 SVG 元素,可以是对象数组、单个对象或 innerHTML 字符串。
* @param {SvgOptions} [options] - SVG 的配置选项,包括宽度和高度。
* @returns {SVGElement} - 创建的 SVG 元素。
*
* @example
* // 使用嵌套对象
* const svg1 = createSvg(
* {
* tag: 'svg',
* children: [
* { tag: 'circle', attributes: { cx: '16', cy: '16', r: '10', fill: 'red' } },
* { tag: 'g', children:
* { tag: 'text', attributes: { x: '10', y: '20', fill: 'black' }, children: 'Hello' }
* }
* ]
* },
* { width: 64, height: 64 }
* );
* document.body.appendChild(svg1);
*
* @example
* // 使用 innerHTML
* const svg2 = createSvg(
* `<circle cx="16" cy="16" r="10" fill="red"></circle>
* <text x="10" y="20" fill="black">Hello</text>`
* );
* document.body.appendChild(svg2);
*/
export declare function createSvg(elements: SvgElement[] | SvgElement | string, options?: SvgOptions): SVGSVGElement;
export {};
export * from "./dom";
export * from "./scroll";

2

dist/index.modern.js

@@ -1,2 +0,2 @@

function t(t){return"function"==typeof(null==t?void 0:t.clone)}function n(t){const n=typeof t;return null===t||"string"===n||"number"===n||"boolean"===n||"undefined"===n}function e(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function o(t){return n(t)?String(t):JSON.stringify(t,function(t,n){return"object"!=typeof n||null===n||Array.isArray(n)?n:Object.keys(n).sort().reduce((t,e)=>(t[e]=n[e],t),{})})}function i(n){if(null===n||"object"!=typeof n)return n;if(t(n))return n.clone();if(Array.isArray(n))return n.map(t=>i(t));const e={};for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=i(n[t]));return e}function r(t,n){let e=null;return function(...o){const i=this;null!==e&&clearTimeout(e),e=setTimeout(()=>{t.apply(i,o),e=null},n)}}function c(t,n){let e=0;return function(...o){const i=Date.now();i-e>=n&&(t.apply(this,o),e=i)}}function u(t,n=0){return new Promise(e=>{0===n?e(t()):setTimeout(()=>{e(t())},n)})}const s={};function l(t){return s[t]}const f={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function a(t,n=f){return function(...e){const r=o(e)+t.name+(n.identifier||"");if(s[r])return Promise.resolve(i(l(r)));const c=r+"_l_o_a_d_i_n_g_";if(s[c]){const t=Object.assign({},f,n);return new Promise(n=>{const e=Date.now(),o=setInterval(()=>{s[r]?(clearInterval(o),n(i(l(r)))):Date.now()-e>t.timeout&&(s[c]=!1,clearInterval(o),n(i(t.timeoutResult)))},100)})}return s[c]=!0,t(...e).then(t=>(s[r]=t,i(s[r]))).catch(t=>{throw t}).finally(()=>{s[c]=!1})}}function d(t){const n=function n(...e){if(n.isExecuting)return void console.log(`Function(${t.name}) is executing.`);let o;n.isExecuting=!0;try{o=t(...e),o instanceof Promise?o.finally(()=>{n.isExecuting=!1}):n.isExecuting=!1}catch(t){throw n.isExecuting=!1,t}return o};return n.isExecuting=!1,n}function y(t,n,e,o=!1){if(n in t.style)t.style[n]=e;else{const i=o?"important":"";t.style.setProperty(n,String(e),i)}}function p({tag:t="div",children:n=[],props:e={},attrs:o={},styles:i={}}={}){const r=document.createElement(t);Object.assign(r,e);for(const[t,n]of Object.entries(o))!1!==n&&r.setAttribute(t,n);for(const[t,n]of Object.entries(i))y(r,t,n);const c=Array.isArray(n)?n:[n];for(const t of c)t&&("object"==typeof t?t instanceof HTMLElement||t instanceof Text?r.appendChild(t):r.appendChild(p(t)):r.appendChild(document.createTextNode(t)));return r}export{a as cacheWrapper,i as cloneDeep,p as createElement,r as debounce,u as delayExecution,o as generateStableUniqueKey,e as getGlobal,t as isCloneable,n as isPrimitive,d as singleExecutionWrapper,c as throttle};
function t(t){return"function"==typeof(null==t?void 0:t.clone)}function e(t){const e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function n(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function r(t){return e(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})})}function o(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(t=>o(t));const n={};for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(n[t]=o(e[t]));return n}function i(t,e){let n=null;return function(...r){const o=this;null!==n&&clearTimeout(n),n=setTimeout(()=>{t.apply(o,r),n=null},e)}}function s(t,e){let n=0;return function(...r){const o=Date.now();o-n>=e&&(t.apply(this,r),n=o)}}function c(t,e=0){return new Promise(n=>{0===e?n(t()):setTimeout(()=>{n(t())},e)})}const u={};function l(t){return u[t]}const f={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function a(t,e=f){return function(...n){const i=r(n)+t.name+(e.identifier||"");if(u[i])return Promise.resolve(o(l(i)));const s=i+"_l_o_a_d_i_n_g_";if(u[s]){const t=Object.assign({},f,e);return new Promise(e=>{const n=Date.now(),r=setInterval(()=>{u[i]?(clearInterval(r),e(o(l(i)))):Date.now()-n>t.timeout&&(u[s]=!1,clearInterval(r),e(o(t.timeoutResult)))},100)})}return u[s]=!0,t(...n).then(t=>(u[i]=t,o(u[i]))).catch(t=>{throw t}).finally(()=>{u[s]=!1})}}function d(t){const e=function e(...n){if(e.isExecuting)return void console.log(`Function(${t.name}) is executing.`);let r;e.isExecuting=!0;try{r=t(...n),r instanceof Promise?r.finally(()=>{e.isExecuting=!1}):e.isExecuting=!1}catch(t){throw e.isExecuting=!1,t}return r};return e.isExecuting=!1,e}function g(t,e,n,r=!1){if(e in t.style)t.style[e]=n;else{const o=r?"important":"";t.style.setProperty(e,String(n),o)}}function p({tag:t="div",children:e=[],props:n={},attrs:r={},styles:o={}}={}){const i=document.createElement(t);Object.assign(i,n);for(const[t,e]of Object.entries(r))!1!==e&&i.setAttribute(t,e);for(const[t,e]of Object.entries(o))g(i,t,e);const s=Array.isArray(e)?e:[e];for(const t of s)t&&("object"==typeof t?t instanceof HTMLElement||t instanceof Text?i.appendChild(t):i.appendChild(p(t)):i.appendChild(document.createTextNode(t)));return i}function y(t,e){const{width:n=32,height:r=32}=e||{},o=document.createElementNS("http://www.w3.org/2000/svg","svg");return o.setAttribute("width",n.toString()),o.setAttribute("height",r.toString()),o.setAttribute("viewBox",`0 0 ${n} ${r}`),"string"==typeof t?o.innerHTML=t:(Array.isArray(t)?t:[t]).forEach(t=>{o.appendChild(h(t))}),o}function h(t){const{tag:e,attributes:n,children:r}=t,o=document.createElementNS("http://www.w3.org/2000/svg",e);if(n)for(const[t,e]of Object.entries(n))o.setAttribute(t,e);return"string"==typeof r?o.textContent=r:r&&(Array.isArray(r)?r:[r]).forEach(t=>{o.appendChild(h(t))}),o}function m(t){t&&setTimeout(()=>{t.scrollTop=t.scrollHeight},0)}function w(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",()=>{!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&m(t))}export{a as cacheWrapper,o as cloneDeep,p as createElement,y as createSvg,i as debounce,c as delayExecution,r as generateStableUniqueKey,n as getGlobal,t as isCloneable,e as isPrimitive,m as scrollToBottom,w as scrollToBottomIfNeeded,d as singleExecutionWrapper,s as throttle};
//# sourceMappingURL=index.modern.js.map

@@ -1,2 +0,2 @@

function n(n){return"function"==typeof(null==n?void 0:n.clone)}function t(n){var t=typeof n;return null===n||"string"===t||"number"===t||"boolean"===t||"undefined"===t}function e(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function r(n){return t(n)?String(n):JSON.stringify(n,function(n,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce(function(n,e){return n[e]=t[e],n},{})})}function i(t){if(null===t||"object"!=typeof t)return t;if(n(t))return t.clone();if(Array.isArray(t))return t.map(function(n){return i(n)});var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=i(t[r]));return e}function o(n,t){var e=null;return function(){var r=arguments,i=this;null!==e&&clearTimeout(e),e=setTimeout(function(){n.apply(i,[].slice.call(r)),e=null},t)}}function u(n,t){var e=0;return function(){var r=Date.now();r-e>=t&&(n.apply(this,[].slice.call(arguments)),e=r)}}function a(n,t){return void 0===t&&(t=0),new Promise(function(e){0===t?e(n()):setTimeout(function(){e(n())},t)})}var l={};function c(n){return l[n]}var f={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function s(n,t){return void 0===t&&(t=f),function(){var e=[].slice.call(arguments),o=r(e)+n.name+(t.identifier||"");if(l[o])return Promise.resolve(i(c(o)));var u=o+"_l_o_a_d_i_n_g_";if(l[u]){var a=Object.assign({},f,t);return new Promise(function(n){var t=Date.now(),e=setInterval(function(){l[o]?(clearInterval(e),n(i(c(o)))):Date.now()-t>a.timeout&&(l[u]=!1,clearInterval(e),n(i(a.timeoutResult)))},100)})}return l[u]=!0,n.apply(void 0,e).then(function(n){return l[o]=n,i(l[o])}).catch(function(n){throw n}).finally(function(){l[u]=!1})}}function d(n){var t=function(){if(!t.isExecuting){var e;t.isExecuting=!0;try{(e=n.apply(void 0,[].slice.call(arguments)))instanceof Promise?e.finally(function(){t.isExecuting=!1}):t.isExecuting=!1}catch(n){throw t.isExecuting=!1,n}return e}console.log("Function("+n.name+") is executing.")};return t.isExecuting=!1,t}function v(n,t){(null==t||t>n.length)&&(t=n.length);for(var e=0,r=Array(t);e<t;e++)r[e]=n[e];return r}function y(n,t,e,r){if(void 0===r&&(r=!1),t in n.style)n.style[t]=e;else{var i=r?"important":"";n.style.setProperty(t,String(e),i)}}function p(n){var t=void 0===n?{}:n,e=t.tag,r=t.children,i=void 0===r?[]:r,o=t.props,u=void 0===o?{}:o,a=t.attrs,l=void 0===a?{}:a,c=t.styles,f=void 0===c?{}:c,s=document.createElement(void 0===e?"div":e);Object.assign(s,u);for(var d=0,m=Object.entries(l);d<m.length;d++){var g=m[d],b=g[1];!1!==b&&s.setAttribute(g[0],b)}for(var h=0,w=Object.entries(f);h<w.length;h++){var A=w[h];y(s,A[0],A[1])}for(var j,x=function(n){var t="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(t)return(t=t.call(n)).next.bind(t);if(Array.isArray(n)||(t=function(n,t){if(n){if("string"==typeof n)return v(n,t);var e={}.toString.call(n).slice(8,-1);return"Object"===e&&n.constructor&&(e=n.constructor.name),"Map"===e||"Set"===e?Array.from(n):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?v(n,t):void 0}}(n))){t&&(n=t);var e=0;return function(){return e>=n.length?{done:!0}:{done:!1,value:n[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(i)?i:[i]);!(j=x()).done;){var E=j.value;E&&("object"==typeof E?E instanceof HTMLElement||E instanceof Text?s.appendChild(E):s.appendChild(p(E)):s.appendChild(document.createTextNode(E)))}return s}export{s as cacheWrapper,i as cloneDeep,p as createElement,o as debounce,a as delayExecution,r as generateStableUniqueKey,e as getGlobal,n as isCloneable,t as isPrimitive,d as singleExecutionWrapper,u as throttle};
function t(t){return"function"==typeof(null==t?void 0:t.clone)}function e(t){var e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function n(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function r(t){return e(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{})})}function i(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(function(t){return i(t)});var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=i(e[r]));return n}function o(t,e){var n=null;return function(){var r=arguments,i=this;null!==n&&clearTimeout(n),n=setTimeout(function(){t.apply(i,[].slice.call(r)),n=null},e)}}function a(t,e){var n=0;return function(){var r=Date.now();r-n>=e&&(t.apply(this,[].slice.call(arguments)),n=r)}}function u(t,e){return void 0===e&&(e=0),new Promise(function(n){0===e?n(t()):setTimeout(function(){n(t())},e)})}var c={};function l(t){return c[t]}var s={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function f(t,e){return void 0===e&&(e=s),function(){var n=[].slice.call(arguments),o=r(n)+t.name+(e.identifier||"");if(c[o])return Promise.resolve(i(l(o)));var a=o+"_l_o_a_d_i_n_g_";if(c[a]){var u=Object.assign({},s,e);return new Promise(function(t){var e=Date.now(),n=setInterval(function(){c[o]?(clearInterval(n),t(i(l(o)))):Date.now()-e>u.timeout&&(c[a]=!1,clearInterval(n),t(i(u.timeoutResult)))},100)})}return c[a]=!0,t.apply(void 0,n).then(function(t){return c[o]=t,i(c[o])}).catch(function(t){throw t}).finally(function(){c[a]=!1})}}function d(t){var e=function(){if(!e.isExecuting){var n;e.isExecuting=!0;try{(n=t.apply(void 0,[].slice.call(arguments)))instanceof Promise?n.finally(function(){e.isExecuting=!1}):e.isExecuting=!1}catch(t){throw e.isExecuting=!1,t}return n}console.log("Function("+t.name+") is executing.")};return e.isExecuting=!1,e}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function y(t,e,n,r){if(void 0===r&&(r=!1),e in t.style)t.style[e]=n;else{var i=r?"important":"";t.style.setProperty(e,String(n),i)}}function p(t){var e=void 0===t?{}:t,n=e.tag,r=e.children,i=void 0===r?[]:r,o=e.props,a=void 0===o?{}:o,u=e.attrs,c=void 0===u?{}:u,l=e.styles,s=void 0===l?{}:l,f=document.createElement(void 0===n?"div":n);Object.assign(f,a);for(var d=0,g=Object.entries(c);d<g.length;d++){var h=g[d],m=h[1];!1!==m&&f.setAttribute(h[0],m)}for(var b=0,w=Object.entries(s);b<w.length;b++){var A=w[b];y(f,A[0],A[1])}for(var E,S=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return v(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?v(t,e):void 0}}(t))){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(i)?i:[i]);!(E=S()).done;){var x=E.value;x&&("object"==typeof x?x instanceof HTMLElement||x instanceof Text?f.appendChild(x):f.appendChild(p(x)):f.appendChild(document.createTextNode(x)))}return f}function g(t,e){var n=e||{},r=n.width,i=void 0===r?32:r,o=n.height,a=void 0===o?32:o,u=document.createElementNS("http://www.w3.org/2000/svg","svg");return u.setAttribute("width",i.toString()),u.setAttribute("height",a.toString()),u.setAttribute("viewBox","0 0 "+i+" "+a),"string"==typeof t?u.innerHTML=t:(Array.isArray(t)?t:[t]).forEach(function(t){u.appendChild(h(t))}),u}function h(t){var e=t.attributes,n=t.children,r=document.createElementNS("http://www.w3.org/2000/svg",t.tag);if(e)for(var i=0,o=Object.entries(e);i<o.length;i++){var a=o[i];r.setAttribute(a[0],a[1])}return"string"==typeof n?r.textContent=n:n&&(Array.isArray(n)?n:[n]).forEach(function(t){r.appendChild(h(t))}),r}function m(t){t&&setTimeout(function(){t.scrollTop=t.scrollHeight},0)}function b(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",function(){!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&m(t))}export{f as cacheWrapper,i as cloneDeep,p as createElement,g as createSvg,o as debounce,u as delayExecution,r as generateStableUniqueKey,n as getGlobal,t as isCloneable,e as isPrimitive,m as scrollToBottom,b as scrollToBottomIfNeeded,d as singleExecutionWrapper,a as throttle};
//# sourceMappingURL=index.module.js.map

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).iunLibs={})}(this,function(e){function n(e){return"function"==typeof(null==e?void 0:e.clone)}function t(e){var n=typeof e;return null===e||"string"===n||"number"===n||"boolean"===n||"undefined"===n}function r(e){return t(e)?String(e):JSON.stringify(e,function(e,n){return"object"!=typeof n||null===n||Array.isArray(n)?n:Object.keys(n).sort().reduce(function(e,t){return e[t]=n[t],e},{})})}function i(e){if(null===e||"object"!=typeof e)return e;if(n(e))return e.clone();if(Array.isArray(e))return e.map(function(e){return i(e)});var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=i(e[r]));return t}var o={};function u(e){return o[e]}var a={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function l(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t<n;t++)r[t]=e[t];return r}function c(e,n,t,r){if(void 0===r&&(r=!1),n in e.style)e.style[n]=t;else{var i=r?"important":"";e.style.setProperty(n,String(t),i)}}e.cacheWrapper=function(e,n){return void 0===n&&(n=a),function(){var t=[].slice.call(arguments),l=r(t)+e.name+(n.identifier||"");if(o[l])return Promise.resolve(i(u(l)));var c=l+"_l_o_a_d_i_n_g_";if(o[c]){var f=Object.assign({},a,n);return new Promise(function(e){var n=Date.now(),t=setInterval(function(){o[l]?(clearInterval(t),e(i(u(l)))):Date.now()-n>f.timeout&&(o[c]=!1,clearInterval(t),e(i(f.timeoutResult)))},100)})}return o[c]=!0,e.apply(void 0,t).then(function(e){return o[l]=e,i(o[l])}).catch(function(e){throw e}).finally(function(){o[c]=!1})}},e.cloneDeep=i,e.createElement=function e(n){var t=void 0===n?{}:n,r=t.tag,i=t.children,o=void 0===i?[]:i,u=t.props,a=void 0===u?{}:u,f=t.attrs,s=void 0===f?{}:f,d=t.styles,v=void 0===d?{}:d,p=document.createElement(void 0===r?"div":r);Object.assign(p,a);for(var y=0,m=Object.entries(s);y<m.length;y++){var g=m[y],b=g[1];!1!==b&&p.setAttribute(g[0],b)}for(var h=0,x=Object.entries(v);h<x.length;h++){var w=x[h];c(p,w[0],w[1])}for(var A,j=function(e){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,n){if(e){if("string"==typeof e)return l(e,n);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?l(e,n):void 0}}(e))){n&&(e=n);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(o)?o:[o]);!(A=j()).done;){var E=A.value;E&&("object"==typeof E?E instanceof HTMLElement||E instanceof Text?p.appendChild(E):p.appendChild(e(E)):p.appendChild(document.createTextNode(E)))}return p},e.debounce=function(e,n){var t=null;return function(){var r=arguments,i=this;null!==t&&clearTimeout(t),t=setTimeout(function(){e.apply(i,[].slice.call(r)),t=null},n)}},e.delayExecution=function(e,n){return void 0===n&&(n=0),new Promise(function(t){0===n?t(e()):setTimeout(function(){t(e())},n)})},e.generateStableUniqueKey=r,e.getGlobal=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this},e.isCloneable=n,e.isPrimitive=t,e.singleExecutionWrapper=function(e){var n=function(){if(!n.isExecuting){var t;n.isExecuting=!0;try{(t=e.apply(void 0,[].slice.call(arguments)))instanceof Promise?t.finally(function(){n.isExecuting=!1}):n.isExecuting=!1}catch(e){throw n.isExecuting=!1,e}return t}console.log("Function("+e.name+") is executing.")};return n.isExecuting=!1,n},e.throttle=function(e,n){var t=0;return function(){var r=Date.now();r-t>=n&&(e.apply(this,[].slice.call(arguments)),t=r)}}});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t||self).iunLibs={})}(this,function(t){function e(t){return"function"==typeof(null==t?void 0:t.clone)}function n(t){var e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function r(t){return n(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{})})}function i(t){if(null===t||"object"!=typeof t)return t;if(e(t))return t.clone();if(Array.isArray(t))return t.map(function(t){return i(t)});var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=i(t[r]));return n}var o={};function a(t){return o[t]}var u={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function c(t,e,n,r){if(void 0===r&&(r=!1),e in t.style)t.style[e]=n;else{var i=r?"important":"";t.style.setProperty(e,String(n),i)}}function s(t){var e=t.attributes,n=t.children,r=document.createElementNS("http://www.w3.org/2000/svg",t.tag);if(e)for(var i=0,o=Object.entries(e);i<o.length;i++){var a=o[i];r.setAttribute(a[0],a[1])}return"string"==typeof n?r.textContent=n:n&&(Array.isArray(n)?n:[n]).forEach(function(t){r.appendChild(s(t))}),r}function f(t){t&&setTimeout(function(){t.scrollTop=t.scrollHeight},0)}t.cacheWrapper=function(t,e){return void 0===e&&(e=u),function(){var n=[].slice.call(arguments),l=r(n)+t.name+(e.identifier||"");if(o[l])return Promise.resolve(i(a(l)));var c=l+"_l_o_a_d_i_n_g_";if(o[c]){var s=Object.assign({},u,e);return new Promise(function(t){var e=Date.now(),n=setInterval(function(){o[l]?(clearInterval(n),t(i(a(l)))):Date.now()-e>s.timeout&&(o[c]=!1,clearInterval(n),t(i(s.timeoutResult)))},100)})}return o[c]=!0,t.apply(void 0,n).then(function(t){return o[l]=t,i(o[l])}).catch(function(t){throw t}).finally(function(){o[c]=!1})}},t.cloneDeep=i,t.createElement=function t(e){var n=void 0===e?{}:e,r=n.tag,i=n.children,o=void 0===i?[]:i,a=n.props,u=void 0===a?{}:a,s=n.attrs,f=void 0===s?{}:s,d=n.styles,v=void 0===d?{}:d,p=document.createElement(void 0===r?"div":r);Object.assign(p,u);for(var y=0,g=Object.entries(f);y<g.length;y++){var h=g[y],m=h[1];!1!==m&&p.setAttribute(h[0],m)}for(var b=0,w=Object.entries(v);b<w.length;b++){var A=w[b];c(p,A[0],A[1])}for(var x,E=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return l(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(t,e):void 0}}(t))){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(o)?o:[o]);!(x=E()).done;){var T=x.value;T&&("object"==typeof T?T instanceof HTMLElement||T instanceof Text?p.appendChild(T):p.appendChild(t(T)):p.appendChild(document.createTextNode(T)))}return p},t.createSvg=function(t,e){var n=e||{},r=n.width,i=void 0===r?32:r,o=n.height,a=void 0===o?32:o,u=document.createElementNS("http://www.w3.org/2000/svg","svg");return u.setAttribute("width",i.toString()),u.setAttribute("height",a.toString()),u.setAttribute("viewBox","0 0 "+i+" "+a),"string"==typeof t?u.innerHTML=t:(Array.isArray(t)?t:[t]).forEach(function(t){u.appendChild(s(t))}),u},t.debounce=function(t,e){var n=null;return function(){var r=arguments,i=this;null!==n&&clearTimeout(n),n=setTimeout(function(){t.apply(i,[].slice.call(r)),n=null},e)}},t.delayExecution=function(t,e){return void 0===e&&(e=0),new Promise(function(n){0===e?n(t()):setTimeout(function(){n(t())},e)})},t.generateStableUniqueKey=r,t.getGlobal=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this},t.isCloneable=e,t.isPrimitive=n,t.scrollToBottom=f,t.scrollToBottomIfNeeded=function(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",function(){!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&f(t))},t.singleExecutionWrapper=function(t){var e=function(){if(!e.isExecuting){var n;e.isExecuting=!0;try{(n=t.apply(void 0,[].slice.call(arguments)))instanceof Promise?n.finally(function(){e.isExecuting=!1}):e.isExecuting=!1}catch(t){throw e.isExecuting=!1,t}return n}console.log("Function("+t.name+") is executing.")};return e.isExecuting=!1,e},t.throttle=function(t,e){var n=0;return function(){var r=Date.now();r-n>=e&&(t.apply(this,[].slice.call(arguments)),n=r)}}});
//# sourceMappingURL=index.umd.js.map
{
"name": "@i.un/libs",
"version": "0.0.12",
"version": "0.0.13",
"description": "一个实用的ts函数库",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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