{"id":13516210,"url":"https://github.com/JakubMifek/SelectTransform","last_synced_at":"2025-03-31T06:30:28.901Z","repository":{"id":35020510,"uuid":"180161037","full_name":"JakubMifek/SelectTransform","owner":"JakubMifek","description":"This project is based upon https://github.com/SelectTransform/st.js but differs in implementation, functionality and robustness.","archived":false,"fork":false,"pushed_at":"2023-01-07T04:08:19.000Z","size":3818,"stargazers_count":21,"open_issues_count":3,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-01T23:34:35.885Z","etag":null,"topics":["javascript","json","modular","module","selecttransform","stjs","transform","typescript"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JakubMifek.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":"2019-04-08T13:59:27.000Z","updated_at":"2023-12-12T23:26:24.000Z","dependencies_parsed_at":"2023-01-15T12:09:55.142Z","dependency_job_id":null,"html_url":"https://github.com/JakubMifek/SelectTransform","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakubMifek%2FSelectTransform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakubMifek%2FSelectTransform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakubMifek%2FSelectTransform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JakubMifek%2FSelectTransform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JakubMifek","download_url":"https://codeload.github.com/JakubMifek/SelectTransform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246429459,"owners_count":20775805,"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":["javascript","json","modular","module","selecttransform","stjs","transform","typescript"],"created_at":"2024-08-01T05:01:20.357Z","updated_at":"2025-03-31T06:30:28.397Z","avatar_url":"https://github.com/JakubMifek.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# SelectTransform\n\nThis project is based upon https://github.com/SelectTransform/st.js but differs\nin implementation, functionality and robustness.\n\n## Description\nSelectTransform is a module that eases transformation of JS objects using JSON template and JS input data object.\n\nJSON template may contain special readable notation describing how to transform data objects.\n\n## Installation\n\n`npm i selecttransform`\n\n## Questions?\nThis package has deviated a bit from the original implementation and has numerous additional features. If you would like to contribute, join the development, help us maintain the repository or just have some questions about the usage, reach out to us on our community server: https://discord.gg/eNVm2N24\n\n## Example Usage\n\n### JavaScript\n```js\nconst ST = require('selecttransform').SelectTransform;\n\nconst st = new ST();\n\nconst data = {\n  name: 'Jakub',\n  friends: [\n    {\n      name: 'Michal',\n    },\n  ],\n};\n\nconst template = {\n  name: '{{ name }}',\n  friends: {\n    '{{ #each friends }}': {\n      index: '{{ $index }}',\n      name: '{{ name }}',\n    },\n  },\n};\n\n// Or you can use transformSync\nst.transform(template, data).then(console.log);\n\n// Result:\n/**\n * {\n *   \"name\": \"Jakub\",\n *   \"friends\": [\n *     {\n *       \"index\": 0,\n *       \"name\": \"Michal\"\n *     },\n *   ],\n * }\n */\n```\n\n### TypeScript\n```js\nimport { SelectTrasnform as ST } from 'selecttransform';\n\nconst st = new ST();\n\nconst data = {\n  name: 'Jakub',\n  friends: [\n    {\n      name: 'Michal',\n    },\n  ],\n};\n\nconst template = {\n  name: '{{ name }}',\n  friends: {\n    '{{ #each friends }}': {\n      index: '{{ $index }}',\n      name: '{{ name }}',\n    },\n  },\n};\n\n// Or you can use transform and promise-like structure\nconsole.log(st.transformSync(template, data));\n\n// Result:\n/**\n * {\n *   \"name\": \"Jakub\",\n *   \"friends\": [\n *     {\n *       \"index\": 0,\n *       \"name\": \"Michal\"\n *     },\n *   ],\n * }\n */\n```\n\nFor complete documentation see **[Wiki](https://github.com/JakubMifek/SelectTransform/wiki)** or *[tests](https://github.com/JakubMifek/SelectTransform/tree/master/__tests__)*.\n\n## Contributions\nYou are welcome to make a pull request to the repository which I will try to resolve as quickly as possible.\n\nMainly I'd expect you to want to extend functions available to you in templates. That is done using executors. Executors are separated into three categories:\n- **Value executors** - those are executors that are in place of any value in the template (eg. `ternary` executor: `\"name\": \"{{ #? path.to.name }}\"`)\n- **Key executors** - those are executors that are in place of any key, usually represent a function which has name and parameters (eg. `optional` executor: `\"{{ #optional name }}\": { ... }`)\n- **Array executors** - those are executors that are in place of an array (eg. `conditional` executor: `[{ \"{{ #if someCondition === true }}\": \"Correct\" }, { \"{{ #else }}\": \"Incorrect\" }]`)\n\nYou can freely create new executor in each of these categories using provided templates and by adding them into corresponding `index.ts` files.\n\nAlternatively, if you would like to make changes to `Select` or `Transform` classes I would gladly see to your requests or proposals.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJakubMifek%2FSelectTransform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJakubMifek%2FSelectTransform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJakubMifek%2FSelectTransform/lists"}