core-decorators
Library of stage-0 JavaScript decorators (aka ES2016/ES7 decorators but not accurate) inspired by languages that come with built-ins like @override, @deprecate, @autobind, @mixin and more. Popular with React/Angular, but is framework agnostic.
core-decorators is a JavaScript library that provides a set of ready-made decorators for use with classes and class methods. Decorators are a syntax feature that lets you attach behavior to a function or class by placing an annotation (starting with @) directly above it, similar to how annotations work in Java or Python. For example, placing @autobind above a method ensures that the method always refers to its own class instance even when passed around as a standalone function, a common headache in React development. Placing @readonly on a property prevents it from being reassigned. Placing @deprecate on a method logs a console warning when the method is called, signaling to other developers that they should stop using it.
The full list of decorators in the library includes @autobind, @readonly, @override, @deprecate, @suppressWarnings, @nonenumerable, @nonconfigurable, @lazyInitialize, @time, @profile, and @mixin, among others. Several of these are marked as deprecated within the library itself because the scope has been narrowed over time.
An important caveat is stated at the top of the README: this library was written against an early draft of the JavaScript decorators specification (stage-0) that has since changed in incompatible ways. The decorators proposal has moved to a substantially different stage-2 form. As a result, the README explicitly says the library should mostly be considered unmaintained and is probably best avoided for new projects. It will only receive security or critical fixes until the decorator specification stabilizes further.
The library was designed to work with Babel 5 or with the babel-plugin-transform-decorators-legacy plugin. It does not officially support TypeScript. It has no framework dependency and was widely used in React and Angular projects during the period when this version of the decorator spec was common.