{"id":18722013,"url":"https://github.com/realign/data-helper","last_synced_at":"2025-11-11T04:30:15.981Z","repository":{"id":124607541,"uuid":"108556923","full_name":"ReAlign/data-helper","owner":"ReAlign","description":null,"archived":false,"fork":false,"pushed_at":"2017-11-30T10:41:24.000Z","size":26,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-28T15:17:03.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ReAlign.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-27T14:34:15.000Z","updated_at":"2017-11-27T05:56:29.000Z","dependencies_parsed_at":"2024-01-29T10:32:55.791Z","dependency_job_id":null,"html_url":"https://github.com/ReAlign/data-helper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReAlign%2Fdata-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReAlign%2Fdata-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReAlign%2Fdata-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ReAlign%2Fdata-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ReAlign","download_url":"https://codeload.github.com/ReAlign/data-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239587243,"owners_count":19663892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T13:39:21.138Z","updated_at":"2025-11-11T04:30:15.921Z","avatar_url":"https://github.com/ReAlign.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# data-helper\n\n\u003e 复杂业务下，复杂接口对应的大量数据，取值、维护存在较大困难。\n\u003e 抽象，封装库来简化工作复杂度\n\n* [x] 别名（批量获取中使用）\n    * 适用于多个不同数据源 / 多个入口进入时，数据统一处理\n* [ ] 遍历复杂对象\n    * 数据处理\n* [ ] 扁平化\n* [ ] 序列化\n* [ ] key匹配 / 数组匹配 / 结构匹配\n    * 批量 取值/赋值\n* [x] deepGet\n    * [x] 防止对象不存在时取子元素报错\n    * [x] 设置默认值，获取不到采用默认值\n* [x] 批量取值\n    * [x] 生成对象 或者 数组\n    * [ ] 目前是扁平化的，后续考虑 `key/key` 层级分割\n* [ ] 重复 key 处理\n    * 如果取值采用 key 匹配模式，需要考虑重复 key 情况\n* [x] deep copy\n    * 防止修改引用类型的数据报错、引发不可知问题\n* [x] 容错处理\n\n### 在处理复杂数据的时候，有什么痛点？\n\n1. 路径是否存在判断\n    * 获取 a.b.c，但是没有 a.b，导致报错\n2. 默认值\n    * 获取 a.b.c，c 不存在时，赋默认值\n3. 引用数据类型 莫名其妙被改变（deepClone）问题\n    * 在需要改变数据的场景，直接全部采用 deepClone\n4. 别名\n    * 调用公共接口，所需数据从多个接口获取，key 不统一，需要重命名\n\n***\n\n#### deepGet\n\n[DEMO](https://github.com/ReAlign/data-helper/blob/master/example/demo/deep-get.js)\n\n#### batchDeepGet\n\n[DEMO](https://github.com/ReAlign/data-helper/blob/master/example/demo/batch-deep-get.js)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealign%2Fdata-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frealign%2Fdata-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frealign%2Fdata-helper/lists"}