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.11.0 to 0.11.1

7

lib/core-decorators.js

@@ -0,1 +1,8 @@

/**
* core-decorators.js
* (c) 2016 Jay Phelps
* MIT Licensed
* https://github.com/jayphelps/core-decorators.js
* @license
*/
'use strict';

@@ -2,0 +9,0 @@

35

lib/time.js

@@ -15,14 +15,18 @@ 'use strict';

var CONSOLE_NATIVE = console;
var labels = {};
var labels = {};
var CONSOLE_TIME = console.time ? console.time.bind(console) : function (label) {
labels[label] = new Date();
// Exported for mocking in tests
var defaultConsole = {
time: console.time ? console.time.bind(console) : function (label) {
labels[label] = new Date();
},
timeEnd: console.timeEnd ? console.timeEnd.bind(console) : function (label) {
var timeNow = new Date();
var timeTaken = timeNow - labels[label];
delete labels[label];
console.log('' + label + ': ' + timeTaken + 'ms');
}
};
var CONSOLE_TIMEEND = console.timeEnd ? console.timeEnd.bind(console) : function (label) {
var timeNow = new Date();
var timeTaken = timeNow - labels[label];
console.log('' + label + ': ' + timeTaken + 'ms');
};
exports.defaultConsole = defaultConsole;
var count = 0;

@@ -36,6 +40,5 @@

var _ref2$1 = _ref2[1];
var konsole = _ref2$1 === undefined ? null : _ref2$1;
var console = _ref2$1 === undefined ? defaultConsole : _ref2$1;
var fn = descriptor.value;
var CONSOLE = konsole || CONSOLE_NATIVE;

@@ -52,7 +55,5 @@ if (prefix === null) {

value: function value() {
var time = CONSOLE.time || CONSOLE_TIME;
var timeEnd = CONSOLE.timeEnd || CONSOLE_TIMEEND;
var label = '' + prefix + '-' + count;
count++;
time(label);
console.time(label);

@@ -62,3 +63,3 @@ try {

} finally {
timeEnd(label);
console.timeEnd(label);
}

@@ -75,4 +76,2 @@ }

return (0, _privateUtils.decorate)(handleDescriptor, args);
}
module.exports = exports['default'];
}
{
"name": "core-decorators",
"version": "0.11.0",
"version": "0.11.1",
"description": "Library of ES2016 (ES7) JavaScript decorators inspired by languages that come with built-ins like @​override, @​deprecate, @​autobind, @​mixin and more! Works great with React/Angular/more!",

@@ -15,3 +15,4 @@ "main": "lib/core-decorators.js",

"build": "babel --out-dir lib src",
"test": "npm run build && mocha --compilers js:babel/register --require babel/polyfill 'test/**/*.spec.js'"
"build-bower": "babel-node scripts/build-bower.js",
"test": "npm run build && mocha --compilers js:babel/register --require babel/polyfill \"test/**/*.spec.js\""
},

@@ -51,2 +52,3 @@ "repository": {

"glob": "^6.0.1",
"interop-require": "1.0.0",
"mocha": "^2.2.5",

@@ -53,0 +55,0 @@ "sinon": "^1.15.4",

# core-decorators.js [![Build Status](https://travis-ci.org/jayphelps/core-decorators.js.svg?branch=master)](https://travis-ci.org/jayphelps/core-decorators.js)
Library of [JavaScript decorators](https://github.com/wycats/javascript-decorators) (aka ES2016/ES7 decorators) inspired by languages that come with built-ins like @​override, @​deprecate, @​autobind, @​mixin and more. Popular with React/Angular, but is framework agnostic. Similar to [Annotations in Java](https://docs.oracle.com/javase/tutorial/java/annotations/predefined.html) but unlike Java annotations, decorators are functions which are applied at runtime.
Library of [JavaScript stage-0 decorators](https://github.com/wycats/javascript-decorators) (aka ES2016/ES7 decorators [but that's not accurate](https://medium.com/@jayphelps/please-stop-referring-to-proposed-javascript-features-as-es7-cad29f9dcc4b)) inspired by languages that come with built-ins like @​override, @​deprecate, @​autobind, @​mixin and more. Popular with React/Angular, but is framework agnostic. Similar to [Annotations in Java](https://docs.oracle.com/javase/tutorial/java/annotations/predefined.html) but unlike Java annotations, decorators are functions which are applied at runtime.

@@ -13,4 +13,10 @@ _*compiled code is intentionally not checked into this repo_

This can be consumed by any transpiler that supports decorators like [babel.js](https://babeljs.io/) or using the recent iterations of TypeScript. To use with babel, you must include the correct babel plugins for decorator [parsing](http://babeljs.io/docs/plugins/syntax-decorators/) and [transformation](http://babeljs.io/docs/plugins/transform-decorators/) or use [stage-1](http://babeljs.io/docs/plugins/preset-stage-1/). *Babel 6 [does not yet support decorators](https://phabricator.babeljs.io/T2645), use Babel 5 until that is fixed.*
This can be consumed by any transpiler that supports stage-0 of the decorators spec, like [babel.js](https://babeljs.io/) version 5 or using the recent iterations of TypeScript. *Babel 6 [does not yet support decorators](https://phabricator.babeljs.io/T2645), use Babel 5 until that is fixed.*
##### Bower/globals
A globals version is available [here in the artifact repo](https://github.com/jayphelps/core-decorators-artifacts), or via `$ bower install core-decorators`. It defines a global variable `CoreDecorators`, which can then be used as you might expect: `@CoreDecorators.autobind()`, etc.
I *highly* recommend against using that globals build as it's quite strange you're using decorators (a proposed future feature of JavaScript) while not using ES2015 modules, a spec ratified feature used by nearly every modern framework. Also--[bower is on its deathbed](https://github.com/bower/bower/pull/1748) and IMO for very good reasons.
## Decorators

@@ -25,3 +31,3 @@

* [@nonenumerable](#nonenumerable)
* [@lazyInitialize](#lazyInitialize) :new:
* [@lazyInitialize](#lazyinitialize) :new:

@@ -39,10 +45,5 @@ ##### For Methods

##### For Classes
* [@autobind](#autobind)
* [@autobind](#autobind) :new:
* [@mixin](#mixin-alias-mixins) :new:
##### Proposed (not implemented, PRs welcome!):
* @assertArguments(arg1 => arg1, arg2 => arg2)
* @private
## Docs

@@ -438,2 +439,2 @@

# Future Compatibility
Since most people can't keep up to date with specs, it's important to note that ES2016 (including the decorators spec this relies on) is in-flux and subject to breaking changes. In fact, the [biggest change is coming shortly](https://github.com/wycats/javascript-decorators/pull/36) but I am active in the appropriate communities and will be keeping this project up to date as things progress. For the most part, these changes will usually be transparent to consumers of this project--that said, core-decorators has not yet reached 1.0 and may in fact introduce breaking changes. If you'd prefer not to receive these changes, be sure to lock your dependency to [PATCH](http://semver.org/). You can track the progress of core-decorators@1.0.0 in the [The Road to 1.0](https://github.com/jayphelps/core-decorators.js/issues/15) ticket.
Since most people can't keep up to date with specs, it's important to note that the spec is in-flux and subject to breaking changes. In fact, the [biggest change is coming shortly](https://github.com/wycats/javascript-decorators/pull/36) but I am active in the appropriate communities and will be keeping this project up to date as things progress. For the most part, these changes will usually be transparent to consumers of this project--that said, core-decorators has not yet reached 1.0 and may in fact introduce breaking changes. If you'd prefer not to receive these changes, be sure to lock your dependency to [PATCH](http://semver.org/). You can track the progress of core-decorators@1.0.0 in the [The Road to 1.0](https://github.com/jayphelps/core-decorators.js/issues/15) ticket.

@@ -0,1 +1,8 @@

/**
* core-decorators.js
* (c) 2016 Jay Phelps
* MIT Licensed
* https://github.com/jayphelps/core-decorators.js
* @license
*/
export { default as override } from './override';

@@ -2,0 +9,0 @@ export { default as deprecate, default as deprecated } from './deprecate';

import { decorate } from './private/utils';
const CONSOLE_NATIVE = console;
const labels = {};
const labels = {};
const CONSOLE_TIME = console.time ? console.time.bind(console) : label => {
labels[label] = new Date();
// Exported for mocking in tests
export const defaultConsole = {
time: console.time ? console.time.bind(console) : label => {
labels[label] = new Date();
},
timeEnd: console.timeEnd ? console.timeEnd.bind(console) : label => {
const timeNow = new Date();
const timeTaken = timeNow - labels[label];
delete labels[label];
console.log(`${label}: ${timeTaken}ms`);
}
};
const CONSOLE_TIMEEND = console.timeEnd ? console.timeEnd.bind(console) : label => {
const timeNow = new Date();
const timeTaken = timeNow - labels[label];
console.log(`${label}: ${timeTaken}ms`);
};
let count = 0;
function handleDescriptor(target, key, descriptor, [prefix = null, konsole = null]) {
function handleDescriptor(target, key, descriptor, [prefix = null, console = defaultConsole]) {
const fn = descriptor.value;
const CONSOLE = konsole || CONSOLE_NATIVE;

@@ -32,7 +34,5 @@ if (prefix === null) {

value() {
const time = CONSOLE.time || CONSOLE_TIME;
const timeEnd = CONSOLE.timeEnd || CONSOLE_TIMEEND;
const label = `${prefix}-${count}`;
count++;
time(label);
console.time(label);

@@ -42,3 +42,3 @@ try {

} finally {
timeEnd(label);
console.timeEnd(label);
}

@@ -45,0 +45,0 @@ }

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