{"name":"sort-object-keys2","version":"3.0.5","keywords":["arr","array","deep","deterministic","function","js","key","keys","obj","object","order","re","re-order","recursive","recursively","sort","source","stable","util","utils","create-by-yarn-tool","create-by-tsdx"],"author":{"url":"http://keithcirkel.co.uk/","name":"Keith Cirkel","email":"npm@keithcirkel.co.uk"},"license":"MIT","_id":"sort-object-keys2@3.0.5","maintainers":[{"name":"bluelovers","email":"codelovers@users.sourceforge.net"}],"homepage":"https://github.com/bluelovers/ws-array/tree/master/packages/sort-object-keys#readme","bugs":{"url":"https://github.com/bluelovers/ws-array/issues"},"dist":{"shasum":"244c300a48cfa9e13ebc8d55c3afbb0e5cef12c2","tarball":"http://registry-npm.ywwl.com/sort-object-keys2/download/sort-object-keys2-3.0.5.tgz","fileCount":18,"integrity":"sha512-Q5fNSFbM4xXeTp1OtH62o67j+gzr2jPhZE0ES9bspDS26ScYfc2z5fL2vyRfVs947pkXCTS95Z/73lcbXuSJfg==","signatures":[{"sig":"MEYCIQDSSQ+hDoz2UcrNzte7tILgoXiVJdEUwmc1wyPkr0LPKwIhAKJeJSn7nd/MaB95o5VF625H6soMc0+HO3hu+VkPiFYX","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":44634,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjWD+QACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoOjRAAoovZ2e9d79v4j7P/q8OmmENHawqTUTb7iwQlKIBMT9sKAFuV\r\nQq4ssH35b1T/gbujuYmWHxDNFLlxvwv95AHs8qlnEUu1jNYKDaPH/Neo7uN+\r\nMK94Skr1X8N1QVe+rMY3F+NbdaJUjSq6TRHFme+xM/lj5+djM9dZO5efgjEd\r\na93GH+aPO4Z4bmcWc0duWb/9YIw4eVxfXnZWdnvoauThEXch4JmoagijGw7/\r\nk4Qi6tJNnRMNR03MQHcg/SBlwcZ5ojd9ZgNOLAI4zPhvSeDSOZKQDASmHy3b\r\nEDLh9zT9/9n8OJ/n+3aYN+xLYao/LmIeb6N8vo3v0kuYfVqEkXJ5cSx1iR++\r\nW3GvAGruDVwH6obXZyXHhNUKHtT+mgX066fh/9s0MWqKFU6JMI5amQlXMZtf\r\nLhEhlonnG0Tjkg2BC6Cq7XxgxR/o/mQCEuLDVw0mGh3NIygGPWKDy4menR/t\r\nRozVYNHucNEd51L1ybxeJyWFi3b0Q5RCZLLMItJSBxXz4bBEQa/lKGQ7bQ6E\r\n4hdnK3NSr0e+9herwcUOq9DgYbVVDpYYcXtJNK6SiV12oEarpBImHX3Cxv17\r\nP7jHnQMkjoxPkNeeH+VtTLtdRFtnK1470IHHXc2QfZGHCWy7bEReTGo5qLxt\r\n+wF6ZpWCl5EvZdQT8NbHw/tgMnnYzX2Lw6Q=\r\n=+fzF\r\n-----END PGP SIGNATURE-----\r\n","size":8133,"noattachment":false,"key":"/sort-object-keys2/-/sort-object-keys2-3.0.5.tgz"},"main":"dist/index.cjs","types":"dist/index.d.ts","unpkg":"dist/index.umd.production.min.cjs","module":"dist/index.esm.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.esm.mjs","require":"./dist/index.cjs"},"./core":{"types":"./dist/index.d.ts","import":"./dist/index.esm.mjs","require":"./dist/index.cjs"},"./src/*":"./src/*","./package.json":"./package.json"},"gitHead":"719fbb0eefb60ef137047dae8f2601d13ea6512a","scripts":{"ncu":"npx yarn-tool ncu -u","pack":"echo pack","test":"jest --passWithNoTests","build":"yarn run build:tsdx && yarn run build:dts:bundle","prepack":"echo prepack","prepare":"echo prepare","pretest":"echo pretest","publish":"echo publish","version":"echo version","ci:build":"echo ci:build","postpack":"echo postpack","posttest":"yarn run build","test:tsd":"ynpx tsd","test:jest":"jest --passWithNoTests","build:tsdx":"ynpx @bluelovers/tsdx build --target node","ci:install":"echo ci:install","prepublish":"echo prepublish","preversion":"echo preversion && yarn run test","npm:publish":"npm publish","postpublish":"git commit -m \"chore(release): publish\" .","postversion":"echo postversion","build:dts:tsc":"yarn run build:dts:tsc:emit && yarn run build:dts:copy","test:snapshot":"yarn run test -- -u","build:dts:copy":"copy .\\src\\index.d.ts .\\dist\\index.d.ts & echo build:dts","prepublishOnly":"yarn run ncu && yarn run sort-package-json && npx yarn-tool install && yarn run test","tsc:showConfig":"ynpx get-current-tsconfig -p","postpublishOnly":"echo postpublishOnly","build:dts:bundle":"ynpx dts-bundle-generator -o ./dist/index.d.ts ./src/index.ts --no-banner --inline-declare-global & echo build:dts:bundle","sort-package-json":"npx yarn-tool sort","build:dts:tsc:emit":"tsc --emitDeclarationOnly --declaration --noEmit false","test:jest:snapshot":"yarn run test:jest -- -u","prepublish:lockfile":"npx sync-lockfile .","prepublishOnly:update":"yarn run ncu && yarn run sort-package-json"},"typings":"dist/index.d.ts","_npmUser":{"name":"bluelovers","email":"codelovers@users.sourceforge.net"},"repository":{"url":"git+https://github.com/bluelovers/ws-array.git","type":"git","directory":"packages/sort-object-keys"},"_npmVersion":"lerna/6.0.1/node@v18.11.0+x64 (win32)","description":"Sort an object's keys, including an optional key list","directories":{"test":"test"},"sideEffects":false,"_nodeVersion":"18.11.0","dependencies":{"@lazy-array/util-unique":"^1.0.4"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.19","_npmOperationalInternal":{"tmp":"tmp/sort-object-keys2_3.0.5_1666727824379_0.42670293447380536","host":"s3://npm-registry-packages"},"readme":"# sort-object-keys2\n\n對物件的鍵進行排序，支援自訂排序函式、指定鍵順序和原地修改選項。\n\nSort object keys with custom sort functions, specified key order, and in-place modification options.\n\n## 功能說明 / Features\n\n- **基本排序**: 依字母順序排序物件鍵\n- **自訂排序**: 使用自訂排序函式\n- **指定鍵順序**: 指定特定鍵的排列順序\n- **原地修改**: 可選擇直接修改原物件\n- **Basic sorting**: Sort keys alphabetically\n- **Custom sorting**: Use custom sort functions\n- **Specified key order**: Specify particular key order\n- **In-place modification**: Option to modify source object directly\n\n## 安裝 / Install\n\n```bash\nyarn add sort-object-keys2\nyarn-tool add sort-object-keys2\nyt add sort-object-keys2\n```\n\n## 使用範例 / Usage Examples\n\n### 基本排序 / Basic Sorting\n\n```typescript\nimport { sortObjectKeys } from 'sort-object-keys2';\n\n// 依鍵名字母順序排序\nconst obj = { c: 1, b: 2, a: 3 };\nconst sorted = sortObjectKeys(obj);\n\nconsole.log(sorted); // => { a: 3, b: 2, c: 1 }\n```\n\n### 指定鍵順序 / Specify Key Order\n\n```typescript\nimport { sortObjectKeys } from 'sort-object-keys2';\n\n// 指定鍵的優先順序\nconst obj = { c: 1, b: 2, a: 3 };\nconst sorted = sortObjectKeys(obj, ['b', 'a', 'c']);\n\nconsole.log(sorted); // => { b: 2, a: 3, c: 1 }\n```\n\n### 自訂排序函式 / Custom Sort Function\n\n```typescript\nimport { sortObjectKeys } from 'sort-object-keys2';\n\n// 自然排序數字鍵\nconst obj = { key2: 1, key10: 1, key1: 1 };\nconst sorted = sortObjectKeys(obj, (a, b) => {\n  return a.localeCompare(b, undefined, { numeric: true });\n});\n\nconsole.log(sorted); // => { key1: 1, key2: 1, key10: 1 }\n```\n\n### 降序排列 / Descending Order\n\n```typescript\nimport { sortObjectKeys } from 'sort-object-keys2';\n\nconst obj = { a: 1, b: 2, c: 3 };\nconst sorted = sortObjectKeys(obj, { desc: true });\n\nconsole.log(sorted); // => { c: 3, b: 2, a: 1 }\n```\n\n### 只返回指定鍵 / Return Only Specified Keys\n\n```typescript\nimport { sortObjectKeys } from 'sort-object-keys2';\n\nconst obj = { a: 1, b: 2, c: 3 };\nconst sorted = sortObjectKeys(obj, { keys: ['b', 'c'], onlyKeys: true });\n\nconsole.log(sorted); // => { b: 2, c: 3 }\n```\n\n### 原地修改 / In-place Modification\n\n```typescript\nimport { sortObjectKeys } from 'sort-object-keys2';\n\nconst obj = { c: 1, b: 2, a: 3 };\nsortObjectKeys(obj, { useSource: true });\n\nconsole.log(obj); // => { a: 3, b: 2, c: 1 }\n```\n\n### 允許不存在的鍵 / Allow Non-existent Keys\n\n```typescript\nimport { sortObjectKeys } from 'sort-object-keys2';\n\nconst obj = { a: 1, b: 2 };\nconst sorted = sortObjectKeys(obj, { keys: ['b', 'c', 'a'], allowNotExists: true });\n\nconsole.log(sorted); // => { b: 2, c: undefined, a: 1 }\n```\n\n## 應用情境 / Application Scenarios\n\n1. **測試穩定性**: 確保物件結構穩定以便比對\n2. **API 響應**: 產生一致且可預測的 JSON 響應\n3. **表單欄位**: 自訂表單欄位的顯示順序\n4. **配置管理**: 排序配置物件以便閱讀\n\n## API 參考 / API Reference\n\n```typescript\ndeclare function sortObject<T>(object: T, options?: sortObject.IOptions & {\n    useSource: true;\n}): T;\ndeclare function sortObject<T>(object: T, options?: sortObject.IOptions & {\n    keys: string[];\n    onlyKeys: true;\n}): Partial<T>;\ndeclare function sortObject<T>(object: T, options?: sortObject.IOptions): Partial<T>;\ndeclare function sortObject<T>(object: T, sortFn: (a, b) => any): Partial<T>;\ndeclare function sortObject<T>(object: T, sortWith: string[]): Partial<T>;\n```\n\n[查看完整 API](index.d.ts)\n","publish_time":1666727824535,"_cnpm_publish_time":1666727824535,"dist-tags":{"latest":"3.0.10"}}