strip html from description

This commit is contained in:
2023-11-24 14:39:28 -05:00
parent f7c6034fb0
commit 5f6e638903
526 changed files with 4373 additions and 23270 deletions
+5
View File
@@ -0,0 +1,5 @@
import { ArgsNum } from "../utils";
export declare const BAKED_EMPTY_FUNC: () => void;
export declare function bakeCollection<Func extends (...args: any) => void>(collection: Func[], fixedArgsNum: ArgsNum<Func>): (...args: Parameters<Func>) => void;
export declare function bakeCollectionAwait<Func extends (...args: any) => void>(collection: Func[], fixedArgsNum: ArgsNum<Func>): (...args: Parameters<Func>) => Promise<void>;
export declare function bakeCollectionVariadic<Func extends (...args: any) => void>(collection: Func[]): (...args: Parameters<Func>) => void;
+120
View File
@@ -0,0 +1,120 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bakeCollectionVariadic = exports.bakeCollectionAwait = exports.bakeCollection = exports.BAKED_EMPTY_FUNC = void 0;
exports.BAKED_EMPTY_FUNC = (function () { });
var FORLOOP_FALLBACK = 1500;
function generateArgsDefCode(numArgs) {
var argsDefCode = '';
if (numArgs === 0)
return argsDefCode;
for (var i = 0; i < numArgs - 1; ++i) {
argsDefCode += ('arg' + String(i) + ', ');
}
argsDefCode += ('arg' + String(numArgs - 1));
return argsDefCode;
}
function generateBodyPartsCode(argsDefCode, collectionLength) {
var funcDefCode = '', funcCallCode = '';
for (var i = 0; i < collectionLength; ++i) {
funcDefCode += "var f".concat(i, " = collection[").concat(i, "];\n");
funcCallCode += "f".concat(i, "(").concat(argsDefCode, ")\n");
}
return { funcDefCode: funcDefCode, funcCallCode: funcCallCode };
}
function generateBodyPartsVariadicCode(collectionLength) {
var funcDefCode = '', funcCallCode = '';
for (var i = 0; i < collectionLength; ++i) {
funcDefCode += "var f".concat(i, " = collection[").concat(i, "];\n");
funcCallCode += "f".concat(i, ".apply(undefined, arguments)\n");
}
return { funcDefCode: funcDefCode, funcCallCode: funcCallCode };
}
function bakeCollection(collection, fixedArgsNum) {
if (collection.length === 0)
return exports.BAKED_EMPTY_FUNC;
else if (collection.length === 1)
return collection[0];
var funcFactoryCode;
if (collection.length < FORLOOP_FALLBACK) {
var argsDefCode = generateArgsDefCode(fixedArgsNum);
var _a = generateBodyPartsCode(argsDefCode, collection.length), funcDefCode = _a.funcDefCode, funcCallCode = _a.funcCallCode;
funcFactoryCode = "(function(collection) {\n ".concat(funcDefCode, "\n collection = undefined;\n return (function(").concat(argsDefCode, ") {\n ").concat(funcCallCode, "\n });\n })");
}
else {
var argsDefCode = generateArgsDefCode(fixedArgsNum);
// loop unroll
if (collection.length % 10 === 0) {
funcFactoryCode = "(function(collection) {\n return (function(".concat(argsDefCode, ") {\n for (var i = 0; i < collection.length; i += 10) {\n collection[i](").concat(argsDefCode, ");\n collection[i+1](").concat(argsDefCode, ");\n collection[i+2](").concat(argsDefCode, ");\n collection[i+3](").concat(argsDefCode, ");\n collection[i+4](").concat(argsDefCode, ");\n collection[i+5](").concat(argsDefCode, ");\n collection[i+6](").concat(argsDefCode, ");\n collection[i+7](").concat(argsDefCode, ");\n collection[i+8](").concat(argsDefCode, ");\n collection[i+9](").concat(argsDefCode, ");\n }\n });\n })");
}
else if (collection.length % 4 === 0) {
funcFactoryCode = "(function(collection) {\n return (function(".concat(argsDefCode, ") {\n for (var i = 0; i < collection.length; i += 4) {\n collection[i](").concat(argsDefCode, ");\n collection[i+1](").concat(argsDefCode, ");\n collection[i+2](").concat(argsDefCode, ");\n collection[i+3](").concat(argsDefCode, ");\n }\n });\n })");
}
else if (collection.length % 3 === 0) {
funcFactoryCode = "(function(collection) {\n return (function(".concat(argsDefCode, ") {\n for (var i = 0; i < collection.length; i += 3) {\n collection[i](").concat(argsDefCode, ");\n collection[i+1](").concat(argsDefCode, ");\n collection[i+2](").concat(argsDefCode, ");\n }\n });\n })");
}
else {
funcFactoryCode = "(function(collection) {\n return (function(".concat(argsDefCode, ") {\n for (var i = 0; i < collection.length; ++i) {\n collection[i](").concat(argsDefCode, ");\n }\n });\n })");
}
}
{
// isolate
var bakeCollection_1 = undefined;
var fixedArgsNum_1 = undefined;
var bakeCollectionVariadic_1 = undefined;
var bakeCollectionAwait_1 = undefined;
var funcFactory = eval(funcFactoryCode);
return funcFactory(collection);
}
}
exports.bakeCollection = bakeCollection;
function bakeCollectionAwait(collection, fixedArgsNum) {
if (collection.length === 0)
return exports.BAKED_EMPTY_FUNC;
else if (collection.length === 1)
return collection[0];
var funcFactoryCode;
if (collection.length < FORLOOP_FALLBACK) {
var argsDefCode = generateArgsDefCode(fixedArgsNum);
var _a = generateBodyPartsCode(argsDefCode, collection.length), funcDefCode = _a.funcDefCode, funcCallCode = _a.funcCallCode;
funcFactoryCode = "(function(collection) {\n ".concat(funcDefCode, "\n collection = undefined;\n return (function(").concat(argsDefCode, ") {\n return Promise.all([ ").concat(funcCallCode, " ]);\n });\n })");
}
else {
var argsDefCode = generateArgsDefCode(fixedArgsNum);
funcFactoryCode = "(function(collection) {\n return (function(".concat(argsDefCode, ") {\n var promises = Array(collection.length);\n for (var i = 0; i < collection.length; ++i) {\n promises[i] = collection[i](").concat(argsDefCode, ");\n }\n return Promise.all(promises);\n });\n })");
}
{
// isolate
var bakeCollection_2 = undefined;
var fixedArgsNum_2 = undefined;
var bakeCollectionVariadic_2 = undefined;
var bakeCollectionAwait_2 = undefined;
var funcFactory = eval(funcFactoryCode);
return funcFactory(collection);
}
}
exports.bakeCollectionAwait = bakeCollectionAwait;
function bakeCollectionVariadic(collection) {
if (collection.length === 0)
return exports.BAKED_EMPTY_FUNC;
else if (collection.length === 1)
return collection[0];
var funcFactoryCode;
if (collection.length < FORLOOP_FALLBACK) {
var _a = generateBodyPartsVariadicCode(collection.length), funcDefCode = _a.funcDefCode, funcCallCode = _a.funcCallCode;
funcFactoryCode = "(function(collection) {\n ".concat(funcDefCode, "\n collection = undefined;\n return (function() {\n ").concat(funcCallCode, "\n });\n })");
}
else {
funcFactoryCode = "(function(collection) {\n return (function() {\n for (var i = 0; i < collection.length; ++i) {\n collection[i].apply(undefined, arguments);\n }\n });\n })";
}
{
// isolate
var bakeCollection_3 = undefined;
var fixedArgsNum = undefined;
var bakeCollectionVariadic_3 = undefined;
var bakeCollectionAwait_3 = undefined;
var funcFactory = eval(funcFactoryCode);
return funcFactory(collection);
}
}
exports.bakeCollectionVariadic = bakeCollectionVariadic;
//# sourceMappingURL=bake-collection.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"bake-collection.js","sourceRoot":"","sources":["../../src/task-collection/bake-collection.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAG,CAAC,cAAW,CAAC,CAAC,CAAC;AAE/C,IAAI,gBAAgB,GAAG,IAAI,CAAC;AAE5B,SAAS,mBAAmB,CAAC,OAAe;IACxC,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,IAAI,OAAO,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;QAClC,WAAW,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;KAC7C;IACD,WAAW,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7C,OAAO,WAAW,CAAC;AACvB,CAAC;AAED,SAAS,qBAAqB,CAAC,WAAmB,EAAE,gBAAwB;IACxE,IAAI,WAAW,GAAG,EAAE,EAAE,YAAY,GAAG,EAAE,CAAC;IACxC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,EAAE,EAAE,CAAC,EAAE;QACvC,WAAW,IAAI,eAAQ,CAAC,2BAAiB,CAAC,SAAM,CAAC;QACjD,YAAY,IAAI,WAAI,CAAC,cAAI,WAAW,QAAK,CAAC;KAC7C;IACD,OAAO,EAAE,WAAW,aAAA,EAAE,YAAY,cAAA,EAAE,CAAC;AACzC,CAAC;AAED,SAAS,6BAA6B,CAAC,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AAW,2LAGQ,WAAW,sGAIlD,CAAC;KACP;IAED;QACI,UAAU;QACV,IAAM,gBAAc,GAAG,SAAS,CAAC;QACjC,IAAM,cAAY,GAAG,SAAS,CAAC;QAC/B,IAAM,wBAAsB,GAAG,SAAS,CAAC;QACzC,IAAM,qBAAmB,GAAG,SAAS,CAAC;QAEtC,IAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC;KAClC;AACL,CAAC;AA3CD,kDA2CC;AAED,SAAgB,sBAAsB,CAClC,UAAkB;IAElB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,wBAAgB,CAAC;SAChD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;IAEvD,IAAI,eAAuB,CAAC;IAE5B,IAAI,UAAU,CAAC,MAAM,GAAG,gBAAgB,EAAE;QAChC,IAAA,KAAgC,6BAA6B,CAAC,UAAU,CAAC,MAAM,CAAC,EAA9E,WAAW,iBAAA,EAAE,YAAY,kBAAqD,CAAC;QAEvF,eAAe,GAAG,+CACZ,WAAW,sGAGP,YAAY,kCAEnB,CAAC;KACP;SAAM;QACH,eAAe,GAAG,0OAMf,CAAC;KACP;IAED;QACI,UAAU;QACV,IAAM,gBAAc,GAAG,SAAS,CAAC;QACjC,IAAM,YAAY,GAAG,SAAS,CAAC;QAC/B,IAAM,wBAAsB,GAAG,SAAS,CAAC;QACzC,IAAM,qBAAmB,GAAG,SAAS,CAAC;QAEtC,IAAM,WAAW,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC,UAAU,CAAC,CAAC;KAClC;AACL,CAAC;AAtCD,wDAsCC"}
+1
View File
@@ -0,0 +1 @@
export * from './task-collection';
+18
View File
@@ -0,0 +1,18 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./task-collection"), exports);
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/task-collection/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
+33
View File
@@ -0,0 +1,33 @@
import { ArgsNum } from '../utils';
export declare function _fast_remove_single(arr: any[], index: number): void;
export declare class TaskCollection<Func extends (...args: any) => void, AwaitTasks extends true | false = false> {
readonly awaitTasks: AwaitTasks;
constructor(argsNum: ArgsNum<Func>, autoRebuild?: boolean, initialTasks?: (Func[]) | Func | null, awaitTasks?: AwaitTasks);
/** DO NOT CHANGE DIRECTLY */
_tasks: (Func[]) | Func | null;
/** cached */
length: number;
/** auto rebuild on first emit call; otherwise autorebuild on every change */
firstEmitBuildStrategy: boolean;
readonly argsNum: ArgsNum<Func>;
autoRebuild: boolean;
readonly growArgsNum: typeof growArgsNum;
setAutoRebuild: typeof setAutoRebuild;
call: (...args: Parameters<Func>) => (AwaitTasks extends true ? Promise<void> : void);
rebuild: () => void;
push: (...func: Func[]) => void;
/** remove last matched task from tasks */
removeLast: (func: Func) => void;
insert: (index: number, ...func: Func[]) => void;
setTasks: (tasks: Func[]) => void;
tasksAsArray: () => Func[];
/** this autorebuilds */
readonly clear: typeof clear;
/** this autorebuilds */
readonly fastClear: typeof fastClear;
}
declare function fastClear<Func extends (...args: any) => void, AwaitTasks extends true | false = false>(this: TaskCollection<Func, AwaitTasks>): void;
declare function clear<Func extends (...args: any) => void, AwaitTasks extends true | false = false>(this: TaskCollection<Func, AwaitTasks>): void;
declare function growArgsNum<Func extends (...args: any) => void, AwaitTasks extends true | false = false>(this: TaskCollection<Func, AwaitTasks>, argsNum: number): void;
declare function setAutoRebuild<Func extends (...args: any) => void, AwaitTasks extends true | false = false>(this: TaskCollection<Func, AwaitTasks>, newVal: boolean): void;
export {};
+313
View File
@@ -0,0 +1,313 @@
"use strict";
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TaskCollection = exports._fast_remove_single = void 0;
var bake_collection_1 = require("./bake-collection");
function push_norebuild(a, b /*, ...func: Func[] */) {
var len = this.length;
if (len > 1) { // tasks is array
if (b) { // if multiple args
var _a;
(_a = this._tasks).push.apply(_a, arguments);
this.length += arguments.length;
}
else { // if single arg (most often case)
this._tasks.push(a);
this.length++;
}
}
else { // tasks is (function or null)
if (b) { // if multiple args
if (len === 1) { // if this._tasks is function
var newAr = Array(1 + arguments.length);
newAr.push(newAr);
newAr.push.apply(newAr, arguments);
this._tasks = newAr;
}
else {
var newAr = Array(arguments.length);
newAr.push.apply(newAr, arguments);
this._tasks = newAr;
}
this.length += arguments.length;
}
else { // if single arg (most often case)
if (len === 1)
this._tasks = [this._tasks, a];
else
this._tasks = a;
this.length++;
}
}
}
function push_rebuild(a, b /*, ...func: Func[] */) {
var len = this.length;
if (len > 1) { // tasks is array
if (b) { // if multiple args
var _a;
(_a = this._tasks).push.apply(_a, arguments);
this.length += arguments.length;
}
else { // if single arg (most often case)
this._tasks.push(a);
this.length++;
}
}
else { // tasks is (function or null)
if (b) { // if multiple args
if (len === 1) { // if this._tasks is function
var newAr = Array(1 + arguments.length);
newAr.push(newAr);
newAr.push.apply(newAr, arguments);
this._tasks = newAr;
}
else {
var newAr = Array(arguments.length);
newAr.push.apply(newAr, arguments);
this._tasks = newAr;
}
this.length += arguments.length;
}
else { // if single arg (most often case)
if (len === 1)
this._tasks = [this._tasks, a];
else
this._tasks = a;
this.length++;
}
}
if (this.firstEmitBuildStrategy)
this.call = rebuild_on_first_call;
else
this.rebuild();
}
function _fast_remove_single(arr, index) {
if (index === -1)
return;
if (index === 0)
arr.shift();
else if (index === arr.length - 1)
arr.length = arr.length - 1;
else
arr.splice(index, 1);
}
exports._fast_remove_single = _fast_remove_single;
function removeLast_norebuild(a) {
if (this.length === 0)
return;
if (this.length === 1) {
if (this._tasks === a) {
this.length = 0;
}
}
else {
_fast_remove_single(this._tasks, this._tasks.lastIndexOf(a));
if (this._tasks.length === 1) {
this._tasks = this._tasks[0];
this.length = 1;
}
else
this.length = this._tasks.length;
}
}
function removeLast_rebuild(a) {
if (this.length === 0)
return;
if (this.length === 1) {
if (this._tasks === a) {
this.length = 0;
}
if (this.firstEmitBuildStrategy) {
this.call = bake_collection_1.BAKED_EMPTY_FUNC;
return;
}
else {
this.rebuild();
return;
}
}
else {
_fast_remove_single(this._tasks, this._tasks.lastIndexOf(a));
if (this._tasks.length === 1) {
this._tasks = this._tasks[0];
this.length = 1;
}
else
this.length = this._tasks.length;
}
if (this.firstEmitBuildStrategy)
this.call = rebuild_on_first_call;
else
this.rebuild();
}
function insert_norebuild(index) {
var _b;
var func = [];
for (var _i = 1; _i < arguments.length; _i++) {
func[_i - 1] = arguments[_i];
}
if (this.length === 0) {
this._tasks = func;
this.length = 1;
}
else if (this.length === 1) {
func.unshift(this._tasks);
this._tasks = func;
this.length = this._tasks.length;
}
else {
(_b = this._tasks).splice.apply(_b, __spreadArray([index, 0], func, false));
this.length = this._tasks.length;
}
}
function insert_rebuild(index) {
var _b;
var func = [];
for (var _i = 1; _i < arguments.length; _i++) {
func[_i - 1] = arguments[_i];
}
if (this.length === 0) {
this._tasks = func;
this.length = 1;
}
else if (this.length === 1) {
func.unshift(this._tasks);
this._tasks = func;
this.length = this._tasks.length;
}
else {
(_b = this._tasks).splice.apply(_b, __spreadArray([index, 0], func, false));
this.length = this._tasks.length;
}
if (this.firstEmitBuildStrategy)
this.call = rebuild_on_first_call;
else
this.rebuild();
}
function rebuild_noawait() {
if (this.length === 0)
this.call = bake_collection_1.BAKED_EMPTY_FUNC;
else if (this.length === 1)
this.call = this._tasks;
else
this.call = (0, bake_collection_1.bakeCollection)(this._tasks, this.argsNum);
}
function rebuild_await() {
if (this.length === 0)
this.call = bake_collection_1.BAKED_EMPTY_FUNC;
else if (this.length === 1)
this.call = this._tasks;
else
this.call = (0, bake_collection_1.bakeCollectionAwait)(this._tasks, this.argsNum);
}
function rebuild_on_first_call() {
this.rebuild();
this.call.apply(undefined, arguments);
}
var TaskCollection = /** @class */ (function () {
function TaskCollection(argsNum, autoRebuild, initialTasks, awaitTasks) {
if (autoRebuild === void 0) { autoRebuild = true; }
if (initialTasks === void 0) { initialTasks = null; }
if (awaitTasks === void 0) { awaitTasks = false; }
this.awaitTasks = awaitTasks;
this.call = bake_collection_1.BAKED_EMPTY_FUNC;
this.argsNum = argsNum;
this.firstEmitBuildStrategy = true;
if (awaitTasks)
this.rebuild = rebuild_await.bind(this);
else
this.rebuild = rebuild_noawait.bind(this);
this.setAutoRebuild(autoRebuild);
if (initialTasks) {
if (typeof initialTasks === 'function') {
this._tasks = initialTasks;
this.length = 1;
}
else {
this._tasks = initialTasks;
this.length = initialTasks.length;
}
}
else {
this._tasks = null;
this.length = 0;
}
if (autoRebuild)
this.rebuild();
}
return TaskCollection;
}());
exports.TaskCollection = TaskCollection;
function fastClear() {
this._tasks = null;
this.length = 0;
this.call = bake_collection_1.BAKED_EMPTY_FUNC;
}
function clear() {
this._tasks = null;
this.length = 0;
this.call = bake_collection_1.BAKED_EMPTY_FUNC;
}
function growArgsNum(argsNum) {
if (this.argsNum < argsNum) {
this.argsNum = argsNum;
if (this.firstEmitBuildStrategy)
this.call = rebuild_on_first_call;
else
this.rebuild();
}
}
function setAutoRebuild(newVal) {
if (newVal) {
this.push = push_rebuild.bind(this);
this.insert = insert_rebuild.bind(this);
this.removeLast = removeLast_rebuild.bind(this);
}
else {
this.push = push_norebuild.bind(this);
this.insert = insert_norebuild.bind(this);
this.removeLast = removeLast_norebuild.bind(this);
}
}
;
function tasksAsArray() {
if (this.length === 0)
return [];
if (this.length === 1)
return [this._tasks];
return this._tasks;
}
function setTasks(tasks) {
if (tasks.length === 0) {
this.length = 0;
this.call = bake_collection_1.BAKED_EMPTY_FUNC;
}
else if (tasks.length === 1) {
this.length = 1;
this.call = tasks[0];
this._tasks = tasks[0];
}
else {
this.length = tasks.length;
this._tasks = tasks;
if (this.firstEmitBuildStrategy)
this.call = rebuild_on_first_call;
else
this.rebuild();
}
}
TaskCollection.prototype.fastClear = fastClear;
TaskCollection.prototype.clear = clear;
TaskCollection.prototype.growArgsNum = growArgsNum;
TaskCollection.prototype.setAutoRebuild = setAutoRebuild;
TaskCollection.prototype.tasksAsArray = tasksAsArray;
TaskCollection.prototype.setTasks = setTasks;
//# sourceMappingURL=task-collection.js.map
File diff suppressed because one or more lines are too long
+5
View File
@@ -0,0 +1,5 @@
export type NoReadonly<T extends {
[x: string]: any;
}> = {
-readonly [X in keyof T]: T[X];
};
+3
View File
@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=utils.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/task-collection/utils.ts"],"names":[],"mappings":""}