{"id":18604274,"url":"https://github.com/izica/decorators-es6","last_synced_at":"2025-11-02T10:30:28.350Z","repository":{"id":139291606,"uuid":"210015396","full_name":"izica/decorators-es6","owner":"izica","description":"Decorators for es6+, with promise support","archived":false,"fork":false,"pushed_at":"2019-10-25T11:23:18.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T07:14:20.382Z","etag":null,"topics":["debounce","debounce-function","debounce-promises","decorator","decorator-es6","decorators","es6","es6-javascript","javascript","js","memoize","memoize-async","memoize-decorator","throttle","throttle-function","throttle-promises"],"latest_commit_sha":null,"homepage":"","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/izica.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":"2019-09-21T16:12:18.000Z","updated_at":"2019-10-25T11:23:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"07d68399-ab0c-4eb3-b15b-dab25fa39c69","html_url":"https://github.com/izica/decorators-es6","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/izica%2Fdecorators-es6","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izica%2Fdecorators-es6/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izica%2Fdecorators-es6/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izica%2Fdecorators-es6/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/izica","download_url":"https://codeload.github.com/izica/decorators-es6/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239073970,"owners_count":19577124,"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":["debounce","debounce-function","debounce-promises","decorator","decorator-es6","decorators","es6","es6-javascript","javascript","js","memoize","memoize-async","memoize-decorator","throttle","throttle-function","throttle-promises"],"created_at":"2024-11-07T02:17:15.099Z","updated_at":"2025-11-02T10:30:28.304Z","avatar_url":"https://github.com/izica.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# decorators-es6\nDecorators for es6+, with promise support(Async support)\n### Install\n```\nnpm install decorators-es6\n```\n```\nyarn add decorators-es6\n```\n\n### Decorators \n* debounce\n* memoize\n* cache - alias for memoize\n* throttle\n\n### Features\n* Easy to use as decorator in es6\n* Promise support\n* Decorated function return value in promise chain\n* Async(work with async as promise)\n\n### Warning\nFor use this package your app need to support these features(Babel or Polyfills):\n* Promise\n* arrow functions () =\u003e {}\n* import, export\n\n### Usage\n#### debounce(time)\nDefault debounce time = 500ms\n```javascript\nimport { debounce } from 'decorators-es6';\n\nclass Store {\n    message = 'msg';\n\n    @debounce(1000)\n    changeMessage = (message) =\u003e {\n        this.message = message;\n        return 'updated';\n    };\n\n    @debounce(1000)\n    updateOnServer = (message) =\u003e {\n        return axios.post('/message/update', {message});\n    }\n}\n\nconst store = new Store();\nstore.changeMessage('msg2');\n\nstore.changeMessage('msg2').then(value =\u003e {\n    //debounce firing;\n    console.log(value) // 'updated'\n});\n\nstore.updateOnServer('msg2').then(response =\u003e {\n    //debounce firing;\n    console.log(response) // axios response from server(Promise resolve)\n});\n```\n\n#### memoize(time) or cache(time)\nDefault memoize time = 9999999ms\n```javascript\nimport { memoize} from 'decorators-es6';\n\nclass Service {\n    @memoize()\n    calc = (number) =\u003e {\n        return number * 5;\n    };\n    \n    // memoize product info for 100 secs\n    @memoize(100000) \n    getProductFromServer = (productId) =\u003e {\n        return axios.post('/product', {productId});\n    }\n}\n\nconst service = new Service();\nservice.calc(10).then(result =\u003e {\n    console.log(result);\n})\n\nservice.getProductFromServer().then(response =\u003e {\n    console.log(response); // response from axios for example\n    store.product = response.data.product;\n})\n```\n\n#### throtle(time)\nDefault debounce time = 500ms\nExample: see debounce example","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizica%2Fdecorators-es6","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fizica%2Fdecorators-es6","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizica%2Fdecorators-es6/lists"}