@pixpilot/object 0.0.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/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/keys-to-camel-case.cjs +1 -0
- package/dist/keys-to-camel-case.d.ts +6 -0
- package/dist/keys-to-camel-case.js +1 -0
- package/dist/keys-to-snake-case.cjs +1 -0
- package/dist/keys-to-snake-case.d.ts +9 -0
- package/dist/keys-to-snake-case.js +1 -0
- package/package.json +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 pixpilot
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./keys-to-camel-case.cjs"),s=require("./keys-to-snake-case.cjs");exports.keysToCamelCase=e.keysToCamelCase,exports.keysToSnakeCase=s.keysToSnakeCase;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{keysToCamelCase}from"./keys-to-camel-case.js";export{keysToSnakeCase}from"./keys-to-snake-case.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=require("@pixpilot/string");exports.keysToCamelCase=function e(t){if(Array.isArray(t))return t.map(e);if(null===t||"object"!=typeof t)return t;const o={};for(const[s,i]of Object.entries(t)){o[r.toCamelCase(s)]=e(i)}return o};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type CamelCase<S extends string> = S extends `${infer P1}_${infer P2}${infer P3}` ? `${P1}${Uppercase<P2>}${CamelCase<P3>}` : S;
|
|
2
|
+
type KeysToCamelCase<T> = {
|
|
3
|
+
[K in keyof T as CamelCase<string & K>]: T[K] extends Record<string, unknown> ? KeysToCamelCase<T[K]> : T[K] extends readonly (infer U)[] ? U extends Record<string, unknown> ? readonly KeysToCamelCase<U>[] : T[K] : T[K];
|
|
4
|
+
};
|
|
5
|
+
export declare function keysToCamelCase<T>(obj: T): T extends Record<string, unknown> ? KeysToCamelCase<T> : T;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toCamelCase as r}from"@pixpilot/string";function t(o){if(Array.isArray(o))return o.map(t);if(null===o||"object"!=typeof o)return o;const n={};for(const[e,i]of Object.entries(o)){n[r(e)]=t(i)}return n}export{t as keysToCamelCase};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var r=require("@pixpilot/string");exports.keysToSnakeCase=function e(t){if(Array.isArray(t))return t.map(e);if(null===t||"object"!=typeof t)return t;const n={};for(const[o,s]of Object.entries(t)){n[r.toSnakeCase(o)]=e(s)}return n};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type SnakeCase<S extends string> = S extends `${infer T}${infer U}` ? `${T extends Uppercase<T> ? '_' : ''}${Lowercase<T>}${SnakeCase<U>}` : S;
|
|
2
|
+
type KeysToSnakeCase<T> = {
|
|
3
|
+
[K in keyof T as SnakeCase<string & K>]: T[K] extends Record<string, unknown> ? KeysToSnakeCase<T[K]> : T[K] extends readonly (infer U)[] ? U extends Record<string, unknown> ? readonly KeysToSnakeCase<U>[] : T[K] : T[K];
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Converts object keys from camelCase to snake_case recursively
|
|
7
|
+
*/
|
|
8
|
+
export declare function keysToSnakeCase<T>(obj: T): T extends Record<string, unknown> ? KeysToSnakeCase<T> : T;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toSnakeCase as r}from"@pixpilot/string";function t(o){if(Array.isArray(o))return o.map(t);if(null===o||"object"!=typeof o)return o;const n={};for(const[e,i]of Object.entries(o)){n[r(e)]=t(i)}return n}export{t as keysToSnakeCase};
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pixpilot/object",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"author": "Pixpilot <m.doaie@hotmail.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/pixpilot/js-utils.git",
|
|
10
|
+
"directory": "packages/object"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^22.18.10",
|
|
28
|
+
"eslint": "^9.37.0",
|
|
29
|
+
"rollup": "^4.52.4",
|
|
30
|
+
"typescript": "^5.9.3",
|
|
31
|
+
"@internal/eslint-config": "0.3.0",
|
|
32
|
+
"@internal/prettier-config": "0.0.1",
|
|
33
|
+
"@internal/rollup-config": "0.1.0",
|
|
34
|
+
"@internal/tsconfig": "0.1.0",
|
|
35
|
+
"@internal/vitest-config": "0.1.0",
|
|
36
|
+
"@pixpilot/string": "0.1.0"
|
|
37
|
+
},
|
|
38
|
+
"prettier": "@internal/prettier-config",
|
|
39
|
+
"scripts": {
|
|
40
|
+
"clean": "git clean -xdf .cache .turbo dist",
|
|
41
|
+
"clean:all": "git clean -xdf .cache .turbo dist node_modules",
|
|
42
|
+
"build": "pnpm run clean && rollup -c",
|
|
43
|
+
"test": "vitest --run --passWithNoTests",
|
|
44
|
+
"test:watch": "vitest --watch",
|
|
45
|
+
"test:ui": "vitest --ui",
|
|
46
|
+
"test:coverage": "vitest --coverage",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"lint": "eslint",
|
|
49
|
+
"format": "prettier --check . --ignore-path ../../.gitignore --ignore-path ../../.prettierignore"
|
|
50
|
+
},
|
|
51
|
+
"main": "./dist/index.cjs",
|
|
52
|
+
"module": "./dist/index.js",
|
|
53
|
+
"types": "./dist/index.d.ts"
|
|
54
|
+
}
|