@pixpilot/object 2.4.0 → 2.4.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.
|
@@ -1,32 +1,12 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let __pixpilot_guid = require("@pixpilot/guid");
|
|
3
|
+
__pixpilot_guid = require_rolldown_runtime.__toESM(__pixpilot_guid);
|
|
2
4
|
let __pixpilot_string = require("@pixpilot/string");
|
|
3
5
|
__pixpilot_string = require_rolldown_runtime.__toESM(__pixpilot_string);
|
|
4
6
|
|
|
5
7
|
//#region src/keys-to-camel-case.ts
|
|
6
|
-
const FIRST_CHARACTER_INDEX = 0;
|
|
7
|
-
const GUID_LENGTH = 36;
|
|
8
|
-
const GUID_SEPARATOR_CODE = "-".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
9
|
-
const GUID_SEPARATOR_ONE_INDEX = 8;
|
|
10
|
-
const GUID_SEPARATOR_TWO_INDEX = 13;
|
|
11
|
-
const GUID_SEPARATOR_THREE_INDEX = 18;
|
|
12
|
-
const GUID_SEPARATOR_FOUR_INDEX = 23;
|
|
13
|
-
const ZERO_CODE = "0".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
14
|
-
const NINE_CODE = "9".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
15
|
-
const UPPERCASE_A_CODE = "A".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
16
|
-
const UPPERCASE_F_CODE = "F".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
17
|
-
const LOWERCASE_A_CODE = "a".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
18
|
-
const LOWERCASE_F_CODE = "f".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
19
|
-
function isHexCode(charCode) {
|
|
20
|
-
return charCode >= ZERO_CODE && charCode <= NINE_CODE || charCode >= UPPERCASE_A_CODE && charCode <= UPPERCASE_F_CODE || charCode >= LOWERCASE_A_CODE && charCode <= LOWERCASE_F_CODE;
|
|
21
|
-
}
|
|
22
|
-
function isGuidString(key) {
|
|
23
|
-
if (key.length !== GUID_LENGTH) return false;
|
|
24
|
-
if (key.charCodeAt(GUID_SEPARATOR_ONE_INDEX) !== GUID_SEPARATOR_CODE || key.charCodeAt(GUID_SEPARATOR_TWO_INDEX) !== GUID_SEPARATOR_CODE || key.charCodeAt(GUID_SEPARATOR_THREE_INDEX) !== GUID_SEPARATOR_CODE || key.charCodeAt(GUID_SEPARATOR_FOUR_INDEX) !== GUID_SEPARATOR_CODE) return false;
|
|
25
|
-
for (let index = 0; index < key.length; index += 1) if (!(index === GUID_SEPARATOR_ONE_INDEX || index === GUID_SEPARATOR_TWO_INDEX || index === GUID_SEPARATOR_THREE_INDEX || index === GUID_SEPARATOR_FOUR_INDEX) && !isHexCode(key.charCodeAt(index))) return false;
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
8
|
function shouldConvertKey(key, options) {
|
|
29
|
-
if (isGuidString(key)) return false;
|
|
9
|
+
if ((0, __pixpilot_guid.isGuidString)(key)) return false;
|
|
30
10
|
return options?.shouldConvert?.(key) !== false;
|
|
31
11
|
}
|
|
32
12
|
function keysToCamelCase(obj, options) {
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
+
import { isGuidString } from "@pixpilot/guid";
|
|
1
2
|
import { toCamelCase } from "@pixpilot/string";
|
|
2
3
|
|
|
3
4
|
//#region src/keys-to-camel-case.ts
|
|
4
|
-
const FIRST_CHARACTER_INDEX = 0;
|
|
5
|
-
const GUID_LENGTH = 36;
|
|
6
|
-
const GUID_SEPARATOR_CODE = "-".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
7
|
-
const GUID_SEPARATOR_ONE_INDEX = 8;
|
|
8
|
-
const GUID_SEPARATOR_TWO_INDEX = 13;
|
|
9
|
-
const GUID_SEPARATOR_THREE_INDEX = 18;
|
|
10
|
-
const GUID_SEPARATOR_FOUR_INDEX = 23;
|
|
11
|
-
const ZERO_CODE = "0".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
12
|
-
const NINE_CODE = "9".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
13
|
-
const UPPERCASE_A_CODE = "A".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
14
|
-
const UPPERCASE_F_CODE = "F".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
15
|
-
const LOWERCASE_A_CODE = "a".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
16
|
-
const LOWERCASE_F_CODE = "f".charCodeAt(FIRST_CHARACTER_INDEX);
|
|
17
|
-
function isHexCode(charCode) {
|
|
18
|
-
return charCode >= ZERO_CODE && charCode <= NINE_CODE || charCode >= UPPERCASE_A_CODE && charCode <= UPPERCASE_F_CODE || charCode >= LOWERCASE_A_CODE && charCode <= LOWERCASE_F_CODE;
|
|
19
|
-
}
|
|
20
|
-
function isGuidString(key) {
|
|
21
|
-
if (key.length !== GUID_LENGTH) return false;
|
|
22
|
-
if (key.charCodeAt(GUID_SEPARATOR_ONE_INDEX) !== GUID_SEPARATOR_CODE || key.charCodeAt(GUID_SEPARATOR_TWO_INDEX) !== GUID_SEPARATOR_CODE || key.charCodeAt(GUID_SEPARATOR_THREE_INDEX) !== GUID_SEPARATOR_CODE || key.charCodeAt(GUID_SEPARATOR_FOUR_INDEX) !== GUID_SEPARATOR_CODE) return false;
|
|
23
|
-
for (let index = 0; index < key.length; index += 1) if (!(index === GUID_SEPARATOR_ONE_INDEX || index === GUID_SEPARATOR_TWO_INDEX || index === GUID_SEPARATOR_THREE_INDEX || index === GUID_SEPARATOR_FOUR_INDEX) && !isHexCode(key.charCodeAt(index))) return false;
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
5
|
function shouldConvertKey(key, options) {
|
|
27
6
|
if (isGuidString(key)) return false;
|
|
28
7
|
return options?.shouldConvert?.(key) !== false;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixpilot/object",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.4.
|
|
4
|
+
"version": "2.4.2",
|
|
5
5
|
"description": "A collection of utility functions for object manipulation and transformation.",
|
|
6
6
|
"author": "Pixpilot <m.doaie@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@fastify/deepmerge": "^3.1.0",
|
|
29
29
|
"dot-prop": "^10.1.0",
|
|
30
|
-
"@pixpilot/
|
|
30
|
+
"@pixpilot/guid": "0.0.0",
|
|
31
|
+
"@pixpilot/string": "3.0.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@manypkg/get-packages": "^3.1.0",
|
|
@@ -37,9 +38,9 @@
|
|
|
37
38
|
"typescript": "^5.9.3",
|
|
38
39
|
"@internal/eslint-config": "0.3.0",
|
|
39
40
|
"@internal/prettier-config": "0.0.1",
|
|
40
|
-
"@internal/
|
|
41
|
+
"@internal/tsdown-config": "0.1.0",
|
|
41
42
|
"@internal/vitest-config": "0.1.0",
|
|
42
|
-
"@internal/
|
|
43
|
+
"@internal/tsconfig": "0.1.0"
|
|
43
44
|
},
|
|
44
45
|
"prettier": "@internal/prettier-config",
|
|
45
46
|
"scripts": {
|