{"id":40813,"library":"decorate","title":"decorate","description":"decorate is a lightweight library (v1.0.0) that allows using decorators in JavaScript without needing transpilers like Babel or TypeScript. It provides a `decorate()` function that applies decorators to classes, methods, or properties. It is useful for environments where native decorator syntax is unsupported or to avoid build tooling. The package is stable but has low release cadence. It offers both ESM and CJS exports and works in Node.js and browsers. Differentiator: it enables decorator patterns without transpilation overhead.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","decorators","decorator","decorate","syntax","transpiler"],"install":[{"cmd":"npm install decorate","lang":"bash","label":"npm"},{"cmd":"yarn add decorate","lang":"bash","label":"yarn"},{"cmd":"pnpm add decorate","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default import. The package provides a default export. In CommonJS, use require('decorate').default.","wrong":"const decorate = require('decorate')","symbol":"default (decorate)","correct":"import decorate from 'decorate'"}],"quickstart":{"code":"import decorate from 'decorate';\n\nclass MyClass {\n  greet() { return 'Hello'; }\n}\n\n// Class decorator function\nfunction classDecorator(cls) {\n  cls.prototype.version = '1.0';\n}\n\ndecorate(MyClass, classDecorator);\n\nconsole.log(new MyClass().version); // '1.0'\n\n// Method decorator (non-enumerable)\nfunction nonenumerable(target, key, descriptor) {\n  descriptor.enumerable = false;\n  return descriptor;\n}\n\nclass MyClass2 {\n  secret() { return 'hidden'; }\n}\n\ndecorate(MyClass2, 'secret', nonenumerable);\n\nconsole.log(Object.keys(MyClass2.prototype)); // []","lang":"javascript","description":"Shows how to import and use decorate to apply class and method decorators without transpiler."},"warnings":[{"fix":"The class is modified directly; treat it as mutation.","message":"decorate() mutates the class/prototype in place; it does not return a new class.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Apply decorators in the order they should execute.","message":"decorate() applies decorators immediately when called, not at decoration time, so order matters.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'allow':9 'appli':27 'avoid':47 'babel':18 'browser':71 'build':48 'cadenc':58 'cjs':64 'class':30 'decor':1,2,11,24,28,41,75,81,82,83 'differenti':72 'enabl':74 'environ':38 'esm':62 'export':65 'function':25 'javascript':13,80 'librari':6 'lightweight':5 'like':17 'low':56 'method':31 'nativ':40 'need':15 'node.js':69 'offer':60 'overhead':79 'packag':51 'pattern':76 'properti':33 'provid':22 'releas':57 'stabl':53 'syntax':42,84 'tool':49 'transpil':16,78,85 'typescript':20 'unsupport':44 'use':10,36 'v1.0.0':7 'without':14,77 'work':67","created_at":"2026-06-04T18:49:23.690502+00:00","updated_at":"2026-06-04T18:49:23.690502+00:00","problems":[{"fix":"Use import decorate from 'decorate' or const decorate = require('decorate').default;","cause":"Using CommonJS require incorrectly; default export is under .default.","error":"TypeError: decorate is not a function"},{"fix":"Ensure decorator argument is a function (class) or string (method name) followed by decorator function.","cause":"Decorator is not a function or is applied incorrectly.","error":"Cannot use decorator on undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"decorate","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}