@koine/utils 1.2.3 → 2.0.0-alpha.2
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/areEqual.d.ts +1 -1
- package/areEqual.js +1 -1
- package/areEqual.mjs +1 -1
- package/arrayOfAll.d.ts +1 -1
- package/arrayOfAll.js +1 -1
- package/arrayOfAll.mjs +1 -1
- package/capitalize.d.ts +1 -1
- package/createPalette.d.ts +12 -0
- package/createPalette.js +26 -0
- package/createPalette.mjs +22 -0
- package/index.d.ts +133 -132
- package/index.js +265 -135
- package/index.mjs +132 -134
- package/package.json +3 -3
- package/render.d.ts +52 -0
- package/render.js +169 -0
- package/render.mjs +165 -0
- package/split.d.ts +3 -0
- package/split.js +8 -0
- package/split.mjs +4 -0
- package/types.d.ts +24 -0
package/index.mjs
CHANGED
|
@@ -1,134 +1,132 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
export
|
|
24
|
-
// export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
-
export
|
|
32
|
-
export
|
|
33
|
-
export
|
|
34
|
-
export
|
|
35
|
-
export
|
|
36
|
-
export
|
|
37
|
-
export
|
|
38
|
-
export
|
|
39
|
-
export
|
|
40
|
-
export
|
|
41
|
-
export
|
|
42
|
-
export
|
|
43
|
-
export
|
|
44
|
-
export
|
|
45
|
-
export
|
|
46
|
-
export
|
|
47
|
-
export
|
|
48
|
-
export
|
|
49
|
-
export
|
|
50
|
-
export
|
|
51
|
-
export
|
|
52
|
-
export
|
|
53
|
-
export
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
62
|
-
export
|
|
63
|
-
export
|
|
64
|
-
export
|
|
65
|
-
export
|
|
66
|
-
export
|
|
67
|
-
export
|
|
68
|
-
export
|
|
69
|
-
export
|
|
70
|
-
export
|
|
71
|
-
export
|
|
72
|
-
export
|
|
73
|
-
export
|
|
74
|
-
export
|
|
75
|
-
export
|
|
76
|
-
export
|
|
77
|
-
export
|
|
78
|
-
export
|
|
79
|
-
export
|
|
80
|
-
export
|
|
81
|
-
export
|
|
82
|
-
export
|
|
83
|
-
export
|
|
84
|
-
export
|
|
85
|
-
export
|
|
86
|
-
export
|
|
87
|
-
export
|
|
88
|
-
export
|
|
89
|
-
export
|
|
90
|
-
export
|
|
91
|
-
export
|
|
92
|
-
export
|
|
93
|
-
export
|
|
94
|
-
export
|
|
95
|
-
export
|
|
96
|
-
export
|
|
97
|
-
export
|
|
98
|
-
export
|
|
99
|
-
export
|
|
100
|
-
export
|
|
101
|
-
export
|
|
102
|
-
export
|
|
103
|
-
export
|
|
104
|
-
export
|
|
105
|
-
export
|
|
106
|
-
export
|
|
107
|
-
export
|
|
108
|
-
|
|
109
|
-
export
|
|
110
|
-
export
|
|
111
|
-
export
|
|
112
|
-
export
|
|
113
|
-
export
|
|
114
|
-
export
|
|
115
|
-
export
|
|
116
|
-
export
|
|
117
|
-
export
|
|
118
|
-
export
|
|
119
|
-
export
|
|
120
|
-
export
|
|
121
|
-
export
|
|
122
|
-
export
|
|
123
|
-
export
|
|
124
|
-
export
|
|
125
|
-
export
|
|
126
|
-
export
|
|
127
|
-
export
|
|
128
|
-
export
|
|
129
|
-
export
|
|
130
|
-
export
|
|
131
|
-
export
|
|
132
|
-
export
|
|
133
|
-
export * from "./wait";
|
|
134
|
-
export * from "./types";
|
|
1
|
+
export { accentsSets } from "./accentSets";
|
|
2
|
+
export { addOrReplaceAtIdx } from "./addOrReplaceAtIdx";
|
|
3
|
+
export { areEqual } from "./areEqual";
|
|
4
|
+
export { arrayOfAll } from "./arrayOfAll";
|
|
5
|
+
export { arraySum } from "./arraySum";
|
|
6
|
+
export { arrayToLookup } from "./arrayToLookup";
|
|
7
|
+
export { buildUrlQueryString } from "./buildUrlQueryString";
|
|
8
|
+
export { capitalize } from "./capitalize";
|
|
9
|
+
export { changeUrlPath } from "./changeUrlPath";
|
|
10
|
+
export { chunkByChunks } from "./chunkByChunks";
|
|
11
|
+
export { chunkBySize } from "./chunkBySize";
|
|
12
|
+
export { clamp } from "./clamp";
|
|
13
|
+
export { clsx } from "./clsx";
|
|
14
|
+
export { convertRange } from "./convertRange";
|
|
15
|
+
export { createPalette } from "./createPalette";
|
|
16
|
+
export { debounce } from "./debounce";
|
|
17
|
+
export { debounceRaf } from "./debounceRaf";
|
|
18
|
+
export { debouncePromise, } from "./debouncePromise";
|
|
19
|
+
export { decode } from "./decode";
|
|
20
|
+
export { Defer } from "./Defer";
|
|
21
|
+
export { Emitter } from "./Emitter";
|
|
22
|
+
export { encode } from "./encode";
|
|
23
|
+
export { ensureInt } from "./ensureInt";
|
|
24
|
+
// export {} from "./env"
|
|
25
|
+
export { errorToString } from "./errorToString";
|
|
26
|
+
export { findDuplicatedIndexes } from "./findDuplicatedIndexes";
|
|
27
|
+
export { forin } from "./forin";
|
|
28
|
+
export { gbToBytes } from "./gbToBytes";
|
|
29
|
+
export { getEmptyArray } from "./getEmptyArray";
|
|
30
|
+
export { getKeys } from "./getKeys";
|
|
31
|
+
export { getMediaQueryWidthResolvers } from "./getMediaQueryWidthResolvers";
|
|
32
|
+
export { getMediaQueryWidthTailwindScreens } from "./getMediaQueryWidthTailwindScreens";
|
|
33
|
+
export { getNonce } from "./getNonce";
|
|
34
|
+
export { getParamAmong } from "./getParamAmong";
|
|
35
|
+
export { getParamAsInt } from "./getParamAsInt";
|
|
36
|
+
export { getParamAsString } from "./getParamAsString";
|
|
37
|
+
export { getType } from "./getType";
|
|
38
|
+
export { getUrlHashParams } from "./getUrlHashParams";
|
|
39
|
+
export { getUrlHashPathname } from "./getUrlHashPathname";
|
|
40
|
+
export { getUrlPathnameParts } from "./getUrlPathnameParts";
|
|
41
|
+
export { getUrlQueryParams } from "./getUrlQueryParams";
|
|
42
|
+
export { imgEmptyPixel } from "./imgEmptyPixel";
|
|
43
|
+
export { isAnyObject } from "./isAnyObject";
|
|
44
|
+
export { isArray } from "./isArray";
|
|
45
|
+
export { isBlob } from "./isBlob";
|
|
46
|
+
export { isBoolean } from "./isBoolean";
|
|
47
|
+
export { isBrowser } from "./isBrowser";
|
|
48
|
+
export { isBrowserNow } from "./isBrowserNow";
|
|
49
|
+
export { isDate } from "./isDate";
|
|
50
|
+
export { isEmptyArray } from "./isEmptyArray";
|
|
51
|
+
export { isEmptyObject } from "./isEmptyObject";
|
|
52
|
+
export { isEmptyString } from "./isEmptyString";
|
|
53
|
+
export { isError } from "./isError";
|
|
54
|
+
export { isExternalUrl } from "./isExternalUrl";
|
|
55
|
+
export { isFile } from "./isFile";
|
|
56
|
+
export { isFloat } from "./isFloat";
|
|
57
|
+
export { isFormData } from "./isFormData";
|
|
58
|
+
export { isFullArray } from "./isFullArray";
|
|
59
|
+
export { isFullObject } from "./isFullObject";
|
|
60
|
+
export { isFullString } from "./isFullString";
|
|
61
|
+
export { isFunction } from "./isFunction";
|
|
62
|
+
export { isInt } from "./isInt";
|
|
63
|
+
export { isMap } from "./isMap";
|
|
64
|
+
export { isNaNValue } from "./isNaNValue";
|
|
65
|
+
export { isNegativeNumber } from "./isNegativeNumber";
|
|
66
|
+
export { isNullOrUndefined } from "./isNullOrUndefined";
|
|
67
|
+
export { isNull } from "./isNull";
|
|
68
|
+
export { isNumber } from "./isNumber";
|
|
69
|
+
export { isObjectLike } from "./isObjectLike";
|
|
70
|
+
export { isObject } from "./isObject";
|
|
71
|
+
export { isOneOf } from "./isOneOf";
|
|
72
|
+
export { isPlainObject } from "./isPlainObject";
|
|
73
|
+
export { isPositiveNumber } from "./isPositiveNumber";
|
|
74
|
+
export { isPrimitive } from "./isPrimitive";
|
|
75
|
+
export { isPromise } from "./isPromise";
|
|
76
|
+
export { isRegExp } from "./isRegExp";
|
|
77
|
+
export { isServer } from "./isServer";
|
|
78
|
+
export { isServerNow } from "./isServerNow";
|
|
79
|
+
export { isSet } from "./isSet";
|
|
80
|
+
export { isString } from "./isString";
|
|
81
|
+
export { isSymbol } from "./isSymbol";
|
|
82
|
+
export { isType } from "./isType";
|
|
83
|
+
export { isUndefined } from "./isUndefined";
|
|
84
|
+
export { isWeakMap } from "./isWeakMap";
|
|
85
|
+
export { isWeakSet } from "./isWeakSet";
|
|
86
|
+
export { kbToBytes } from "./kbToBytes";
|
|
87
|
+
export { lowercase } from "./lowercase";
|
|
88
|
+
export { mapListBy } from "./mapListBy";
|
|
89
|
+
export { matchSorter } from "./matchSorter";
|
|
90
|
+
export { mbToBytes } from "./mbToBytes";
|
|
91
|
+
export { mergeObjects } from "./mergeObjects";
|
|
92
|
+
export { mergeUrlQueryParams } from "./mergeUrlQueryParams";
|
|
93
|
+
export { moveSortableArrayItemByKey } from "./moveSortableArrayItemByKey";
|
|
94
|
+
export { noop } from "./noop";
|
|
95
|
+
export { normaliseUrlPathname } from "./normaliseUrlPathname";
|
|
96
|
+
export { normaliseUrl } from "./normaliseUrl";
|
|
97
|
+
export { objectPick } from "./objectPick";
|
|
98
|
+
export { objectOmit } from "./objectOmit";
|
|
99
|
+
export { parseCookie } from "./parseCookie";
|
|
100
|
+
export { parseURL } from "./parseURL";
|
|
101
|
+
export { quaranteneProps } from "./quaranteneProps";
|
|
102
|
+
export { randomInt } from "./randomInt";
|
|
103
|
+
export { randomKey } from "./randomKey";
|
|
104
|
+
export { readCookie } from "./readCookie";
|
|
105
|
+
export { removeAccents } from "./removeAccents";
|
|
106
|
+
export { removeCookie } from "./removeCookie";
|
|
107
|
+
// export {} from "./removeDuplicates";
|
|
108
|
+
export { removeDuplicatesByKey } from "./removeDuplicatesByKey";
|
|
109
|
+
export { removeDuplicatesComparing } from "./removeDuplicatesComparing";
|
|
110
|
+
export { removeIndexesFromArray } from "./removeIndexesFromArray";
|
|
111
|
+
export { removeTralingSlash } from "./removeTrailingSlash";
|
|
112
|
+
export { removeUrlQueryParams } from "./removeUrlQueryParams";
|
|
113
|
+
export { roundTo } from "./roundTo";
|
|
114
|
+
export { serializeCookie } from "./serializeCookie";
|
|
115
|
+
export { setCookie } from "./setCookie";
|
|
116
|
+
export { shuffle } from "./shuffle";
|
|
117
|
+
export { slugify } from "./slugify";
|
|
118
|
+
export { swapMap } from "./swapMap";
|
|
119
|
+
export { throttle } from "./throttle";
|
|
120
|
+
export { titleCase } from "./titleCase";
|
|
121
|
+
export { toNumber } from "./toNumber";
|
|
122
|
+
export { toRgba } from "./toRgba";
|
|
123
|
+
export { transformToUrlPathname } from "./transformToUrlPathname";
|
|
124
|
+
export { truncate } from "./truncate";
|
|
125
|
+
export { tryUntil } from "./tryUntil";
|
|
126
|
+
export { uid } from "./uid";
|
|
127
|
+
export { updateLinkParams } from "./updateLinkParams";
|
|
128
|
+
export { updateUrlQueryParams } from "./updateUrlQueryParams";
|
|
129
|
+
export { uppercase } from "./uppercase";
|
|
130
|
+
export { uuid } from "./uuid";
|
|
131
|
+
export { uuidNumeric } from "./uuidNumeric";
|
|
132
|
+
export { wait } from "./wait";
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"clsx": "1.2.1",
|
|
6
6
|
"ts-debounce": "^4.0.0",
|
|
7
|
-
"type-fest": "^3.
|
|
7
|
+
"type-fest": "^3.11.1"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"tslib": "
|
|
10
|
+
"tslib": "2.5.3"
|
|
11
11
|
},
|
|
12
12
|
"main": "./index.js",
|
|
13
13
|
"types": "./index.d.ts",
|
|
14
|
-
"version": "
|
|
14
|
+
"version": "2.0.0-alpha.2",
|
|
15
15
|
"module": "./index.mjs"
|
|
16
16
|
}
|
package/render.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
type DefinitionExtended = {
|
|
2
|
+
__exp?: {
|
|
3
|
+
[key: string]: number | boolean | string;
|
|
4
|
+
};
|
|
5
|
+
arg: string;
|
|
6
|
+
text: string;
|
|
7
|
+
};
|
|
8
|
+
type Definitions = {
|
|
9
|
+
[key: string]: DefinitionExtended;
|
|
10
|
+
} & DefinitionExtended;
|
|
11
|
+
/**
|
|
12
|
+
* Returned render function
|
|
13
|
+
*/
|
|
14
|
+
type RenderFunction = (data: object) => string;
|
|
15
|
+
/**
|
|
16
|
+
* Render template (adapted from doT.js)
|
|
17
|
+
*
|
|
18
|
+
* The data made available to the template is always on the `data` key, e.g.:
|
|
19
|
+
* `renderer({ myVal: "xx" })`
|
|
20
|
+
* ... will be accessible on
|
|
21
|
+
* `<%= data.myVal %>`
|
|
22
|
+
*
|
|
23
|
+
* The default delimiters are customised to work without conflicts with Blade and Twig:
|
|
24
|
+
* ```
|
|
25
|
+
* <% %> for evaluation
|
|
26
|
+
* <%= %> for interpolation
|
|
27
|
+
* <%? %> for conditionals
|
|
28
|
+
* <%~ %> for array iteration
|
|
29
|
+
* <%# %> for compile-time evaluation/includes and partials
|
|
30
|
+
* <%## #%> for compile-time defines
|
|
31
|
+
*
|
|
32
|
+
* Unsupported:
|
|
33
|
+
* <%! %> for interpolation with encoding
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
*
|
|
38
|
+
* ```js
|
|
39
|
+
* import { render } from "...";
|
|
40
|
+
*
|
|
41
|
+
* const data = { name: "XYZ" };
|
|
42
|
+
* const tpl = `Hello <%= data.name %>`;
|
|
43
|
+
* const renderer = render(tpl);
|
|
44
|
+
*
|
|
45
|
+
* console.log(renderer(data)); // outputs 'Hello XYZ'
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @borrows [olado/doT by Laura Doktorova](https://github.com/olado/doT)
|
|
49
|
+
* @see https://olado.github.io/doT/index.html
|
|
50
|
+
*/
|
|
51
|
+
export declare const render: (tmpl: string, def?: Definitions) => RenderFunction;
|
|
52
|
+
export default render;
|
package/render.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.render = void 0;
|
|
4
|
+
var varname = "data";
|
|
5
|
+
var evaluate = /<%([\s\S]+?(\}?)+)%>/g;
|
|
6
|
+
var interpolate = /<%=([\s\S]+?)%>/g;
|
|
7
|
+
var conditional = /<%\?(\?)?\s*([\s\S]*?)\s*%>/g;
|
|
8
|
+
var iterate = /<%~\s*(?:%>|([\s\S]+?)\s*:\s*([\w$]+)\s*(?::\s*([\w$]+))?\s*%>)/g;
|
|
9
|
+
// const encode = /<%!([\s\S]+?)%>/g;
|
|
10
|
+
var use = /<%#([\s\S]+?)%>/g;
|
|
11
|
+
var useParams = /(^|[^\w$])def(?:\.|\[['"])([\w$.]+)(?:['"]\])?\s*:\s*([\w$.]+|"[^"]+"|'[^']+'|\{[^}]+\})/g;
|
|
12
|
+
var define = /<%##\s*([\w.$]+)\s*(:|=)([\s\S]+?)#%>/g;
|
|
13
|
+
var defineParams = /^\s*([\w$]+):([\s\S]+)/;
|
|
14
|
+
var start = "'+(";
|
|
15
|
+
var end = ")+'";
|
|
16
|
+
// const startencode = "'+encodeHTML(";
|
|
17
|
+
var skip = /$^/;
|
|
18
|
+
var resolveDefs = function (block, def) {
|
|
19
|
+
return (typeof block === "string" ? block : block.toString())
|
|
20
|
+
.replace(define || skip, function (_, code, assign, value) {
|
|
21
|
+
if (code.indexOf("def.") === 0) {
|
|
22
|
+
code = code.substring(4);
|
|
23
|
+
}
|
|
24
|
+
if (!(code in def)) {
|
|
25
|
+
if (assign === ":") {
|
|
26
|
+
value.replace(defineParams,
|
|
27
|
+
// @ts-expect-error nevermind
|
|
28
|
+
function (_, param, v) {
|
|
29
|
+
def[code] = { arg: param, text: v };
|
|
30
|
+
});
|
|
31
|
+
// @ts-expect-error nevermind
|
|
32
|
+
if (!(code in def))
|
|
33
|
+
def[code] = value;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
new Function("def", "def['" + code + "']=" + value)(def);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return "";
|
|
40
|
+
})
|
|
41
|
+
.replace(use || skip, function (_, code) {
|
|
42
|
+
code = code.replace(useParams, function (_, s, d, param) {
|
|
43
|
+
if (def[d] && def[d].arg && param) {
|
|
44
|
+
var rw = (d + ":" + param).replace(/'|\\/g, "_");
|
|
45
|
+
def.__exp = def.__exp || {};
|
|
46
|
+
def.__exp[rw] = def[d].text.replace(new RegExp("(^|[^\\w$])" + def[d].arg + "([^\\w$])", "g"), "$1" + param + "$2");
|
|
47
|
+
return s + "def.__exp['" + rw + "']";
|
|
48
|
+
}
|
|
49
|
+
return s;
|
|
50
|
+
});
|
|
51
|
+
var v = new Function("def", "return " + code)(def);
|
|
52
|
+
return v ? resolveDefs(v, def) : v;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
var unescape = function (code) {
|
|
56
|
+
return code.replace(/\\('|\\)/g, "$1").replace(/[\r\t\n]/g, " ");
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Render template (adapted from doT.js)
|
|
60
|
+
*
|
|
61
|
+
* The data made available to the template is always on the `data` key, e.g.:
|
|
62
|
+
* `renderer({ myVal: "xx" })`
|
|
63
|
+
* ... will be accessible on
|
|
64
|
+
* `<%= data.myVal %>`
|
|
65
|
+
*
|
|
66
|
+
* The default delimiters are customised to work without conflicts with Blade and Twig:
|
|
67
|
+
* ```
|
|
68
|
+
* <% %> for evaluation
|
|
69
|
+
* <%= %> for interpolation
|
|
70
|
+
* <%? %> for conditionals
|
|
71
|
+
* <%~ %> for array iteration
|
|
72
|
+
* <%# %> for compile-time evaluation/includes and partials
|
|
73
|
+
* <%## #%> for compile-time defines
|
|
74
|
+
*
|
|
75
|
+
* Unsupported:
|
|
76
|
+
* <%! %> for interpolation with encoding
|
|
77
|
+
* ```
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
*
|
|
81
|
+
* ```js
|
|
82
|
+
* import { render } from "...";
|
|
83
|
+
*
|
|
84
|
+
* const data = { name: "XYZ" };
|
|
85
|
+
* const tpl = `Hello <%= data.name %>`;
|
|
86
|
+
* const renderer = render(tpl);
|
|
87
|
+
*
|
|
88
|
+
* console.log(renderer(data)); // outputs 'Hello XYZ'
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @borrows [olado/doT by Laura Doktorova](https://github.com/olado/doT)
|
|
92
|
+
* @see https://olado.github.io/doT/index.html
|
|
93
|
+
*/
|
|
94
|
+
var render = function (tmpl, def) {
|
|
95
|
+
var sid = 0;
|
|
96
|
+
var indv;
|
|
97
|
+
var str = use || define ? resolveDefs(tmpl, def || {}) : tmpl;
|
|
98
|
+
str = ("var X='" +
|
|
99
|
+
str
|
|
100
|
+
.replace(/(^|\r|\n)\t* +| +\t*(\r|\n|$)/g, " ")
|
|
101
|
+
.replace(/\r|\n|\t|\/\*[\s\S]*?\*\//g, "")
|
|
102
|
+
.replace(/'|\\/g, "\\$&")
|
|
103
|
+
.replace(interpolate || skip, function (_, code) { return start + unescape(code) + end; })
|
|
104
|
+
// .replace(
|
|
105
|
+
// encode || skip,
|
|
106
|
+
// (_, code) => cse.startencode + unescape(code) + cse.end
|
|
107
|
+
// )
|
|
108
|
+
.replace(conditional || skip, function (_, elseCase, code) {
|
|
109
|
+
return elseCase
|
|
110
|
+
? code
|
|
111
|
+
? "';}else if(" + unescape(code) + "){X+='"
|
|
112
|
+
: "';}else{X+='"
|
|
113
|
+
: code
|
|
114
|
+
? "';if(" + unescape(code) + "){X+='"
|
|
115
|
+
: "';}X+='";
|
|
116
|
+
})
|
|
117
|
+
.replace(iterate || skip, function (_, arr, vName, iName) {
|
|
118
|
+
if (!arr)
|
|
119
|
+
return "';} } X+='";
|
|
120
|
+
sid++;
|
|
121
|
+
indv = iName || "i" + sid;
|
|
122
|
+
arr = unescape(arr);
|
|
123
|
+
return ("';var arr" +
|
|
124
|
+
sid +
|
|
125
|
+
"=" +
|
|
126
|
+
arr +
|
|
127
|
+
";if(arr" +
|
|
128
|
+
sid +
|
|
129
|
+
"){var " +
|
|
130
|
+
vName +
|
|
131
|
+
"," +
|
|
132
|
+
indv +
|
|
133
|
+
"=-1,l" +
|
|
134
|
+
sid +
|
|
135
|
+
"=arr" +
|
|
136
|
+
sid +
|
|
137
|
+
".length-1;while(" +
|
|
138
|
+
indv +
|
|
139
|
+
"<l" +
|
|
140
|
+
sid +
|
|
141
|
+
"){" +
|
|
142
|
+
vName +
|
|
143
|
+
"=arr" +
|
|
144
|
+
sid +
|
|
145
|
+
"[" +
|
|
146
|
+
indv +
|
|
147
|
+
"+=1];X+='");
|
|
148
|
+
})
|
|
149
|
+
.replace(evaluate || skip, function (_, code) { return "';" + unescape(code) + "X+='"; }) +
|
|
150
|
+
"';return X;")
|
|
151
|
+
.replace(/\n/g, "\\n")
|
|
152
|
+
.replace(/\t/g, "\\t")
|
|
153
|
+
.replace(/\r/g, "\\r")
|
|
154
|
+
.replace(/(\s|;|\}|^|\{)X\+='';/g, "$1")
|
|
155
|
+
.replace(/\+''/g, "");
|
|
156
|
+
//.replace(/(\s|;|\}|^|\{)X\+=''\+/g,'$1X+=');
|
|
157
|
+
try {
|
|
158
|
+
return new Function(varname, str);
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
if (process.env["NODE_ENV"] !== "production") {
|
|
162
|
+
console.log("Could not create a template function: " + str);
|
|
163
|
+
throw e;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return function () { return ""; };
|
|
167
|
+
};
|
|
168
|
+
exports.render = render;
|
|
169
|
+
exports.default = exports.render;
|