@radishland/runtime 0.2.0 → 0.2.1
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/client/index.js +3 -5
- package/client/utils.d.ts +2 -10
- package/client/utils.js +4 -37
- package/package.json +5 -6
package/client/index.js
CHANGED
@@ -12,11 +12,9 @@ function type(value) {
|
|
12
12
|
if (!["object", "function"].includes(baseType)) {
|
13
13
|
return baseType;
|
14
14
|
}
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
return tag;
|
19
|
-
}
|
15
|
+
const tag = value[Symbol.toStringTag];
|
16
|
+
if (typeof tag === "string") {
|
17
|
+
return tag;
|
20
18
|
}
|
21
19
|
if (baseType === "function" && Function.prototype.toString.call(value).startsWith("class")) {
|
22
20
|
return "class";
|
package/client/utils.d.ts
CHANGED
@@ -1,14 +1,6 @@
|
|
1
1
|
declare const spaces_sep_by_comma: RegExp;
|
2
|
-
/**
|
3
|
-
* Idempotent string conversion to kebab-case
|
4
|
-
*/
|
5
|
-
declare const toKebabCase: (str: string) => string;
|
6
|
-
/**
|
7
|
-
* Idempotent string conversion to PascalCase
|
8
|
-
*/
|
9
|
-
declare const toPascalCase: (str: string) => string;
|
10
2
|
type LooseAutocomplete<T extends string> = T | Omit<string, T>;
|
11
|
-
type Types = LooseAutocomplete<"null" | "undefined" | "boolean" | "number" | "bigint" | "string" | "symbol" | "function" | "class" | "array" | "date" | "error" | "regexp" | "object">;
|
3
|
+
type Types = LooseAutocomplete<"null" | "undefined" | "boolean" | "number" | "bigint" | "string" | "symbol" | "function" | "AsyncFunction" | "class" | "array" | "date" | "error" | "regexp" | "object">;
|
12
4
|
/**
|
13
5
|
* A more reliable `typeof` function
|
14
6
|
*/
|
@@ -25,4 +17,4 @@ declare const bindingConfig: {
|
|
25
17
|
};
|
26
18
|
};
|
27
19
|
|
28
|
-
export { bindingConfig, booleanAttributes, spaces_sep_by_comma,
|
20
|
+
export { bindingConfig, booleanAttributes, spaces_sep_by_comma, type };
|
package/client/utils.js
CHANGED
@@ -1,36 +1,5 @@
|
|
1
1
|
// src/utils.ts
|
2
|
-
var is_upper = /[A-Z]/;
|
3
2
|
var spaces_sep_by_comma = /\s*,\s*/;
|
4
|
-
var toKebabCase = (str) => {
|
5
|
-
let kebab = "";
|
6
|
-
for (let index = 0; index < str.length; index++) {
|
7
|
-
const char = str[index];
|
8
|
-
if (index !== 0 && is_upper.test(char)) {
|
9
|
-
kebab += `-${char.toLowerCase()}`;
|
10
|
-
} else {
|
11
|
-
kebab += char.toLowerCase();
|
12
|
-
}
|
13
|
-
}
|
14
|
-
return kebab;
|
15
|
-
};
|
16
|
-
var toPascalCase = (str) => {
|
17
|
-
let pascal = "";
|
18
|
-
let toUpper = true;
|
19
|
-
for (let index = 0; index < str.length; index++) {
|
20
|
-
const char = str[index];
|
21
|
-
if (char === "-") {
|
22
|
-
toUpper = true;
|
23
|
-
continue;
|
24
|
-
}
|
25
|
-
if (toUpper) {
|
26
|
-
pascal += char.toUpperCase();
|
27
|
-
toUpper = false;
|
28
|
-
} else {
|
29
|
-
pascal += char.toLowerCase();
|
30
|
-
}
|
31
|
-
}
|
32
|
-
return pascal;
|
33
|
-
};
|
34
3
|
function type(value) {
|
35
4
|
if (value === null) {
|
36
5
|
return "null";
|
@@ -42,11 +11,9 @@ function type(value) {
|
|
42
11
|
if (!["object", "function"].includes(baseType)) {
|
43
12
|
return baseType;
|
44
13
|
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
return tag;
|
49
|
-
}
|
14
|
+
const tag = value[Symbol.toStringTag];
|
15
|
+
if (typeof tag === "string") {
|
16
|
+
return tag;
|
50
17
|
}
|
51
18
|
if (baseType === "function" && Function.prototype.toString.call(value).startsWith("class")) {
|
52
19
|
return "class";
|
@@ -118,4 +85,4 @@ var bindingConfig = {
|
|
118
85
|
}
|
119
86
|
};
|
120
87
|
|
121
|
-
export { bindingConfig, booleanAttributes, spaces_sep_by_comma,
|
88
|
+
export { bindingConfig, booleanAttributes, spaces_sep_by_comma, type };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@radishland/runtime",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.1",
|
4
4
|
"type": "module",
|
5
5
|
"description": "The Radish runtime",
|
6
6
|
"author": "Frédéric Crozatier",
|
@@ -12,10 +12,6 @@
|
|
12
12
|
"url": "https://github.com/radishland/radish/issues"
|
13
13
|
},
|
14
14
|
"license": "MIT",
|
15
|
-
"scripts": {
|
16
|
-
"build": "tsup",
|
17
|
-
"prepublishOnly": "pnpm build"
|
18
|
-
},
|
19
15
|
"exports": {
|
20
16
|
".": {
|
21
17
|
"import": "./client/index.js",
|
@@ -46,5 +42,8 @@
|
|
46
42
|
"devDependencies": {
|
47
43
|
"tsup": "^8.4.0",
|
48
44
|
"typescript": "^5.7.3"
|
45
|
+
},
|
46
|
+
"scripts": {
|
47
|
+
"build": "tsup"
|
49
48
|
}
|
50
|
-
}
|
49
|
+
}
|