Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

core-decorators

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core-decorators - npm Package Compare versions

Comparing version 0.0.11 to 0.0.13

.editorconfig

13

package.json
{
"name": "core-decorators",
"version": "0.0.11",
"version": "0.0.13",
"description": "Library of ES7 decorators inspired by languages that come with built-ins like @override, @deprecated, etc",
"main": "src/core-decorators.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "mocha --require babel/register 'src/**/*.spec.js'"
},

@@ -29,3 +29,8 @@ "repository": {

},
"homepage": "https://github.com/jayphelps/core-decorators.js"
}
"homepage": "https://github.com/jayphelps/core-decorators.js",
"devDependencies": {
"babel": "^5.2.16",
"mocha": "^2.2.4",
"must": "^0.12.0"
}
}
# core-decorators.js
Library of ES7 decorators inspired by languages that come with built-ins like @​override, @​deprecate, etc, similar to [pre-defined Annotations in Java](https://docs.oracle.com/javase/tutorial/java/annotations/predefined.html).
Library of ES7 decorators inspired by languages that come with built-ins like @​override, @​deprecate, etc, similar to [pre-defined Annotations in Java](https://docs.oracle.com/javase/tutorial/java/annotations/predefined.html). Note that unlike Java annotations, decorators are functions which are applied at runtime.
The idea is these decorators would be used to ensure code sanity, but would be removed in production builds via a Babel plugin.
### @readonly

@@ -112,2 +110,23 @@

### @autobind
Forces invocations of this function to always have `this` refer to the class instance, even if the function is passed around or would otherwise lose its `this` context. e.g. `var fn = context.method;`
```js
import { autobind } from 'core-decorators';
class Person {
@autobind
getPerson() {
return this;
}
}
let person = new Person();
let getPerson = person.getPerson;
getPerson() === person;
// true
```
### @memoize

@@ -120,2 +139,2 @@

![adorable dog](https://cloud.githubusercontent.com/assets/762949/7152487/b0fec1ce-e2f1-11e4-9207-93fb1422381c.gif)
![adorable dog](https://cloud.githubusercontent.com/assets/762949/7152487/b0fec1ce-e2f1-11e4-9207-93fb1422381c.gif)

@@ -6,1 +6,2 @@ export { default as override } from './override';

export { default as readonly } from './readonly';
export { default as autobind } from './autobind';
import { decorate } from './private/utils';
function handleDescriptor(target, key, descriptor, [msg = DEFAULT_MSG, options = {}]) {
function handleDescriptor(target, key, descriptor) {
descriptor.writable = false;

@@ -5,0 +5,0 @@ return descriptor;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc