{"id":21031283,"url":"https://github.com/workable/objecttransformator","last_synced_at":"2025-10-25T00:13:45.141Z","repository":{"id":43993495,"uuid":"240236924","full_name":"Workable/objectTransformator","owner":"Workable","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-15T15:00:15.000Z","size":1774,"stargazers_count":0,"open_issues_count":17,"forks_count":1,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-02-20T21:37:07.742Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Workable.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-13T10:46:17.000Z","updated_at":"2020-02-17T10:06:12.000Z","dependencies_parsed_at":"2023-02-03T17:30:38.067Z","dependency_job_id":null,"html_url":"https://github.com/Workable/objectTransformator","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workable%2FobjectTransformator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workable%2FobjectTransformator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workable%2FobjectTransformator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Workable%2FobjectTransformator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Workable","download_url":"https://codeload.github.com/Workable/objectTransformator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243471455,"owners_count":20296120,"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-19T12:27:04.138Z","updated_at":"2025-10-25T00:13:45.042Z","avatar_url":"https://github.com/Workable.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# objectTransformator\n\nTransforms a javascript object from one shape to another.\n`objectTransformator` comes with some preset transformations.\n\n## Installing\n\nUsing npm:\n\n```\n\\$ npm install @workablehr/object-transformator\n```\n\n## Basic usage\n\n```javascript\nimport { underscoredKeys } from \"@workablehr/object-transformator\";\n\nunderscoredKeys({ attrV1: \"val1\", attrs: { attrV2: \"val2\" } });\n// {attr_v1: 'val1', attrs: {attr_v2: 'val2'}}\n```\n\n## Presets\n\n### camelizeKeys\n\nTransforms all the object keys to camel case.\n\n- shallow, if true, it transforms only the first level of the object.\n- omit, excludes specific keys from the transformation.\n\n```javascript\nimport { camelizeKeys } from \"@workablehr/object-transformator\";\n\ncamelizeKeys({ attr_v1: \"val1\", attrs: { attr_v2: \"val2\" } });\n// { attrV1: \"val1\", attrs: { attrV2: \"val2\" } }\n```\n\n### underscoredKeys\n\nTransforms all the object keys to underscored case.\n\n- shallow, if true, it transforms only the first level of the object.\n- omit, excludes specific keys from the transformation.\n\n```javascript\nimport { underscoredKeys } from \"@workablehr/object-transformator\";\n\nunderscoredKeys(\n  { attrV1: \"val1\", attrs: { attrV2: \"val2\" } },\n  { shallow: true }\n);\n// {attr_v1: 'val1', attrs: {attrV2: 'val2'}}\n```\n\n## transformator\n\nThe pure transformator function.\n\n```javascript\nimport transformKeys from \"@workablehr/object-transformator\";\n\nconst prefixKeys = (data, prefix, { shallow = false, omit = [] } = {}) =\u003e\n  transformKeys(data, {\n    shallow,\n    func: prefixKeys,\n    action: (target, key, value) =\u003e ({ ...target, [prefix + key]: value }),\n    omit\n  });\n\nprefixKeys({ attr1: \"val1\", attrs: { attr2: \"val2\" } }, \"v1_\");\n// {{ v1_attr1: \"val1\", v1_attrs: { v1_attr2: \"val2\" } }}\n```\n\n### compose\n\nCreates a chain of transformators.\n\n```javascript\nimport transformKeys, {compose} from \"@workablehr/object-transformator\";\n\nconst prefixAction =  (target, key, value) =\u003e ({ ...target, ['v1_' + key]: value })\nconst payloadTransformator = data =\u003e\n  transformKeys(data, {\n    func: payloadTransformator,\n    action: compose(\n      camelizeKey,\n      prefixAction\n    )\n  });\n\npayloadTransformator({...});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkable%2Fobjecttransformator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fworkable%2Fobjecttransformator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fworkable%2Fobjecttransformator/lists"}