@tko/utils 4.0.0-alpha8.0 → 4.0.0-beta1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array.js +156 -0
- package/dist/array.js.map +7 -0
- package/dist/async.js +20 -0
- package/dist/async.js.map +7 -0
- package/dist/bind-shim.js +18 -0
- package/dist/bind-shim.js.map +7 -0
- package/dist/css.js +27 -0
- package/dist/css.js.map +7 -0
- package/dist/dom/data.js +63 -0
- package/dist/dom/data.js.map +7 -0
- package/dist/dom/disposal.js +98 -0
- package/dist/dom/disposal.js.map +7 -0
- package/dist/dom/event.js +87 -0
- package/dist/dom/event.js.map +7 -0
- package/dist/dom/fixes.js +45 -0
- package/dist/dom/fixes.js.map +7 -0
- package/dist/dom/html.js +115 -0
- package/dist/dom/html.js.map +7 -0
- package/dist/dom/info.js +43 -0
- package/dist/dom/info.js.map +7 -0
- package/dist/dom/manipulation.js +55 -0
- package/dist/dom/manipulation.js.map +7 -0
- package/dist/dom/selectExtensions.js +62 -0
- package/dist/dom/selectExtensions.js.map +7 -0
- package/dist/dom/virtualElements.js +202 -0
- package/dist/dom/virtualElements.js.map +7 -0
- package/dist/error.js +22 -0
- package/dist/error.js.map +7 -0
- package/dist/function.js +16 -0
- package/dist/function.js.map +7 -0
- package/dist/ie.js +15 -0
- package/dist/ie.js.map +7 -0
- package/dist/index.cjs +1448 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +24 -0
- package/dist/index.mjs.map +7 -0
- package/dist/jquery.js +6 -0
- package/dist/jquery.js.map +7 -0
- package/dist/memoization.js +64 -0
- package/dist/memoization.js.map +7 -0
- package/dist/object.js +76 -0
- package/dist/object.js.map +7 -0
- package/dist/options.js +36 -0
- package/dist/options.js.map +7 -0
- package/dist/string.js +23 -0
- package/dist/string.js.map +7 -0
- package/dist/symbol.js +5 -0
- package/dist/symbol.js.map +7 -0
- package/dist/tasks.js +76 -0
- package/dist/tasks.js.map +7 -0
- package/helpers/{jasmine-13-helper.js → jasmine-13-helper.ts} +1 -1
- package/package.json +15 -25
- package/dist/utils.es6.js +0 -1628
- package/dist/utils.es6.js.map +0 -1
- package/dist/utils.js +0 -1645
- package/dist/utils.js.map +0 -1
package/dist/tasks.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// @tko/utils 🥊 4.0.0-beta1.0 ESM
|
|
2
|
+
import options from "./options";
|
|
3
|
+
import { deferError } from "./error";
|
|
4
|
+
var taskQueue = [], taskQueueLength = 0, nextHandle = 1, nextIndexToProcess = 0, w = options.global;
|
|
5
|
+
if (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {
|
|
6
|
+
options.taskScheduler = function(callback) {
|
|
7
|
+
var div = w.document.createElement("div");
|
|
8
|
+
new w.MutationObserver(callback).observe(div, { attributes: true });
|
|
9
|
+
return function() {
|
|
10
|
+
div.classList.toggle("foo");
|
|
11
|
+
};
|
|
12
|
+
}(scheduledProcess);
|
|
13
|
+
} else if (w && w.document && "onreadystatechange" in w.document.createElement("script")) {
|
|
14
|
+
options.taskScheduler = function(callback) {
|
|
15
|
+
var script = document.createElement("script");
|
|
16
|
+
script.onreadystatechange = function() {
|
|
17
|
+
script.onreadystatechange = null;
|
|
18
|
+
document.documentElement.removeChild(script);
|
|
19
|
+
script = null;
|
|
20
|
+
callback();
|
|
21
|
+
};
|
|
22
|
+
document.documentElement.appendChild(script);
|
|
23
|
+
};
|
|
24
|
+
} else {
|
|
25
|
+
options.taskScheduler = function(callback) {
|
|
26
|
+
setTimeout(callback, 0);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function processTasks() {
|
|
30
|
+
if (taskQueueLength) {
|
|
31
|
+
var mark = taskQueueLength, countMarks = 0;
|
|
32
|
+
for (var task; nextIndexToProcess < taskQueueLength; ) {
|
|
33
|
+
if (task = taskQueue[nextIndexToProcess++]) {
|
|
34
|
+
if (nextIndexToProcess > mark) {
|
|
35
|
+
if (++countMarks >= 5e3) {
|
|
36
|
+
nextIndexToProcess = taskQueueLength;
|
|
37
|
+
deferError(Error("'Too much recursion' after processing " + countMarks + " task groups."));
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
mark = taskQueueLength;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
task();
|
|
44
|
+
} catch (ex) {
|
|
45
|
+
deferError(ex);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function scheduledProcess() {
|
|
52
|
+
processTasks();
|
|
53
|
+
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
|
54
|
+
}
|
|
55
|
+
function scheduleTaskProcessing() {
|
|
56
|
+
options.taskScheduler(scheduledProcess);
|
|
57
|
+
}
|
|
58
|
+
export function schedule(func) {
|
|
59
|
+
if (!taskQueueLength) {
|
|
60
|
+
scheduleTaskProcessing();
|
|
61
|
+
}
|
|
62
|
+
taskQueue[taskQueueLength++] = func;
|
|
63
|
+
return nextHandle++;
|
|
64
|
+
}
|
|
65
|
+
export function cancel(handle) {
|
|
66
|
+
var index = handle - (nextHandle - taskQueueLength);
|
|
67
|
+
if (index >= nextIndexToProcess && index < taskQueueLength) {
|
|
68
|
+
taskQueue[index] = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export function resetForTesting() {
|
|
72
|
+
var length = taskQueueLength - nextIndexToProcess;
|
|
73
|
+
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
|
74
|
+
return length;
|
|
75
|
+
}
|
|
76
|
+
export { processTasks as runEarly };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/tasks.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Tasks Micro-scheduler\n// ===\n//\n/* eslint no-cond-assign: 0 */\nimport options from './options'\nimport { deferError } from './error'\n\nvar taskQueue = [],\n taskQueueLength = 0,\n nextHandle = 1,\n nextIndexToProcess = 0,\n w = options.global\n\nif (w && w.MutationObserver && !(w.navigator && w.navigator.standalone)) {\n // Chrome 27+, Firefox 14+, IE 11+, Opera 15+, Safari 6.1+, node\n // From https://github.com/petkaantonov/bluebird * Copyright (c) 2014 Petka Antonov * License: MIT\n options.taskScheduler = (function (callback) {\n var div = w.document.createElement('div')\n new w.MutationObserver(callback).observe(div, {attributes: true})\n return function () { div.classList.toggle('foo') }\n })(scheduledProcess)\n} else if (w && w.document && 'onreadystatechange' in w.document.createElement('script')) {\n // IE 6-10\n // From https://github.com/YuzuJS/setImmediate * Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic Denicola * License: MIT\n options.taskScheduler = function (callback) {\n var script = document.createElement('script')\n script.onreadystatechange = function () {\n script.onreadystatechange = null\n document.documentElement.removeChild(script)\n script = null\n callback()\n }\n document.documentElement.appendChild(script)\n }\n} else {\n options.taskScheduler = function (callback) {\n setTimeout(callback, 0)\n }\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 var mark = taskQueueLength, countMarks = 0\n\n // nextIndexToProcess keeps track of where we are in the queue; processTasks can be called recursively without issue\n for (var 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) {\n if (!taskQueueLength) {\n scheduleTaskProcessing()\n }\n\n taskQueue[taskQueueLength++] = func\n return nextHandle++\n}\n\nexport function cancel (handle) {\n var 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 var length = taskQueueLength - nextIndexToProcess\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0\n return length\n}\n\nexport {processTasks as runEarly}\n"],
|
|
5
|
+
"mappings": ";AAKA;AACA;AAEA,IAAI,YAAY,CAAC,GACf,kBAAkB,GAClB,aAAa,GACb,qBAAqB,GACrB,IAAI,QAAQ;AAEd,IAAI,KAAK,EAAE,oBAAoB,CAAE,GAAE,aAAa,EAAE,UAAU,aAAa;AAGvE,UAAQ,gBAAiB,SAAU,UAAU;AAC3C,QAAI,MAAM,EAAE,SAAS,cAAc,KAAK;AACxC,QAAI,EAAE,iBAAiB,QAAQ,EAAE,QAAQ,KAAK,EAAC,YAAY,KAAI,CAAC;AAChE,WAAO,WAAY;AAAE,UAAI,UAAU,OAAO,KAAK;AAAA,IAAE;AAAA,EACnD,EAAG,gBAAgB;AACrB,WAAW,KAAK,EAAE,YAAY,wBAAwB,EAAE,SAAS,cAAc,QAAQ,GAAG;AAGxF,UAAQ,gBAAgB,SAAU,UAAU;AAC1C,QAAI,SAAS,SAAS,cAAc,QAAQ;AAC5C,WAAO,qBAAqB,WAAY;AACtC,aAAO,qBAAqB;AAC5B,eAAS,gBAAgB,YAAY,MAAM;AAC3C,eAAS;AACT,eAAS;AAAA,IACX;AACA,aAAS,gBAAgB,YAAY,MAAM;AAAA,EAC7C;AACF,OAAO;AACL,UAAQ,gBAAgB,SAAU,UAAU;AAC1C,eAAW,UAAU,CAAC;AAAA,EACxB;AACF;AAEA,wBAAyB;AACvB,MAAI,iBAAiB;AAGnB,QAAI,OAAO,iBAAiB,aAAa;AAGzC,aAAS,MAAM,qBAAqB,mBAAkB;AACpD,UAAI,OAAO,UAAU,uBAAuB;AAC1C,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,IAAP;AACA,qBAAW,EAAE;AAAA,QACf;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,4BAA6B;AAC3B,eAAa;AAGb,uBAAqB,kBAAkB,UAAU,SAAS;AAC5D;AAEA,kCAAmC;AACjC,UAAQ,cAAc,gBAAgB;AACxC;AAEO,yBAAmB,MAAM;AAC9B,MAAI,CAAC,iBAAiB;AACpB,2BAAuB;AAAA,EACzB;AAEA,YAAU,qBAAqB;AAC/B,SAAO;AACT;AAEO,uBAAiB,QAAQ;AAC9B,MAAI,QAAQ,SAAU,cAAa;AACnC,MAAI,SAAS,sBAAsB,QAAQ,iBAAiB;AAC1D,cAAU,SAAS;AAAA,EACrB;AACF;AAGO,kCAA4B;AACjC,MAAI,SAAS,kBAAkB;AAC/B,uBAAqB,kBAAkB,UAAU,SAAS;AAC1D,SAAO;AACT;AAEA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
+
"version": "4.0.0-beta1.0",
|
|
2
3
|
"name": "@tko/utils",
|
|
3
|
-
"version": "4.0.0-alpha8.0",
|
|
4
4
|
"description": "TKO Utilities",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist/",
|
|
8
8
|
"helpers/"
|
|
9
9
|
],
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/knockout/tko.
|
|
12
|
+
"url": "git+https://github.com/knockout/tko.git"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"knockout",
|
|
16
16
|
"tko",
|
|
17
17
|
"ko"
|
|
18
18
|
],
|
|
19
|
-
"author": "Knockout",
|
|
19
|
+
"author": "The Knockout Team",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"bugs": {
|
|
22
|
-
"url": "https://github.com/knockout/tko
|
|
22
|
+
"url": "https://github.com/knockout/tko/issues"
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://tko.io",
|
|
25
25
|
"karma": {
|
|
@@ -28,30 +28,20 @@
|
|
|
28
28
|
]
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"tslib": "^
|
|
32
|
-
},
|
|
33
|
-
"__about__shared.package.json": "These properties are copied into all packages/*/package.json. Run `yarn repackage`",
|
|
34
|
-
"standard": {
|
|
35
|
-
"env": [
|
|
36
|
-
"browser",
|
|
37
|
-
"jasmine",
|
|
38
|
-
"mocha"
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
"scripts": {
|
|
42
|
-
"test": "npx karma start ../../karma.conf.js --once",
|
|
43
|
-
"build": "npx rollup -c ../../rollup.config.js",
|
|
44
|
-
"watch": "npx karma start ../../karma.conf.js",
|
|
45
|
-
"prepare": "npx rollup -c ../../rollup.config.js"
|
|
46
|
-
},
|
|
47
|
-
"publishConfig": {
|
|
48
|
-
"access": "public"
|
|
31
|
+
"tslib": "^2.2.0"
|
|
49
32
|
},
|
|
50
33
|
"licenses": [
|
|
51
34
|
{
|
|
52
35
|
"type": "MIT",
|
|
53
|
-
"url": "
|
|
36
|
+
"url": "https://opensource.org/licenses/MIT"
|
|
54
37
|
}
|
|
55
38
|
],
|
|
56
|
-
"
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"require": "./dist/index.cjs",
|
|
42
|
+
"import": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./helpers/*": "./helpers/*"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "99114c4deded3fc5dbddd5c7c9c63c845a18263b"
|
|
57
47
|
}
|