{"id":15408294,"url":"https://github.com/krzkaczor/babel-plugin-proxy","last_synced_at":"2025-04-14T12:50:54.660Z","repository":{"id":46184738,"uuid":"48659500","full_name":"krzkaczor/babel-plugin-proxy","owner":"krzkaczor","description":"Use ES6 proxies today!","archived":false,"fork":false,"pushed_at":"2017-05-11T04:33:10.000Z","size":11,"stargazers_count":65,"open_issues_count":7,"forks_count":6,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-30T01:36:00.285Z","etag":null,"topics":["babel","es6","javascript"],"latest_commit_sha":null,"homepage":"","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/krzkaczor.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":"2015-12-27T20:31:38.000Z","updated_at":"2024-05-13T11:41:24.000Z","dependencies_parsed_at":"2022-08-31T16:00:36.469Z","dependency_job_id":null,"html_url":"https://github.com/krzkaczor/babel-plugin-proxy","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzkaczor%2Fbabel-plugin-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzkaczor%2Fbabel-plugin-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzkaczor%2Fbabel-plugin-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krzkaczor%2Fbabel-plugin-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krzkaczor","download_url":"https://codeload.github.com/krzkaczor/babel-plugin-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248884709,"owners_count":21177475,"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":["babel","es6","javascript"],"created_at":"2024-10-01T16:33:14.978Z","updated_at":"2025-04-14T12:50:54.630Z","avatar_url":"https://github.com/krzkaczor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# babel-plugin-proxy\n[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n\nUse ES6 proxies today!\n\n## Installation\n    \n    npm install babel-plugin-proxy --save-dev\n\n## Motivation\n\nProxies are awesome feature of ES2015 that enables redefining some language operations. For example we can intercept every object property access with our own function.\n    \nThe problem is that proper proxy implementation requires native browser support (currently it works in Firefox and Edge). This plugin is proof of concept that proxies can be implemented with ES5 features. It is not suitable for production environments because performance impact is huge.\n    \n## How does it work?\n\nWe are intercepting every property access (except these connected with function invocation) and property assignment with custom interceptor functions that performs runtime check if object is proxied.\n    \n    proxy.foo = 5;\n    proxy.foo;\n       \nbecomes:\n    \n    globalSetInterceptor(proxy, \"foo\", 5);\n    globalGetInterceptor(proxy, 'foo');\n    \nThese interceptors performs runtime check if object should be proxied. You can check out whole runtime [here](https://github.com/krzkaczor/babel-plugin-proxy/blob/master/src/runtime.js)\n\n## Example\nProxies for example allow us to create objects that will warn us when `undefined` key is being accessed. \n     \n    var proxy = new Proxy({}, {\n        get: function(target, propKey) {\n            if (!(propKey in target)) {\n                console.log(\"Accessing undefined key!\");\n            }\n    \n            return target[propKey];\n        }\n    });\n    \n    proxy.a = 5;\n    console.log(proxy.a);\n    console.log(proxy.b);\n\noutput:\n\n    5\n    Accessing undefined key!\n    undefined","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrzkaczor%2Fbabel-plugin-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrzkaczor%2Fbabel-plugin-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrzkaczor%2Fbabel-plugin-proxy/lists"}