@tko/utils
Advanced tools
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
| export function createSymbolOrString(identifier) { | ||
| return Symbol(identifier); | ||
| } | ||
| export function stringTrim(value) { | ||
| return String(value ?? "").trim(); | ||
| } | ||
| export function stringStartsWith(value, prefix) { | ||
| return (value ?? "").startsWith(prefix); | ||
| } | ||
| export function overwriteLengthPropertyIfSupported(fn, descriptor) { | ||
| Object.defineProperty(fn, "length", descriptor); | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../src/compat.ts"], | ||
| "sourcesContent": ["// Compat passthroughs preserving the public @tko/utils API after the\n// post-Symbol/post-IE9 polyfill removals. Each function delegates to a\n// native API; kept so consumers importing these names continue to work.\n// All entries here are slated for removal in the next major version.\n\n/**\n * @deprecated Use `Symbol(identifier)` directly. Will be removed in a future major.\n */\nexport function createSymbolOrString(identifier: string): symbol {\n return Symbol(identifier)\n}\n\n/**\n * @deprecated Use `String(value ?? '').trim()` directly (or `String.prototype.trim`\n * when the input is known to be a string). Will be removed in a future major.\n */\nexport function stringTrim(value: any): string {\n return String(value ?? '').trim()\n}\n\n/**\n * @deprecated Use `String.prototype.startsWith` directly. Will be removed in a future major.\n */\nexport function stringStartsWith(value: string, prefix: string): boolean {\n return (value ?? '').startsWith(prefix)\n}\n\n/**\n * @deprecated Use `Object.defineProperty(fn, 'length', descriptor)` directly.\n * Will be removed in a future major.\n */\nexport function overwriteLengthPropertyIfSupported(fn: Function, descriptor: PropertyDescriptor): void {\n Object.defineProperty(fn, 'length', descriptor)\n}\n"], | ||
| "mappings": ";;AAQO,gBAAS,qBAAqB,YAA4B;AAC/D,SAAO,OAAO,UAAU;AAC1B;AAMO,gBAAS,WAAW,OAAoB;AAC7C,SAAO,OAAO,SAAS,EAAE,EAAE,KAAK;AAClC;AAKO,gBAAS,iBAAiB,OAAe,QAAyB;AACvE,UAAQ,SAAS,IAAI,WAAW,MAAM;AACxC;AAMO,gBAAS,mCAAmC,IAAc,YAAsC;AACrG,SAAO,eAAe,IAAI,UAAU,UAAU;AAChD;", | ||
| "names": [] | ||
| } |
| # @tko/utils | ||
| Core utilities (DOM manipulation, arrays, events, tasks) | ||
| Part of [TKO](https://tko.io) — modern Knockout.js. [Docs](https://tko.io) · [Source](https://github.com/knockout/tko/tree/main/packages/utils) |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ const { isArray } = Array; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ import { safeSetTimeout } from "./error.js"; |
+8
-19
@@ -1,28 +0,17 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
| import { arrayForEach, addOrRemoveItem } from "./array.js"; | ||
| const cssClassNameRegex = /\S+/g; | ||
| function toggleDomNodeCssClass(node, classNames, shouldHaveClass) { | ||
| let addOrRemoveFn; | ||
| if (!classNames) { | ||
| return; | ||
| } | ||
| if (typeof node.classList === "object") { | ||
| addOrRemoveFn = node.classList[shouldHaveClass ? "add" : "remove"]; | ||
| arrayForEach(classNames.match(cssClassNameRegex), function(className) { | ||
| addOrRemoveFn.call(node.classList, className); | ||
| }); | ||
| } else if (typeof node.className["baseVal"] === "string") { | ||
| toggleObjectClassPropertyString(node.className, "baseVal", classNames, shouldHaveClass); | ||
| } else { | ||
| toggleObjectClassPropertyString(node, "className", classNames, shouldHaveClass); | ||
| const tokens = classNames.match(cssClassNameRegex); | ||
| if (!tokens) { | ||
| return; | ||
| } | ||
| const method = shouldHaveClass ? "add" : "remove"; | ||
| for (const token of tokens) { | ||
| node.classList[method](token); | ||
| } | ||
| } | ||
| function toggleObjectClassPropertyString(obj, prop, classNames, shouldHaveClass) { | ||
| const currentClassNames = obj[prop].match(cssClassNameRegex) || []; | ||
| arrayForEach(classNames.match(cssClassNameRegex), function(className) { | ||
| addOrRemoveItem(currentClassNames, className, shouldHaveClass); | ||
| }); | ||
| obj[prop] = currentClassNames.join(" "); | ||
| } | ||
| export { toggleDomNodeCssClass }; |
+2
-2
| { | ||
| "version": 3, | ||
| "sources": ["../src/css.ts"], | ||
| "sourcesContent": ["//\n// DOM - CSS\n//\n\nimport { arrayForEach, addOrRemoveItem } from './array'\n\n// For details on the pattern for changing node classes\n// see: https://github.com/knockout/knockout/issues/1597\nconst cssClassNameRegex = /\\S+/g\n\nfunction toggleDomNodeCssClass(node: Element, classNames: string, shouldHaveClass?: boolean): void {\n let addOrRemoveFn\n if (!classNames) {\n return\n }\n if (typeof node.classList === 'object') {\n addOrRemoveFn = node.classList[shouldHaveClass ? 'add' : 'remove']\n arrayForEach(classNames.match(cssClassNameRegex)!, function (className) {\n addOrRemoveFn.call(node.classList, className)\n })\n } else if (typeof node.className['baseVal'] === 'string') {\n // SVG tag .classNames is an SVGAnimatedString instance\n toggleObjectClassPropertyString(node.className, 'baseVal', classNames, shouldHaveClass)\n } else {\n // node.className ought to be a string.\n toggleObjectClassPropertyString(node, 'className', classNames, shouldHaveClass)\n }\n}\n\nfunction toggleObjectClassPropertyString(obj, prop, classNames, shouldHaveClass) {\n // obj/prop is either a node/'className' or a SVGAnimatedString/'baseVal'.\n const currentClassNames = obj[prop].match(cssClassNameRegex) || []\n arrayForEach(classNames.match(cssClassNameRegex), function (className) {\n addOrRemoveItem(currentClassNames, className, shouldHaveClass)\n })\n obj[prop] = currentClassNames.join(' ')\n}\n\nexport { toggleDomNodeCssClass }\n"], | ||
| "mappings": ";;AAIA,SAAS,cAAc,uBAAuB;AAI9C,MAAM,oBAAoB;AAE1B,SAAS,sBAAsB,MAAe,YAAoB,iBAAiC;AACjG,MAAI;AACJ,MAAI,CAAC,YAAY;AACf;AAAA,EACF;AACA,MAAI,OAAO,KAAK,cAAc,UAAU;AACtC,oBAAgB,KAAK,UAAU,kBAAkB,QAAQ,QAAQ;AACjE,iBAAa,WAAW,MAAM,iBAAiB,GAAI,SAAU,WAAW;AACtE,oBAAc,KAAK,KAAK,WAAW,SAAS;AAAA,IAC9C,CAAC;AAAA,EACH,WAAW,OAAO,KAAK,UAAU,SAAS,MAAM,UAAU;AAExD,oCAAgC,KAAK,WAAW,WAAW,YAAY,eAAe;AAAA,EACxF,OAAO;AAEL,oCAAgC,MAAM,aAAa,YAAY,eAAe;AAAA,EAChF;AACF;AAEA,SAAS,gCAAgC,KAAK,MAAM,YAAY,iBAAiB;AAE/E,QAAM,oBAAoB,IAAI,IAAI,EAAE,MAAM,iBAAiB,KAAK,CAAC;AACjE,eAAa,WAAW,MAAM,iBAAiB,GAAG,SAAU,WAAW;AACrE,oBAAgB,mBAAmB,WAAW,eAAe;AAAA,EAC/D,CAAC;AACD,MAAI,IAAI,IAAI,kBAAkB,KAAK,GAAG;AACxC;AAEA,SAAS;", | ||
| "sourcesContent": ["//\n// DOM - CSS\n//\n\n// See: https://github.com/knockout/knockout/issues/1597\nconst cssClassNameRegex = /\\S+/g\n\nfunction toggleDomNodeCssClass(node: Element, classNames: string, shouldHaveClass?: boolean): void {\n if (!classNames) {\n return\n }\n const tokens = classNames.match(cssClassNameRegex)\n if (!tokens) {\n return\n }\n const method = shouldHaveClass ? 'add' : 'remove'\n for (const token of tokens) {\n node.classList[method](token)\n }\n}\n\nexport { toggleDomNodeCssClass }\n"], | ||
| "mappings": ";;AAKA,MAAM,oBAAoB;AAE1B,SAAS,sBAAsB,MAAe,YAAoB,iBAAiC;AACjG,MAAI,CAAC,YAAY;AACf;AAAA,EACF;AACA,QAAM,SAAS,WAAW,MAAM,iBAAiB;AACjD,MAAI,CAAC,QAAQ;AACX;AAAA,EACF;AACA,QAAM,SAAS,kBAAkB,QAAQ;AACzC,aAAW,SAAS,QAAQ;AAC1B,SAAK,UAAU,MAAM,EAAE,KAAK;AAAA,EAC9B;AACF;AAEA,SAAS;", | ||
| "names": [] | ||
| } |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ const datastoreTime = (/* @__PURE__ */ new Date()).getTime(); |
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ import * as domData from "./data.js"; |
+18
-28
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -55,32 +55,22 @@ import { objectForEach } from "../object.js"; | ||
| options.jQuery(element).trigger(eventType); | ||
| } else if (typeof document.createEvent === "function") { | ||
| if (typeof element.dispatchEvent === "function") { | ||
| const eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents"; | ||
| const event = document.createEvent(eventCategory); | ||
| event.initEvent( | ||
| eventType, | ||
| true, | ||
| true, | ||
| options.global, | ||
| 0, | ||
| 0, | ||
| 0, | ||
| 0, | ||
| 0, | ||
| false, | ||
| false, | ||
| false, | ||
| false, | ||
| 0, | ||
| element | ||
| ); | ||
| element.dispatchEvent(event); | ||
| } else { | ||
| throw new Error("The supplied element doesn't support dispatchEvent"); | ||
| return; | ||
| } | ||
| if (typeof element.dispatchEvent !== "function") { | ||
| if (useClickWorkaround && hasClick(element)) { | ||
| element.click(); | ||
| return; | ||
| } | ||
| } else if (useClickWorkaround && hasClick(element)) { | ||
| element.click(); | ||
| throw new Error("The supplied element doesn't support dispatchEvent"); | ||
| } | ||
| const eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents"; | ||
| const view = options.global; | ||
| let event; | ||
| if (eventCategory === "MouseEvents" && typeof MouseEvent === "function") { | ||
| event = new MouseEvent(eventType, { bubbles: true, cancelable: true, view, relatedTarget: element }); | ||
| } else if (eventCategory === "UIEvents" && typeof KeyboardEvent === "function") { | ||
| event = new KeyboardEvent(eventType, { bubbles: true, cancelable: true, view }); | ||
| } else { | ||
| throw new Error("Browser doesn't support triggering events"); | ||
| event = new Event(eventType, { bubbles: true, cancelable: true }); | ||
| } | ||
| element.dispatchEvent(event); | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../../src/dom/event.ts"], | ||
| "sourcesContent": ["//\n// DOM Events\n//\n\nimport { objectForEach } from '../object'\nimport { catchFunctionErrors } from '../error'\nimport { tagNameLower } from './info'\n\nimport options from '../options'\n\n// Represent the known event types in a compact way, then at runtime transform it into a hash with event name as key (for fast lookup)\nconst knownEvents = {},\n knownEventTypesByEventName = {}\n\nknownEvents['UIEvents'] = ['keyup', 'keydown', 'keypress']\n\nknownEvents['MouseEvents'] = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mouseup',\n 'mousemove',\n 'mouseover',\n 'mouseout',\n 'mouseenter',\n 'mouseleave'\n]\n\nobjectForEach(knownEvents, function (eventType, knownEventsForType) {\n if (knownEventsForType.length) {\n for (let i = 0, j = knownEventsForType.length; i < j; i++) {\n knownEventTypesByEventName[knownEventsForType[i]] = eventType\n }\n }\n})\n\nfunction isClickOnCheckableElement(element: Element, eventType: string) {\n if (tagNameLower(element) !== 'input' || !(element as HTMLInputElement).type) return false\n if (eventType.toLowerCase() != 'click') return false\n const inputType = (element as HTMLInputElement).type\n return inputType == 'checkbox' || inputType == 'radio'\n}\n\nexport function registerEventHandler(\n element: Element,\n eventType: string,\n handler: EventListener,\n eventOptions = false\n): void {\n const wrappedHandler = catchFunctionErrors(handler)\n const mustUseNative = Boolean(eventOptions)\n const jQuery = options.jQuery\n\n if (!options.useOnlyNativeEvents && !mustUseNative && jQuery) {\n jQuery(element).on(eventType, wrappedHandler)\n } else if (typeof element.addEventListener === 'function') {\n element.addEventListener(eventType, wrappedHandler, eventOptions)\n } else {\n throw new Error(\"Browser doesn't support addEventListener\")\n }\n}\n\nfunction hasClick(element: Element): element is Element & { click(): void } {\n return typeof (element as any).click === 'function'\n}\n\nexport function triggerEvent(element: Element, eventType: string): void {\n if (!(element && element.nodeType)) {\n throw new Error('element must be a DOM node when calling triggerEvent')\n }\n\n // For click events on checkboxes and radio buttons, jQuery toggles the element checked state *after* the\n // event handler runs instead of *before*. (This was fixed in 1.9 for checkboxes but not for radio buttons.)\n const useClickWorkaround = isClickOnCheckableElement(element, eventType)\n\n if (!options.useOnlyNativeEvents && options.jQuery && !useClickWorkaround) {\n options.jQuery(element).trigger(eventType)\n } else if (typeof document.createEvent === 'function') {\n if (typeof element.dispatchEvent === 'function') {\n const eventCategory = knownEventTypesByEventName[eventType] || 'HTMLEvents'\n const event = document.createEvent(eventCategory)\n ;(event as any).initEvent(\n eventType,\n true,\n true,\n options.global,\n 0,\n 0,\n 0,\n 0,\n 0,\n false,\n false,\n false,\n false,\n 0,\n element\n )\n element.dispatchEvent(event)\n } else {\n throw new Error(\"The supplied element doesn't support dispatchEvent\")\n }\n } else if (useClickWorkaround && hasClick(element)) {\n element.click()\n } else {\n throw new Error(\"Browser doesn't support triggering events\")\n }\n}\n"], | ||
| "mappings": ";;AAIA,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAE7B,OAAO,aAAa;AAGpB,MAAM,cAAc,CAAC,GACnB,6BAA6B,CAAC;AAEhC,YAAY,UAAU,IAAI,CAAC,SAAS,WAAW,UAAU;AAEzD,YAAY,aAAa,IAAI;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,cAAc,aAAa,SAAU,WAAW,oBAAoB;AAClE,MAAI,mBAAmB,QAAQ;AAC7B,aAAS,IAAI,GAAG,IAAI,mBAAmB,QAAQ,IAAI,GAAG,KAAK;AACzD,iCAA2B,mBAAmB,CAAC,CAAC,IAAI;AAAA,IACtD;AAAA,EACF;AACF,CAAC;AAED,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AAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AACA,cAAQ,cAAc,KAAK;AAAA,IAC7B,OAAO;AACL,YAAM,IAAI,MAAM,oDAAoD;AAAA,IACtE;AAAA,EACF,WAAW,sBAAsB,SAAS,OAAO,GAAG;AAClD,YAAQ,MAAM;AAAA,EAChB,OAAO;AACL,UAAM,IAAI,MAAM,2CAA2C;AAAA,EAC7D;AACF;", | ||
| "sourcesContent": ["//\n// DOM Events\n//\n\nimport { objectForEach } from '../object'\nimport { catchFunctionErrors } from '../error'\nimport { tagNameLower } from './info'\n\nimport options from '../options'\n\n// Represent the known event types in a compact way, then at runtime transform it into a hash with event name as key (for fast lookup)\nconst knownEvents = {},\n knownEventTypesByEventName = {}\n\nknownEvents['UIEvents'] = ['keyup', 'keydown', 'keypress']\n\nknownEvents['MouseEvents'] = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mouseup',\n 'mousemove',\n 'mouseover',\n 'mouseout',\n 'mouseenter',\n 'mouseleave'\n]\n\nobjectForEach(knownEvents, function (eventType, knownEventsForType) {\n if (knownEventsForType.length) {\n for (let i = 0, j = knownEventsForType.length; i < j; i++) {\n knownEventTypesByEventName[knownEventsForType[i]] = eventType\n }\n }\n})\n\nfunction isClickOnCheckableElement(element: Element, eventType: string) {\n if (tagNameLower(element) !== 'input' || !(element as HTMLInputElement).type) return false\n if (eventType.toLowerCase() != 'click') return false\n const inputType = (element as HTMLInputElement).type\n return inputType == 'checkbox' || inputType == 'radio'\n}\n\nexport function registerEventHandler(\n element: Element,\n eventType: string,\n handler: EventListener,\n eventOptions = false\n): void {\n const wrappedHandler = catchFunctionErrors(handler)\n const mustUseNative = Boolean(eventOptions)\n const jQuery = options.jQuery\n\n if (!options.useOnlyNativeEvents && !mustUseNative && jQuery) {\n jQuery(element).on(eventType, wrappedHandler)\n } else if (typeof element.addEventListener === 'function') {\n element.addEventListener(eventType, wrappedHandler, eventOptions)\n } else {\n throw new Error(\"Browser doesn't support addEventListener\")\n }\n}\n\nfunction hasClick(element: Element): element is Element & { click(): void } {\n return typeof (element as any).click === 'function'\n}\n\nexport function triggerEvent(element: Element, eventType: string): void {\n if (!(element && element.nodeType)) {\n throw new Error('element must be a DOM node when calling triggerEvent')\n }\n\n // For click events on checkboxes and radio buttons, jQuery toggles the element checked state *after* the\n // event handler runs instead of *before*. (This was fixed in 1.9 for checkboxes but not for radio buttons.)\n const useClickWorkaround = isClickOnCheckableElement(element, eventType)\n\n if (!options.useOnlyNativeEvents && options.jQuery && !useClickWorkaround) {\n options.jQuery(element).trigger(eventType)\n return\n }\n\n if (typeof element.dispatchEvent !== 'function') {\n if (useClickWorkaround && hasClick(element)) {\n element.click()\n return\n }\n throw new Error(\"The supplied element doesn't support dispatchEvent\")\n }\n\n const eventCategory = knownEventTypesByEventName[eventType] || 'HTMLEvents'\n const view = options.global as Window | undefined\n let event: Event\n if (eventCategory === 'MouseEvents' && typeof MouseEvent === 'function') {\n // Preserve the legacy initEvent(...) behavior of passing the element itself\n // as relatedTarget \u2014 handlers for mouseover/mouseout/mouseenter/mouseleave\n // observe event.relatedTarget.\n event = new MouseEvent(eventType, { bubbles: true, cancelable: true, view, relatedTarget: element })\n } else if (eventCategory === 'UIEvents' && typeof KeyboardEvent === 'function') {\n event = new KeyboardEvent(eventType, { bubbles: true, cancelable: true, view })\n } else {\n event = new Event(eventType, { bubbles: true, cancelable: true })\n }\n element.dispatchEvent(event)\n}\n"], | ||
| "mappings": ";;AAIA,SAAS,qBAAqB;AAC9B,SAAS,2BAA2B;AACpC,SAAS,oBAAoB;AAE7B,OAAO,aAAa;AAGpB,MAAM,cAAc,CAAC,GACnB,6BAA6B,CAAC;AAEhC,YAAY,UAAU,IAAI,CAAC,SAAS,WAAW,UAAU;AAEzD,YAAY,aAAa,IAAI;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,cAA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AAM;AACd;AAAA,IACF;AACA,UAAM,IAAI,MAAM,oDAAoD;AAAA,EACtE;AAEA,QAAM,gBAAgB,2BAA2B,SAAS,KAAK;AAC/D,QAAM,OAAO,QAAQ;AACrB,MAAI;AACJ,MAAI,kBAAkB,iBAAiB,OAAO,eAAe,YAAY;AAIvE,YAAQ,IAAI,WAAW,WAAW,EAAE,SAAS,MAAM,YAAY,MAAM,MAAM,eAAe,QAAQ,CAAC;AAAA,EACrG,WAAW,kBAAkB,cAAc,OAAO,kBAAkB,YAAY;AAC9E,YAAQ,IAAI,cAAc,WAAW,EAAE,SAAS,MAAM,YAAY,MAAM,KAAK,CAAC;AAAA,EAChF,OAAO;AACL,YAAQ,IAAI,MAAM,WAAW,EAAE,SAAS,MAAM,YAAY,KAAK,CAAC;AAAA,EAClE;AACA,UAAQ,cAAc,KAAK;AAC7B;", | ||
| "names": [] | ||
| } |
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ export function fixUpContinuousNodeArray(continuousNodeArray, parentNode) { |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ import { makeArray } from "../array.js"; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ import { arrayFirst } from "../array.js"; |
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ import { makeArray } from "../array.js"; |
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ import { tagNameLower } from "./info.js"; |
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -7,2 +7,3 @@ import { emptyDomNode, setDomNodeChildren as setRegularDomNodeChildren } from "./manipulation.js"; | ||
| import * as domData from "./data.js"; | ||
| import options from "../options.js"; | ||
| export const startCommentRegex = /^\s*ko(?:\s+([\s\S]+))?\s*$/; | ||
@@ -9,0 +10,0 @@ export const endCommentRegex = /^\s*\/ko\s*$/; |
@@ -5,4 +5,4 @@ { | ||
| "sourcesContent": ["/* eslint no-cond-assign: 0 */\n//\n// Virtual Elements\n//\n//\n// \"Virtual elements\" is an abstraction on top of the usual DOM API which understands the notion that comment nodes\n// may be used to represent hierarchy (in addition to the DOM's natural hierarchy).\n// If you call the DOM-manipulating functions on ko.virtualElements, you will be able to read and write the state\n// of that virtual hierarchy\n//\n// The point of all this is to support containerless templates (e.g., <!-- ko foreach:someCollection -->blah<!-- /ko -->)\n// without having to scatter special cases all over the binding and templating code.\n\nimport { emptyDomNode, setDomNodeChildren as setRegularDomNodeChildren } from './manipulation'\nimport { removeNode } from './disposal'\nimport { tagNameLower } from './info'\nimport * as domData from './data'\nimport options from '../options'\n\nexport const startCommentRegex = /^\\s*ko(?:\\s+([\\s\\S]+))?\\s*$/\nexport const endCommentRegex = /^\\s*\\/ko\\s*$/\nconst htmlTagsWithOptionallyClosingChildren = { ul: true, ol: true }\n\nexport function isStartComment(node) {\n return node.nodeType === Node.COMMENT_NODE && startCommentRegex.test(node.nodeValue)\n}\n\nexport function isEndComment(node) {\n return node.nodeType === Node.COMMENT_NODE && endCommentRegex.test(node.nodeValue)\n}\n\nfunction isUnmatchedEndComment(node) {\n return isEndComment(node) && !domData.get(node, matchedEndCommentDataKey)\n}\n\nconst matchedEndCommentDataKey = '__ko_matchedEndComment__'\n\nexport function getVirtualChildren(startComment, allowUnbalanced?) {\n let currentNode = startComment\n let depth = 1\n const children = new Array()\n while ((currentNode = currentNode.nextSibling)) {\n if (isEndComment(currentNode)) {\n domData.set(currentNode, matchedEndCommentDataKey, true)\n depth--\n if (depth === 0) {\n return children\n }\n }\n\n children.push(currentNode)\n\n if (isStartComment(currentNode)) {\n depth++\n }\n }\n if (!allowUnbalanced) {\n throw new Error('Cannot find closing comment tag to match: ' + startComment.nodeValue)\n }\n return null\n}\n\nfunction getMatchingEndComment(startComment, allowUnbalanced?) {\n const allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced)\n if (allVirtualChildren) {\n if (allVirtualChildren.length > 0) {\n return allVirtualChildren[allVirtualChildren.length - 1].nextSibling\n }\n return startComment.nextSibling\n } else {\n return null\n } // Must have no matching end comment, and allowUnbalanced is true\n}\n\nfunction getUnbalancedChildTags(node) {\n // e.g., from <div>OK</div><!-- ko blah --><span>Another</span>, returns: <!-- ko blah --><span>Another</span>\n // from <div>OK</div><!-- /ko --><!-- /ko -->, returns: <!-- /ko --><!-- /ko -->\n let childNode = node.firstChild,\n captureRemaining: any = null\n if (childNode) {\n do {\n if (captureRemaining) {\n // We already hit an unbalanced node and are now just scooping up all subsequent nodes\n captureRemaining.push(childNode)\n } else if (isStartComment(childNode)) {\n const matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true)\n if (matchingEndComment) {\n // It's a balanced tag, so skip immediately to the end of this virtual set\n childNode = matchingEndComment\n } else {\n captureRemaining = [childNode]\n } // It's unbalanced, so start capturing from this point\n } else if (isEndComment(childNode)) {\n captureRemaining = [childNode] // It's unbalanced (if it wasn't, we'd have skipped over it already), so start capturing\n }\n } while ((childNode = childNode.nextSibling))\n }\n return captureRemaining\n}\n\nexport interface VirtualElementsAllowedBindings {\n text: boolean\n foreach: boolean\n if: boolean\n ifnot: boolean\n with: boolean\n let: boolean\n using: boolean\n template: boolean\n component: boolean\n}\n\nexport const allowedBindings: VirtualElementsAllowedBindings = Object.create(null)\nexport const hasBindingValue = isStartComment\n\nexport function childNodes(node: Node): any {\n return isStartComment(node) ? getVirtualChildren(node) : node.childNodes\n}\n\nexport function emptyNode(node: Node) {\n if (!isStartComment(node)) {\n emptyDomNode(node)\n } else {\n const virtualChildren = childNodes(node)\n for (let i = 0, j = virtualChildren.length; i < j; i++) {\n removeNode(virtualChildren[i])\n }\n }\n}\n\nexport function setDomNodeChildren(node: Node, childNodes: Node[]) {\n if (!isStartComment(node)) {\n setRegularDomNodeChildren(node, childNodes)\n } else {\n emptyNode(node)\n const endCommentNode = node.nextSibling // Must be the next sibling, as we just emptied the children\n if (endCommentNode && endCommentNode.parentNode) {\n const parentNode = endCommentNode.parentNode\n for (let i = 0, j = childNodes.length; i < j; ++i) {\n parentNode.insertBefore(childNodes[i], endCommentNode)\n }\n }\n }\n}\n\nexport function prepend(containerNode: Node, nodeToPrepend: Node) {\n if (!isStartComment(containerNode)) {\n if (containerNode.firstChild) {\n containerNode.insertBefore(nodeToPrepend, containerNode.firstChild)\n } else {\n containerNode.appendChild(nodeToPrepend)\n }\n } else {\n // Start comments must always have a parent and at least one following sibling (the end comment)\n containerNode.parentNode?.insertBefore(nodeToPrepend, containerNode.nextSibling)\n }\n}\n\nexport function insertAfter(containerNode: Node, nodeToInsert: Node, insertAfterNode: Node) {\n if (!insertAfterNode) {\n prepend(containerNode, nodeToInsert)\n } else if (!isStartComment(containerNode)) {\n // Insert after insertion point\n if (insertAfterNode.nextSibling) {\n containerNode.insertBefore(nodeToInsert, insertAfterNode.nextSibling)\n } else {\n containerNode.appendChild(nodeToInsert)\n }\n } else {\n // Children of start comments must always have a parent and at least one following sibling (the end comment)\n containerNode.parentNode?.insertBefore(nodeToInsert, insertAfterNode.nextSibling)\n }\n}\n\nexport function firstChild(node: Node) {\n if (!isStartComment(node)) {\n if (node.firstChild && isEndComment(node.firstChild)) {\n throw new Error('Found invalid end comment, as the first child of ' + (node as Element).outerHTML)\n }\n return node.firstChild\n }\n if (!node.nextSibling || isEndComment(node.nextSibling)) {\n return null\n }\n return node.nextSibling\n}\n\nexport function lastChild(node: Node) {\n let nextChild = firstChild(node)\n if (!nextChild) return null\n\n let lastChildNode\n\n do {\n lastChildNode = nextChild\n } while ((nextChild = nextSibling(nextChild)))\n\n return lastChildNode\n}\n\nexport function nextSibling(node: Node) {\n if (isStartComment(node)) {\n node = getMatchingEndComment(node)\n }\n\n if (node.nextSibling && isEndComment(node.nextSibling)) {\n if (isUnmatchedEndComment(node.nextSibling)) {\n throw Error(\n 'Found end comment without a matching opening comment, as next sibling of ' + (node as Element).outerHTML\n )\n }\n return null\n } else {\n return node.nextSibling\n }\n}\n\nexport function previousSibling(node) {\n let depth = 0\n do {\n if (node.nodeType === Node.COMMENT_NODE) {\n if (isStartComment(node)) {\n if (--depth === 0) {\n return node\n }\n } else if (isEndComment(node)) {\n depth++\n }\n } else {\n if (depth === 0) {\n return node\n }\n }\n } while ((node = node.previousSibling))\n}\n\nexport function virtualNodeBindingValue(node): string | null {\n const regexMatch = node.nodeValue.match(startCommentRegex) as RegExpMatchArray\n return regexMatch ? regexMatch[1] : null\n}\n\nexport function normaliseVirtualElementDomStructure(elementVerified) {\n // Workaround for https://github.com/SteveSanderson/knockout/issues/155\n // (IE <= 8 or IE 9 quirks mode parses your HTML weirdly, treating closing </li> tags as if they don't exist, thereby moving comment nodes\n // that are direct descendants of <ul> into the preceding <li>)\n if (!htmlTagsWithOptionallyClosingChildren[tagNameLower(elementVerified)]) {\n return\n }\n\n // Scan immediate children to see if they contain unbalanced comment tags. If they do, those comment tags\n // must be intended to appear *after* that child, so move them there.\n let childNode = elementVerified.firstChild\n if (childNode) {\n do {\n if (childNode.nodeType === Node.ELEMENT_NODE) {\n const unbalancedTags = getUnbalancedChildTags(childNode)\n if (unbalancedTags) {\n // Fix up the DOM by moving the unbalanced tags to where they most likely were intended to be placed - *after* the child\n const nodeToInsertBefore = childNode.nextSibling\n for (let i = 0; i < unbalancedTags.length; i++) {\n if (nodeToInsertBefore) {\n elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore)\n } else {\n elementVerified.appendChild(unbalancedTags[i])\n }\n }\n }\n }\n } while ((childNode = childNode.nextSibling))\n }\n}\n"], | ||
| "mappings": ";;AAaA,SAAS,cAAc,sBAAsB,iCAAiC;AAC9E,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,YAAY,aAAa;AAGlB,aAAM,oBAAoB;AAC1B,aAAM,kBAAkB;AAC/B,MAAM,wCAAwC,EAAE,IAAI,MAAM,IAAI,KAAK;AAE5D,gBAAS,eAAe,MAAM;AACnC,SAAO,KAAK,aAAa,KAAK,gBAAgB,kBAAkB,KAAK,KAAK,SAAS;AACrF;AAEO,gBAAS,aAAa,MAAM;AACjC,SAAO,KAAK,aAAa,KAAK,gBAAgB,gBAAgB,KAAK,KAAK,SAAS;AACnF;AAEA,SAAS,sBAAsB,MAAM;AACnC,SAAO,aAAa,IAAI,KAAK,CAAC,QAAQ,IAAI,MAAM,wBAAwB;AAC1E;AAEA,MAAM,2BAA2B;AAE1B,gBAAS,mBAAmB,cAAc,iBAAkB;AACjE,MAAI,cAAc;AAClB,MAAI,QAAQ;AACZ,QAAM,WAAW,IAAI,MAAM;AAC3B,SAAQ,cAAc,YAAY,aAAc;AAC9C,QAAI,aAAa,WAAW,GAAG;AAC7B,cAAQ,IAAI,aAAa,0BAA0B,IAAI;AACvD;AACA,UAAI,UAAU,GAAG;AACf,eAAO;AAAA,MACT;AAAA,IACF;AAEA,aAAS,KAAK,WAAW;AAEzB,QAAI,eAAe,WAAW,GAAG;AAC/B;AAAA,IACF;AAAA,EACF;AACA,MAAI,CAAC,iBAAiB;AACpB,UAAM,IAAI,MAAM,+CAA+C,aAAa,SAAS;AAAA,EACvF;AACA,SAAO;AACT;AAEA,SAAS,sBAAsB,cAAc,iBAAkB;AAC7D,QAAM,qBAAqB,mBAAmB,cAAc,eAAe;AAC3E,MAAI,oBAAoB;AACtB,QAAI,mBAAmB,SAAS,GAAG;AACjC,aAAO,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1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ import options from "./options.js"; |
+61
-101
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 CommonJS | ||
| // @tko/utils 🥊 4.1.0 CommonJS | ||
| "use strict"; | ||
@@ -57,3 +57,2 @@ var __defProp = Object.defineProperty; | ||
| fixUpContinuousNodeArray: () => fixUpContinuousNodeArray, | ||
| functionSupportsLengthOverwrite: () => functionSupportsLengthOverwrite, | ||
| getObjectOwnProperty: () => getObjectOwnProperty, | ||
@@ -96,3 +95,2 @@ hasOwnProperty: () => hasOwnProperty, | ||
| triggerEvent: () => triggerEvent, | ||
| useSymbols: () => useSymbols, | ||
| virtualElements: () => virtualElements_exports | ||
@@ -198,13 +196,13 @@ }); | ||
| var statusNotInNew = "deleted"; | ||
| function compareArrays(oldArray, newArray, options2) { | ||
| options2 = typeof options2 === "boolean" ? { dontLimitMoves: options2 } : options2 || {}; | ||
| function compareArrays(oldArray, newArray, options3) { | ||
| options3 = typeof options3 === "boolean" ? { dontLimitMoves: options3 } : options3 || {}; | ||
| oldArray = oldArray || []; | ||
| newArray = newArray || []; | ||
| if (oldArray.length < newArray.length) { | ||
| return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options2); | ||
| return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options3); | ||
| } else { | ||
| return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options2); | ||
| return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options3); | ||
| } | ||
| } | ||
| function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options2) { | ||
| function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options3) { | ||
| let myMin = Math.min, myMax = Math.max, editDistanceMatrix = new Array(), smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = bigIndexMax - smlIndexMax || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow; | ||
@@ -254,3 +252,3 @@ for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) { | ||
| --smlIndex; | ||
| if (!(options2 == null ? void 0 : options2.sparse)) { | ||
| if (!(options3 == null ? void 0 : options3.sparse)) { | ||
| editScript.push({ status: "retained", value: bigArray[bigIndex] }); | ||
@@ -260,3 +258,3 @@ } | ||
| } | ||
| findMovesInArrayComparison(notInBig, notInSml, !options2.dontLimitMoves && smlIndexMax * 10); | ||
| findMovesInArrayComparison(notInBig, notInSml, !options3.dontLimitMoves && smlIndexMax * 10); | ||
| return editScript.reverse(); | ||
@@ -318,5 +316,5 @@ } | ||
| get jQuery() { | ||
| var _a; | ||
| var _a2; | ||
| if (this.disableJQueryUsage) return void 0; | ||
| return (_a = this._jQuery) != null ? _a : globalThis.jQuery; | ||
| return (_a2 = this._jQuery) != null ? _a2 : globalThis.jQuery; | ||
| } | ||
@@ -367,3 +365,3 @@ /** | ||
| function defineOption(name, config) { | ||
| var _a; | ||
| var _a2; | ||
| let _value = config.default; | ||
@@ -375,5 +373,5 @@ Object.defineProperty(options, name, { | ||
| set(value) { | ||
| var _a2; | ||
| var _a3; | ||
| _value = value; | ||
| (_a2 = config.set) == null ? void 0 : _a2.call(config, value); | ||
| (_a3 = config.set) == null ? void 0 : _a3.call(config, value); | ||
| }, | ||
@@ -383,3 +381,3 @@ enumerable: true, | ||
| }); | ||
| (_a = config.set) == null ? void 0 : _a.call(config, _value); | ||
| (_a2 = config.set) == null ? void 0 : _a2.call(config, _value); | ||
| } | ||
@@ -430,2 +428,16 @@ var options_default = options; | ||
| // src/compat.ts | ||
| function createSymbolOrString(identifier) { | ||
| return Symbol(identifier); | ||
| } | ||
| function stringTrim(value) { | ||
| return String(value != null ? value : "").trim(); | ||
| } | ||
| function stringStartsWith(value, prefix) { | ||
| return (value != null ? value : "").startsWith(prefix); | ||
| } | ||
| function overwriteLengthPropertyIfSupported(fn, descriptor) { | ||
| Object.defineProperty(fn, "length", descriptor); | ||
| } | ||
| // src/object.ts | ||
@@ -509,35 +521,8 @@ function hasOwnProperty(obj, propName) { | ||
| // src/function.ts | ||
| function testOverwrite() { | ||
| try { | ||
| Object.defineProperty(function x() { | ||
| }, "length", {}); | ||
| return true; | ||
| } catch (e) { | ||
| return false; | ||
| } | ||
| } | ||
| var functionSupportsLengthOverwrite = testOverwrite(); | ||
| function overwriteLengthPropertyIfSupported(fn, descriptor) { | ||
| if (functionSupportsLengthOverwrite) { | ||
| Object.defineProperty(fn, "length", descriptor); | ||
| } | ||
| } | ||
| // src/string.ts | ||
| function stringTrim(string) { | ||
| return string === null || string === void 0 ? "" : string.trim ? string.trim() : string.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, ""); | ||
| } | ||
| function stringStartsWith(string, startsWith) { | ||
| string = string || ""; | ||
| if (startsWith.length > string.length) { | ||
| return false; | ||
| } | ||
| return string.substring(0, startsWith.length) === startsWith; | ||
| } | ||
| function parseJson(jsonString) { | ||
| if (typeof jsonString === "string") { | ||
| jsonString = stringTrim(jsonString); | ||
| if (jsonString) { | ||
| return JSON.parse(jsonString); | ||
| const trimmed = jsonString.trim(); | ||
| if (trimmed) { | ||
| return JSON.parse(trimmed); | ||
| } | ||
@@ -548,33 +533,17 @@ } | ||
| // src/symbol.ts | ||
| var useSymbols = typeof Symbol === "function"; | ||
| function createSymbolOrString(identifier) { | ||
| return useSymbols ? Symbol(identifier) : identifier; | ||
| } | ||
| // src/css.ts | ||
| var cssClassNameRegex = /\S+/g; | ||
| function toggleDomNodeCssClass(node, classNames, shouldHaveClass) { | ||
| let addOrRemoveFn; | ||
| if (!classNames) { | ||
| return; | ||
| } | ||
| if (typeof node.classList === "object") { | ||
| addOrRemoveFn = node.classList[shouldHaveClass ? "add" : "remove"]; | ||
| arrayForEach(classNames.match(cssClassNameRegex), function(className) { | ||
| addOrRemoveFn.call(node.classList, className); | ||
| }); | ||
| } else if (typeof node.className["baseVal"] === "string") { | ||
| toggleObjectClassPropertyString(node.className, "baseVal", classNames, shouldHaveClass); | ||
| } else { | ||
| toggleObjectClassPropertyString(node, "className", classNames, shouldHaveClass); | ||
| const tokens = classNames.match(cssClassNameRegex); | ||
| if (!tokens) { | ||
| return; | ||
| } | ||
| const method = shouldHaveClass ? "add" : "remove"; | ||
| for (const token of tokens) { | ||
| node.classList[method](token); | ||
| } | ||
| } | ||
| function toggleObjectClassPropertyString(obj, prop, classNames, shouldHaveClass) { | ||
| const currentClassNames = obj[prop].match(cssClassNameRegex) || []; | ||
| arrayForEach(classNames.match(cssClassNameRegex), function(className) { | ||
| addOrRemoveItem(currentClassNames, className, shouldHaveClass); | ||
| }); | ||
| obj[prop] = currentClassNames.join(" "); | ||
| } | ||
@@ -675,32 +644,22 @@ // src/dom/info.ts | ||
| options_default.jQuery(element).trigger(eventType); | ||
| } else if (typeof document.createEvent === "function") { | ||
| if (typeof element.dispatchEvent === "function") { | ||
| const eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents"; | ||
| const event = document.createEvent(eventCategory); | ||
| event.initEvent( | ||
| eventType, | ||
| true, | ||
| true, | ||
| options_default.global, | ||
| 0, | ||
| 0, | ||
| 0, | ||
| 0, | ||
| 0, | ||
| false, | ||
| false, | ||
| false, | ||
| false, | ||
| 0, | ||
| element | ||
| ); | ||
| element.dispatchEvent(event); | ||
| } else { | ||
| throw new Error("The supplied element doesn't support dispatchEvent"); | ||
| return; | ||
| } | ||
| if (typeof element.dispatchEvent !== "function") { | ||
| if (useClickWorkaround && hasClick(element)) { | ||
| element.click(); | ||
| return; | ||
| } | ||
| } else if (useClickWorkaround && hasClick(element)) { | ||
| element.click(); | ||
| throw new Error("The supplied element doesn't support dispatchEvent"); | ||
| } | ||
| const eventCategory = knownEventTypesByEventName[eventType] || "HTMLEvents"; | ||
| const view = options_default.global; | ||
| let event; | ||
| if (eventCategory === "MouseEvents" && typeof MouseEvent === "function") { | ||
| event = new MouseEvent(eventType, { bubbles: true, cancelable: true, view, relatedTarget: element }); | ||
| } else if (eventCategory === "UIEvents" && typeof KeyboardEvent === "function") { | ||
| event = new KeyboardEvent(eventType, { bubbles: true, cancelable: true, view }); | ||
| } else { | ||
| throw new Error("Browser doesn't support triggering events"); | ||
| event = new Event(eventType, { bubbles: true, cancelable: true }); | ||
| } | ||
| element.dispatchEvent(event); | ||
| } | ||
@@ -1062,3 +1021,3 @@ | ||
| function prepend(containerNode, nodeToPrepend) { | ||
| var _a; | ||
| var _a2; | ||
| if (!isStartComment(containerNode)) { | ||
@@ -1071,7 +1030,7 @@ if (containerNode.firstChild) { | ||
| } else { | ||
| (_a = containerNode.parentNode) == null ? void 0 : _a.insertBefore(nodeToPrepend, containerNode.nextSibling); | ||
| (_a2 = containerNode.parentNode) == null ? void 0 : _a2.insertBefore(nodeToPrepend, containerNode.nextSibling); | ||
| } | ||
| } | ||
| function insertAfter(containerNode, nodeToInsert, insertAfterNode) { | ||
| var _a; | ||
| var _a2; | ||
| if (!insertAfterNode) { | ||
@@ -1086,3 +1045,3 @@ prepend(containerNode, nodeToInsert); | ||
| } else { | ||
| (_a = containerNode.parentNode) == null ? void 0 : _a.insertBefore(nodeToInsert, insertAfterNode.nextSibling); | ||
| (_a2 = containerNode.parentNode) == null ? void 0 : _a2.insertBefore(nodeToInsert, insertAfterNode.nextSibling); | ||
| } | ||
@@ -1426,5 +1385,6 @@ } | ||
| var schedulerGlobal = options_default.global; | ||
| var _a; | ||
| if (schedulerGlobal && typeof schedulerGlobal.queueMicrotask === "function") { | ||
| options_default.taskScheduler = (callback) => schedulerGlobal.queueMicrotask(callback); | ||
| } else if (schedulerGlobal && schedulerGlobal.MutationObserver && schedulerGlobal.document && !(schedulerGlobal.navigator && schedulerGlobal.navigator.standalone)) { | ||
| } else if ((schedulerGlobal == null ? void 0 : schedulerGlobal.MutationObserver) && schedulerGlobal.document && !((_a = schedulerGlobal.navigator) == null ? void 0 : _a.standalone)) { | ||
| options_default.taskScheduler = (function() { | ||
@@ -1431,0 +1391,0 @@ let scheduledCallback = null; |
+2
-3
@@ -1,10 +0,9 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
| export * from "./array.js"; | ||
| export * from "./async.js"; | ||
| export * from "./compat.js"; | ||
| export * from "./error.js"; | ||
| export * from "./object.js"; | ||
| export * from "./function.js"; | ||
| export * from "./string.js"; | ||
| export * from "./symbol.js"; | ||
| export * from "./css.js"; | ||
@@ -11,0 +10,0 @@ export { default as options, defineOption, Options } from "./options.js"; |
| { | ||
| "version": 3, | ||
| "sources": ["../src/index.ts"], | ||
| "sourcesContent": ["/*\n tko.util\n ===\n\n*/\n\nexport * from './array'\nexport * from './async'\nexport * from './error'\nexport * from './object'\nexport * from './function'\nexport * from './string'\nexport * from './symbol'\nexport * from './css'\nexport { default as options, defineOption, Options } from './options'\n\n// DOM;\nexport * from './dom/event'\nexport * from './dom/info'\nexport * from './dom/manipulation'\nexport * from './dom/fixes'\nexport * from './dom/html'\nexport * from './dom/disposal'\nexport * from './dom/selectExtensions'\n\n// Sub-Modules;\nimport * as memoization from './memoization'\nimport * as tasks from './tasks'\nimport * as virtualElements from './dom/virtualElements'\nimport * as domData from './dom/data'\n\nexport { tasks, virtualElements, domData, memoization }\n"], | ||
| "mappings": ";;AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,WAAW,SAAS,cAAc,eAAe;AAG1D,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,YAAY,iBAAiB;AAC7B,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,YAAY,aAAa;AAEzB,SAAS,OAAO,iBAAiB,SAAS;", | ||
| "sourcesContent": ["/*\n tko.util\n ===\n\n*/\n\nexport * from './array'\nexport * from './async'\nexport * from './compat'\nexport * from './error'\nexport * from './object'\nexport * from './string'\nexport * from './css'\nexport { default as options, defineOption, Options } from './options'\n\n// DOM;\nexport * from './dom/event'\nexport * from './dom/info'\nexport * from './dom/manipulation'\nexport * from './dom/fixes'\nexport * from './dom/html'\nexport * from './dom/disposal'\nexport * from './dom/selectExtensions'\n\n// Sub-Modules;\nimport * as memoization from './memoization'\nimport * as tasks from './tasks'\nimport * as virtualElements from './dom/virtualElements'\nimport * as domData from './dom/data'\n\nexport { tasks, virtualElements, domData, memoization }\n"], | ||
| "mappings": ";;AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,WAAW,SAAS,cAAc,eAAe;AAG1D,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,YAAY,iBAAiB;AAC7B,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,YAAY,aAAa;AAEzB,SAAS,OAAO,iBAAiB,SAAS;", | ||
| "names": [] | ||
| } |
+2
-3
@@ -1,10 +0,9 @@ | ||
| // @tko/utils 🥊 4.0.1 MJS | ||
| // @tko/utils 🥊 4.1.0 MJS | ||
| "use strict"; | ||
| export * from "./array.js"; | ||
| export * from "./async.js"; | ||
| export * from "./compat.js"; | ||
| export * from "./error.js"; | ||
| export * from "./object.js"; | ||
| export * from "./function.js"; | ||
| export * from "./string.js"; | ||
| export * from "./symbol.js"; | ||
| export * from "./css.js"; | ||
@@ -11,0 +10,0 @@ export { default as options, defineOption, Options } from "./options.js"; |
| { | ||
| "version": 3, | ||
| "sources": ["../src/index.ts"], | ||
| "sourcesContent": ["/*\n tko.util\n ===\n\n*/\n\nexport * from './array'\nexport * from './async'\nexport * from './error'\nexport * from './object'\nexport * from './function'\nexport * from './string'\nexport * from './symbol'\nexport * from './css'\nexport { default as options, defineOption, Options } from './options'\n\n// DOM;\nexport * from './dom/event'\nexport * from './dom/info'\nexport * from './dom/manipulation'\nexport * from './dom/fixes'\nexport * from './dom/html'\nexport * from './dom/disposal'\nexport * from './dom/selectExtensions'\n\n// Sub-Modules;\nimport * as memoization from './memoization'\nimport * as tasks from './tasks'\nimport * as virtualElements from './dom/virtualElements'\nimport * as domData from './dom/data'\n\nexport { tasks, virtualElements, domData, memoization }\n"], | ||
| "mappings": ";;AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,WAAW,SAAS,cAAc,eAAe;AAG1D,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,YAAY,iBAAiB;AAC7B,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,YAAY,aAAa;AAEzB,SAAS,OAAO,iBAAiB,SAAS;", | ||
| "sourcesContent": ["/*\n tko.util\n ===\n\n*/\n\nexport * from './array'\nexport * from './async'\nexport * from './compat'\nexport * from './error'\nexport * from './object'\nexport * from './string'\nexport * from './css'\nexport { default as options, defineOption, Options } from './options'\n\n// DOM;\nexport * from './dom/event'\nexport * from './dom/info'\nexport * from './dom/manipulation'\nexport * from './dom/fixes'\nexport * from './dom/html'\nexport * from './dom/disposal'\nexport * from './dom/selectExtensions'\n\n// Sub-Modules;\nimport * as memoization from './memoization'\nimport * as tasks from './tasks'\nimport * as virtualElements from './dom/virtualElements'\nimport * as domData from './dom/data'\n\nexport { tasks, virtualElements, domData, memoization }\n"], | ||
| "mappings": ";;AAMA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,WAAW,SAAS,cAAc,eAAe;AAG1D,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAGd,YAAY,iBAAiB;AAC7B,YAAY,WAAW;AACvB,YAAY,qBAAqB;AACjC,YAAY,aAAa;AAEzB,SAAS,OAAO,iBAAiB,SAAS;", | ||
| "names": [] | ||
| } |
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ import { arrayPushAll } from "./array.js"; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ export function hasOwnProperty(obj, propName) { |
+1
-1
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -3,0 +3,0 @@ export class Options { |
+4
-14
@@ -1,18 +0,8 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
| export function stringTrim(string) { | ||
| return string === null || string === void 0 ? "" : string.trim ? string.trim() : string.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g, ""); | ||
| } | ||
| export function stringStartsWith(string, startsWith) { | ||
| string = string || ""; | ||
| if (startsWith.length > string.length) { | ||
| return false; | ||
| } | ||
| return string.substring(0, startsWith.length) === startsWith; | ||
| } | ||
| export function parseJson(jsonString) { | ||
| if (typeof jsonString === "string") { | ||
| jsonString = stringTrim(jsonString); | ||
| if (jsonString) { | ||
| return JSON.parse(jsonString); | ||
| const trimmed = jsonString.trim(); | ||
| if (trimmed) { | ||
| return JSON.parse(trimmed); | ||
| } | ||
@@ -19,0 +9,0 @@ } |
| { | ||
| "version": 3, | ||
| "sources": ["../src/string.ts"], | ||
| "sourcesContent": ["//\n// String (and JSON)\n//\n\nexport function stringTrim(string) {\n return string === null || string === undefined\n ? ''\n : string.trim\n ? string.trim()\n : string.toString().replace(/^[\\s\\xa0]+|[\\s\\xa0]+$/g, '')\n}\n\nexport function stringStartsWith(string, startsWith) {\n string = string || ''\n if (startsWith.length > string.length) {\n return false\n }\n return string.substring(0, startsWith.length) === startsWith\n}\n\nexport function parseJson<T = any>(jsonString: string): T | null {\n if (typeof jsonString === 'string') {\n jsonString = stringTrim(jsonString)\n if (jsonString) {\n return JSON.parse(jsonString) as T\n }\n }\n return null\n}\n"], | ||
| "mappings": ";;AAIO,gBAAS,WAAW,QAAQ;AACjC,SAAO,WAAW,QAAQ,WAAW,SACjC,KACA,OAAO,OACL,OAAO,KAAK,IACZ,OAAO,SAAS,EAAE,QAAQ,0BAA0B,EAAE;AAC9D;AAEO,gBAAS,iBAAiB,QAAQ,YAAY;AACnD,WAAS,UAAU;AACnB,MAAI,WAAW,SAAS,OAAO,QAAQ;AACrC,WAAO;AAAA,EACT;AACA,SAAO,OAAO,UAAU,GAAG,WAAW,MAAM,MAAM;AACpD;AAEO,gBAAS,UAAmB,YAA8B;AAC/D,MAAI,OAAO,eAAe,UAAU;AAClC,iBAAa,WAAW,UAAU;AAClC,QAAI,YAAY;AACd,aAAO,KAAK,MAAM,UAAU;AAAA,IAC9B;AAAA,EACF;AACA,SAAO;AACT;", | ||
| "sourcesContent": ["//\n// String (and JSON)\n//\n\nexport function parseJson<T = any>(jsonString: string): T | null {\n if (typeof jsonString === 'string') {\n const trimmed = jsonString.trim()\n if (trimmed) {\n return JSON.parse(trimmed) as T\n }\n }\n return null\n}\n"], | ||
| "mappings": ";;AAIO,gBAAS,UAAmB,YAA8B;AAC/D,MAAI,OAAO,eAAe,UAAU;AAClC,UAAM,UAAU,WAAW,KAAK;AAChC,QAAI,SAAS;AACX,aAAO,KAAK,MAAM,OAAO;AAAA,IAC3B;AAAA,EACF;AACA,SAAO;AACT;", | ||
| "names": [] | ||
| } |
+2
-2
@@ -1,2 +0,2 @@ | ||
| // @tko/utils 🥊 4.0.1 ESM | ||
| // @tko/utils 🥊 4.1.0 ESM | ||
| "use strict"; | ||
@@ -9,3 +9,3 @@ import options from "./options.js"; | ||
| options.taskScheduler = (callback) => schedulerGlobal.queueMicrotask(callback); | ||
| } else if (schedulerGlobal && schedulerGlobal.MutationObserver && schedulerGlobal.document && !(schedulerGlobal.navigator && schedulerGlobal.navigator.standalone)) { | ||
| } else if (schedulerGlobal?.MutationObserver && schedulerGlobal.document && !schedulerGlobal.navigator?.standalone) { | ||
| options.taskScheduler = (function() { | ||
@@ -12,0 +12,0 @@ let scheduledCallback = null; |
| { | ||
| "version": 3, | ||
| "sources": ["../src/tasks.ts"], | ||
| "sourcesContent": ["//\n// Tasks Micro-scheduler\n// ===\n//\n/* eslint no-cond-assign: 0 */\nimport options from './options'\nimport { deferError } from './error'\n\nlet taskQueue = new Array(),\n taskQueueLength = 0,\n nextHandle = 1,\n nextIndexToProcess = 0\n\nconst schedulerGlobal = options.global\n\nif (schedulerGlobal && typeof schedulerGlobal.queueMicrotask === 'function') {\n options.taskScheduler = callback => schedulerGlobal.queueMicrotask(callback)\n} else if (\n schedulerGlobal &&\n schedulerGlobal.MutationObserver &&\n schedulerGlobal.document &&\n !(schedulerGlobal.navigator && schedulerGlobal.navigator.standalone)\n) {\n options.taskScheduler = (function () {\n let scheduledCallback: null | (() => void) = null\n let toggle = false\n const div = schedulerGlobal.document.createElement('div')\n\n new schedulerGlobal.MutationObserver(function () {\n const callback = scheduledCallback\n scheduledCallback = null\n callback?.()\n }).observe(div, { attributes: true })\n\n return function (callback: () => void) {\n scheduledCallback = callback\n toggle = !toggle\n div.setAttribute('data-task-scheduler', toggle ? '1' : '0')\n }\n })()\n} else {\n options.taskScheduler = callback => setTimeout(callback, 0)\n}\n\nfunction processTasks() {\n if (taskQueueLength) {\n // Each mark represents the end of a logical group of tasks and the number of these groups is\n // limited to prevent unchecked recursion.\n let mark = taskQueueLength,\n countMarks = 0\n\n // nextIndexToProcess keeps track of where we are in the queue; processTasks can be called recursively without issue\n for (let task; nextIndexToProcess < taskQueueLength; ) {\n if ((task = taskQueue[nextIndexToProcess++])) {\n if (nextIndexToProcess > mark) {\n if (++countMarks >= 5000) {\n nextIndexToProcess = taskQueueLength // skip all tasks remaining in the queue since any of them could be causing the recursion\n deferError(Error(\"'Too much recursion' after processing \" + countMarks + ' task groups.'))\n break\n }\n mark = taskQueueLength\n }\n try {\n task()\n } catch (ex) {\n deferError(ex)\n }\n }\n }\n }\n}\n\nfunction scheduledProcess() {\n processTasks()\n\n // Reset the queue\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0\n}\n\nfunction scheduleTaskProcessing() {\n options.taskScheduler(scheduledProcess)\n}\n\nexport function schedule(func: () => any): number {\n if (!taskQueueLength) {\n scheduleTaskProcessing()\n }\n\n taskQueue[taskQueueLength++] = func\n return nextHandle++\n}\n\nexport function cancel(handle: number) {\n const index = handle - (nextHandle - taskQueueLength)\n if (index >= nextIndexToProcess && index < taskQueueLength) {\n taskQueue[index] = null\n }\n}\n\n// For testing only: reset the queue and return the previous queue length\nexport function resetForTesting() {\n const length = taskQueueLength - nextIndexToProcess\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0\n return length\n}\n\nexport { processTasks as runEarly }\n"], | ||
| "mappings": ";;AAKA,OAAO,aAAa;AACpB,SAAS,kBAAkB;AAE3B,IAAI,YAAY,IAAI,MAAM,GACxB,kBAAkB,GAClB,aAAa,GACb,qBAAqB;AAEvB,MAAM,kBAAkB,QAAQ;AAEhC,IAAI,mBAAmB,OAAO,gBAAgB,mBAAmB,YAAY;AAC3E,UAAQ,gBAAgB,cAAY,gBAAgB,eAAe,QAAQ;AAC7E,WACE,mBACA,gBAAgB,oBAChB,gBAAgB,YAChB,EAAE,gBAAgB,aAAa,gBAAgB,UAAU,aACzD;AACA,UAAQ,iBAAiB,WAAY;AACnC,QAAI,oBAAyC;AAC7C,QAAI,SAAS;AACb,UAAM,MAAM,gBAAgB,SAAS,cAAc,KAAK;AAExD,QAAI,gBAAgB,iBAAiB,WAAY;AAC/C,YAAM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esContent": ["//\n// Tasks Micro-scheduler\n// ===\n//\n/* eslint no-cond-assign: 0 */\nimport options from './options'\nimport { deferError } from './error'\n\nlet taskQueue = new Array(),\n taskQueueLength = 0,\n nextHandle = 1,\n nextIndexToProcess = 0\n\nconst schedulerGlobal = options.global\n\nif (schedulerGlobal && typeof schedulerGlobal.queueMicrotask === 'function') {\n options.taskScheduler = callback => schedulerGlobal.queueMicrotask(callback)\n} else if (schedulerGlobal?.MutationObserver && schedulerGlobal.document && !schedulerGlobal.navigator?.standalone) {\n options.taskScheduler = (function () {\n let scheduledCallback: null | (() => void) = null\n let toggle = false\n const div = schedulerGlobal.document.createElement('div')\n\n new schedulerGlobal.MutationObserver(function () {\n const callback = scheduledCallback\n scheduledCallback = null\n callback?.()\n }).observe(div, { attributes: true })\n\n return function (callback: () => void) {\n scheduledCallback = callback\n toggle = !toggle\n div.setAttribute('data-task-scheduler', toggle ? '1' : '0')\n }\n })()\n} else {\n options.taskScheduler = callback => setTimeout(callback, 0)\n}\n\nfunction processTasks() {\n if (taskQueueLength) {\n // Each mark represents the end of a logical group of tasks and the number of these groups is\n // limited to prevent unchecked recursion.\n let mark = taskQueueLength,\n countMarks = 0\n\n // nextIndexToProcess keeps track of where we are in the queue; processTasks can be called recursively without issue\n for (let task; nextIndexToProcess < taskQueueLength; ) {\n if ((task = taskQueue[nextIndexToProcess++])) {\n if (nextIndexToProcess > mark) {\n if (++countMarks >= 5000) {\n nextIndexToProcess = taskQueueLength // skip all tasks remaining in the queue since any of them could be causing the recursion\n deferError(Error(\"'Too much recursion' after processing \" + countMarks + ' task groups.'))\n break\n }\n mark = taskQueueLength\n }\n try {\n task()\n } catch (ex) {\n deferError(ex)\n }\n }\n }\n }\n}\n\nfunction scheduledProcess() {\n processTasks()\n\n // Reset the queue\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0\n}\n\nfunction scheduleTaskProcessing() {\n options.taskScheduler(scheduledProcess)\n}\n\nexport function schedule(func: () => any): number {\n if (!taskQueueLength) {\n scheduleTaskProcessing()\n }\n\n taskQueue[taskQueueLength++] = func\n return nextHandle++\n}\n\nexport function cancel(handle: number) {\n const index = handle - (nextHandle - taskQueueLength)\n if (index >= nextIndexToProcess && index < taskQueueLength) {\n taskQueue[index] = null\n }\n}\n\n// For testing only: reset the queue and return the previous queue length\nexport function resetForTesting() {\n const length = taskQueueLength - nextIndexToProcess\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0\n return length\n}\n\nexport { processTasks as runEarly }\n"], | ||
| "mappings": ";;AAKA,OAAO,aAAa;AACpB,SAAS,kBAAkB;AAE3B,IAAI,YAAY,IAAI,MAAM,GACxB,kBAAkB,GAClB,aAAa,GACb,qBAAqB;AAEvB,MAAM,kBAAkB,QAAQ;AAEhC,IAAI,mBAAmB,OAAO,gBAAgB,mBAAmB,YAAY;AAC3E,UAAQ,gBAAgB,cAAY,gBAAgB,eAAe,QAAQ;AAC7E,WAAW,iBAAiB,oBAAoB,gBAAgB,YAAY,CAAC,gBAAgB,WAAW,YAAY;AAClH,UAAQ,iBAAiB,WAAY;AACnC,QAAI,oBAAyC;AAC7C,QAAI,SAAS;AACb,UAAM,MAAM,gBAAgB,SAAS,cAAc,KAAK;AAExD,QAAI,gBAAgB,iBAAiB,WAAY;AAC/C,YAAM,WAAW;AACjB,0BAAoB;AACpB,iBAAW;AAAA,IACb,CAAC,EAAE,QAAQ,KAAK,EAAE,YAAY,KAAK,CAAC;AAEpC,WAAO,SAAU,UAAsB;AACrC,0BAAoB;AACpB,eAAS,CAAC;AACV,UAAI,aAAa,uBAAuB,SAAS,MAAM,GAAG;AAAA,IAC5D;AAAA,EACF,GAAG;AACL,OAAO;AACL,UAAQ,gBAAgB,cAAY,WAAW,UAAU,CAAC;AAC5D;AAEA,SAAS,eAAe;AACtB,MAAI,iBAAiB;AAGnB,QAAI,OAAO,iBACT,aAAa;AAGf,aAAS,MAAM,qBAAqB,mBAAmB;AACrD,UAAK,OAAO,UAAU,oBAAoB,GAAI;AAC5C,YAAI,qBAAqB,MAAM;AAC7B,cAAI,EAAE,cAAc,KAAM;AACxB,iCAAqB;AACrB,uBAAW,MAAM,2CAA2C,aAAa,eAAe,CAAC;AACzF;AAAA,UACF;AACA,iBAAO;AAAA,QACT;AACA,YAAI;AACF,eAAK;AAAA,QACP,SAAS,IAAI;AACX,qBAAW,EAAE;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,mBAAmB;AAC1B,eAAa;AAGb,uBAAqB,kBAAkB,UAAU,SAAS;AAC5D;AAEA,SAAS,yBAAyB;AAChC,UAAQ,cAAc,gBAAgB;AACxC;AAEO,gBAAS,SAAS,MAAyB;AAChD,MAAI,CAAC,iBAAiB;AACpB,2BAAuB;AAAA,EACzB;AAEA,YAAU,iBAAiB,IAAI;AAC/B,SAAO;AACT;AAEO,gBAAS,OAAO,QAAgB;AACrC,QAAM,QAAQ,UAAU,aAAa;AACrC,MAAI,SAAS,sBAAsB,QAAQ,iBAAiB;AAC1D,cAAU,KAAK,IAAI;AAAA,EACrB;AACF;AAGO,gBAAS,kBAAkB;AAChC,QAAM,SAAS,kBAAkB;AACjC,uBAAqB,kBAAkB,UAAU,SAAS;AAC1D,SAAO;AACT;AAEA,SAAS,gBAAgB;", | ||
| "names": [] | ||
| } |
+6
-3
| { | ||
| "version": "4.0.1", | ||
| "version": "4.1.0", | ||
| "name": "@tko/utils", | ||
@@ -16,3 +16,5 @@ "description": "TKO Utilities", | ||
| "tko", | ||
| "ko" | ||
| "utilities", | ||
| "dom", | ||
| "helpers" | ||
| ], | ||
@@ -26,3 +28,4 @@ "author": "The Knockout Team", | ||
| "dependencies": { | ||
| "tslib": "^2.2.0" | ||
| "@tko/provider": "^4.1.0", | ||
| "@tko/builder": "^4.1.0" | ||
| }, | ||
@@ -29,0 +32,0 @@ "licenses": [ |
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| function testOverwrite() { | ||
| try { | ||
| Object.defineProperty(function x() { | ||
| }, "length", {}); | ||
| return true; | ||
| } catch (e) { | ||
| return false; | ||
| } | ||
| } | ||
| export const functionSupportsLengthOverwrite = testOverwrite(); | ||
| export function overwriteLengthPropertyIfSupported(fn, descriptor) { | ||
| if (functionSupportsLengthOverwrite) { | ||
| Object.defineProperty(fn, "length", descriptor); | ||
| } | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../src/function.ts"], | ||
| "sourcesContent": ["function testOverwrite() {\n try {\n Object.defineProperty(function x() {}, 'length', {})\n return true\n } catch (e) {\n return false\n }\n}\n\nexport const functionSupportsLengthOverwrite = testOverwrite()\n\nexport function overwriteLengthPropertyIfSupported(fn, descriptor) {\n if (functionSupportsLengthOverwrite) {\n Object.defineProperty(fn, 'length', descriptor)\n }\n}\n"], | ||
| "mappings": ";;AAAA,SAAS,gBAAgB;AACvB,MAAI;AACF,WAAO,eAAe,SAAS,IAAI;AAAA,IAAC,GAAG,UAAU,CAAC,CAAC;AACnD,WAAO;AAAA,EACT,SAAS,GAAG;AACV,WAAO;AAAA,EACT;AACF;AAEO,aAAM,kCAAkC,cAAc;AAEtD,gBAAS,mCAAmC,IAAI,YAAY;AACjE,MAAI,iCAAiC;AACnC,WAAO,eAAe,IAAI,UAAU,UAAU;AAAA,EAChD;AACF;", | ||
| "names": [] | ||
| } |
| // @tko/utils 🥊 4.0.1 ESM | ||
| "use strict"; | ||
| export const useSymbols = typeof Symbol === "function"; | ||
| export function createSymbolOrString(identifier) { | ||
| return useSymbols ? Symbol(identifier) : identifier; | ||
| } |
| { | ||
| "version": 3, | ||
| "sources": ["../src/symbol.ts"], | ||
| "sourcesContent": ["//\n// ES6 Symbols\n//\n\nexport const useSymbols = typeof Symbol === 'function'\n\nexport function createSymbolOrString(identifier) {\n return useSymbols ? Symbol(identifier) : identifier\n}\n"], | ||
| "mappings": ";;AAIO,aAAM,aAAa,OAAO,WAAW;AAErC,gBAAS,qBAAqB,YAAY;AAC/C,SAAO,aAAa,OAAO,UAAU,IAAI;AAC3C;", | ||
| "names": [] | ||
| } |
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
0
-100%6
Infinity%2
-71.43%273545
-1.78%2
100%46
-2.13%2779
-2.8%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed