core-decorators
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -7,3 +7,5 @@ 'use strict'; | ||
exports['default'] = mixin; | ||
var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors; | ||
var _privateUtils = require('./private/utils'); | ||
var defineProperty = Object.defineProperty; | ||
@@ -17,3 +19,3 @@ | ||
for (var i = 0, l = mixins.length; i < l; i++) { | ||
var descs = getOwnPropertyDescriptors(mixins[i]); | ||
var descs = (0, _privateUtils.getOwnPropertyDescriptors)(mixins[i]); | ||
@@ -20,0 +22,0 @@ for (var key in descs) { |
@@ -10,2 +10,3 @@ 'use strict'; | ||
exports.metaFor = metaFor; | ||
exports.getOwnPropertyDescriptors = getOwnPropertyDescriptors; | ||
@@ -16,2 +17,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var defineProperty = Object.defineProperty; | ||
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; | ||
var getOwnPropertyNames = Object.getOwnPropertyNames; | ||
var getOwnPropertySymbols = Object.getOwnPropertySymbols; | ||
function isDescriptor(desc) { | ||
@@ -49,4 +55,2 @@ if (!desc || !desc.hasOwnProperty) { | ||
var defineProperty = Object.defineProperty; | ||
function metaFor(obj) { | ||
@@ -61,2 +65,16 @@ if (obj.hasOwnProperty('__core_decorators__') === false) { | ||
return obj.__core_decorators__; | ||
} | ||
var getOwnKeys = getOwnPropertySymbols ? function (object) { | ||
return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object)); | ||
} : getOwnPropertyNames; | ||
function getOwnPropertyDescriptors(obj) { | ||
var descs = {}; | ||
getOwnKeys(obj).forEach(function (key) { | ||
return descs[key] = getOwnPropertyDescriptor(obj, key); | ||
}); | ||
return descs; | ||
} |
{ | ||
"name": "core-decorators", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Library of ES7 decorators inspired by languages that come with built-ins like @override, @deprecated, etc", | ||
@@ -5,0 +5,0 @@ "main": "lib/core-decorators.js", |
@@ -31,3 +31,3 @@ # core-decorators.js [![Build Status](https://travis-ci.org/jayphelps/core-decorators.js.svg?branch=master)](https://travis-ci.org/jayphelps/core-decorators.js) | ||
##### For Classes | ||
* [@mixin](#mixin) | ||
* [@mixin](#mixin-alias-mixins) | ||
@@ -243,3 +243,3 @@ | ||
Mixes in all property descriptors from the provided Plain Old JavaScript Objects (aka POJOs) as arguments. Mixins are applied in the order they are passed, but do **not** overload descriptors originally on the class, included those inherited traditionally. | ||
Mixes in all property descriptors from the provided Plain Old JavaScript Objects (aka POJOs) as arguments. Mixins are applied in the order they are passed, but do **not** overload descriptors originally on the class, including those inherited traditionally. | ||
@@ -246,0 +246,0 @@ ```js |
@@ -1,3 +0,5 @@ | ||
const { getOwnPropertyDescriptors, defineProperty } = Object; | ||
import { getOwnPropertyDescriptors } from './private/utils'; | ||
const { defineProperty } = Object; | ||
function handleClass(target, mixins) { | ||
@@ -4,0 +6,0 @@ if (!mixins.length) { |
@@ -0,1 +1,4 @@ | ||
const { defineProperty, getOwnPropertyDescriptor, | ||
getOwnPropertyNames, getOwnPropertySymbols } = Object; | ||
export function isDescriptor(desc) { | ||
@@ -31,4 +34,2 @@ if (!desc || !desc.hasOwnProperty) { | ||
const { defineProperty } = Object; | ||
export function metaFor(obj) { | ||
@@ -44,1 +45,19 @@ if (obj.hasOwnProperty('__core_decorators__') === false) { | ||
} | ||
const getOwnKeys = getOwnPropertySymbols | ||
? function (object) { | ||
return getOwnPropertyNames(object) | ||
.concat(getOwnPropertySymbols(object)); | ||
} | ||
: getOwnPropertyNames; | ||
export function getOwnPropertyDescriptors(obj) { | ||
const descs = {}; | ||
getOwnKeys(obj).forEach( | ||
key => (descs[key] = getOwnPropertyDescriptor(obj, key)) | ||
); | ||
return descs; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62198
1370