Template Upload
This commit is contained in:
5
node_modules/reflect-metadata/.npmignore
generated
vendored
Normal file
5
node_modules/reflect-metadata/.npmignore
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
./node_modules
|
||||
./test
|
||||
./typings
|
||||
./Reflect.ts
|
||||
./tsconfig.json
|
15
node_modules/reflect-metadata/CopyrightNotice.txt
generated
vendored
Normal file
15
node_modules/reflect-metadata/CopyrightNotice.txt
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
55
node_modules/reflect-metadata/LICENSE
generated
vendored
Normal file
55
node_modules/reflect-metadata/LICENSE
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
Apache License
|
||||
|
||||
Version 2.0, January 2004
|
||||
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||
|
||||
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||
|
||||
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
171
node_modules/reflect-metadata/README.md
generated
vendored
Normal file
171
node_modules/reflect-metadata/README.md
generated
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
Proposal to add Decorators to ES7, along with a prototype for an ES7 Reflection API for Decorator Metadata
|
||||
|
||||
# Metadata Reflection API
|
||||
|
||||
* [Detailed proposal][Metadata-Spec]
|
||||
|
||||
## Background
|
||||
|
||||
* [Decorators][] add the ability to augment a class and its members as the class is defined, through a declarative syntax.
|
||||
* Traceur attaches annotations to a static property on the class.
|
||||
* Languages like C# (.NET), and Java support attributes or annotations that add metadata to types, along with a reflective API for reading metadata.
|
||||
|
||||
## Goals
|
||||
|
||||
* A number of use cases (Composition/Dependency Injection, Runtime Type Assertions, Reflection/Mirroring, Testing) want the ability to add additional metadata to a class in a consistent manner.
|
||||
* A consistent approach is needed for various tools and libraries to be able to reason over metadata.
|
||||
* Metadata-producing decorators (nee. "Annotations") need to be generally composable with mutating decorators.
|
||||
* Metadata should be available not only on an object but also through a Proxy, with related traps.
|
||||
* Defining new metadata-producing decorators should not be arduous or over-complex for a developer.
|
||||
* Metadata should be consistent with other language and runtime features of ECMAScript.
|
||||
|
||||
## Syntax
|
||||
|
||||
* Declarative definition of metadata:
|
||||
```JavaScript
|
||||
class C {
|
||||
@Reflect.metadata(metadataKey, metadataValue)
|
||||
method() {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
* Imperative definition of metadata:
|
||||
```JavaScript
|
||||
Reflect.defineMetadata(metadataKey, metadataValue, C.prototype, "method");
|
||||
```
|
||||
|
||||
* Imperative introspection of metadata:
|
||||
```JavaScript
|
||||
let obj = new C();
|
||||
let metadataValue = Reflect.getMetadata(metadataKey, obj, "method");
|
||||
```
|
||||
|
||||
## Semantics
|
||||
|
||||
* Object has a new \[\[Metadata\]\] internal property that will contain a Map whose keys are property keys (or **undefined**) and whose values are Maps of metadata keys to metadata values.
|
||||
* Object will have a number of new internal methods for \[\[DefineOwnMetadata\]\], \[\[GetOwnMetadata\]\], \[\[HasOwnMetadata\]\], etc.
|
||||
* These internal methods can be overridden by a Proxy to support additional traps.
|
||||
* These internal methods will by default call a set of abstract operations to define and read metadata.
|
||||
* The Reflect object will expose the MOP operations to allow imperative access to metadata.
|
||||
* Metadata defined on class declaration *C* is stored in *C*.\[\[Metadata\]\], with **undefined** as the key.
|
||||
* Metadata defined on static members of class declaration *C* are stored in *C*.\[\[Metadata\]\], with the property key as the key.
|
||||
* Metadata defined on instance members of class declaration *C* are stored in *C*.prototype.\[\[Metadata\]\], with the property key as the key.
|
||||
|
||||
## API
|
||||
|
||||
```JavaScript
|
||||
// define metadata on an object or property
|
||||
Reflect.defineMetadata(metadataKey, metadataValue, target);
|
||||
Reflect.defineMetadata(metadataKey, metadataValue, target, propertyKey);
|
||||
|
||||
// check for presence of a metadata key on the prototype chain of an object or property
|
||||
let result = Reflect.hasMetadata(metadataKey, target);
|
||||
let result = Reflect.hasMetadata(metadataKey, target, propertyKey);
|
||||
|
||||
// check for presence of an own metadata key of an object or property
|
||||
let result = Reflect.hasOwnMetadata(metadataKey, target);
|
||||
let result = Reflect.hasOwnMetadata(metadataKey, target, propertyKey);
|
||||
|
||||
// get metadata value of a metadata key on the prototype chain of an object or property
|
||||
let result = Reflect.getMetadata(metadataKey, target);
|
||||
let result = Reflect.getMetadata(metadataKey, target, propertyKey);
|
||||
|
||||
// get metadata value of an own metadata key of an object or property
|
||||
let result = Reflect.getOwnMetadata(metadataKey, target);
|
||||
let result = Reflect.getOwnMetadata(metadataKey, target, propertyKey);
|
||||
|
||||
// get all metadata keys on the prototype chain of an object or property
|
||||
let result = Reflect.getMetadataKeys(target);
|
||||
let result = Reflect.getMetadataKeys(target, propertyKey);
|
||||
|
||||
// get all own metadata keys of an object or property
|
||||
let result = Reflect.getOwnMetadataKeys(target);
|
||||
let result = Reflect.getOwnMetadataKeys(target, propertyKey);
|
||||
|
||||
// delete metadata from an object or property
|
||||
let result = Reflect.deleteMetadata(metadataKey, target);
|
||||
let result = Reflect.deleteMetadata(metadataKey, target, propertyKey);
|
||||
|
||||
// apply metadata via a decorator to a constructor
|
||||
@Reflect.metadata(metadataKey, metadataValue)
|
||||
class C {
|
||||
// apply metadata via a decorator to a method (property)
|
||||
@Reflect.metadata(metadataKey, metadataValue)
|
||||
method() {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Alternatives
|
||||
|
||||
* Use properties rather than a separate API.
|
||||
* Obvious downside is that this can be a lot of code:
|
||||
```JavaScript
|
||||
function ParamTypes(...types) {
|
||||
return (target, propertyKey) => {
|
||||
const symParamTypes = Symbol.for("design:paramtypes");
|
||||
if (propertyKey === undefined) {
|
||||
target[symParamTypes] = types;
|
||||
}
|
||||
else {
|
||||
const symProperties = Symbol.for("design:properties");
|
||||
let properties, property;
|
||||
if (Object.prototype.hasOwnProperty.call(target, symProperties)) {
|
||||
properties = target[symProperties];
|
||||
}
|
||||
else {
|
||||
properties = target[symProperties] = {};
|
||||
}
|
||||
if (Object.prototype.hasOwnProperty.call(properties, propertyKey)) {
|
||||
property = properties[propertyKey];
|
||||
}
|
||||
else {
|
||||
property = properties[propertyKey] = {};
|
||||
}
|
||||
property[symParamTypes] = types;
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
* Though it may seem counterintuitive, the methods on Reflect place the parameters for the metadata key and metadata value before the target or property key. This is due to the fact that the property key is the only optional parameter in the argument list. This also makes the methods easier to curry with Function#bind. This also helps reduce the overall footprint and complexity of a metadata-producing decorator that could target both a class or a property:
|
||||
|
||||
```JavaScript
|
||||
function ParamTypes(...types) {
|
||||
// as propertyKey is effectively optional, its easier to use here
|
||||
return (target, propertyKey) => { Reflect.defineMetadata("design:paramtypes", types, target, propertyKey); }
|
||||
|
||||
// vs. having multiple overloads with the target and key in the front:
|
||||
//
|
||||
// return (target, propertyKey) => {
|
||||
// if (propertyKey === undefined) {
|
||||
// Reflect.defineMetadata(target, "design:paramtypes", types);
|
||||
// }
|
||||
// else {
|
||||
// Reflect.defineMetadata(target, propertyKey, "design:paramtypes", types);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// vs. having a different methods for the class or a property:
|
||||
//
|
||||
// return (target, propertyKey) => {
|
||||
// if (propertyKey === undefined) {
|
||||
// Reflect.defineMetadata(target, "design:paramtypes", types);
|
||||
// }
|
||||
// else {
|
||||
// Reflect.definePropertyMetadata(target, propertyKey, "design:paramtypes", types);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
```
|
||||
|
||||
## Issues
|
||||
|
||||
* A poorly written mutating decorator for a class constructor could cause metadata to become lost if the prototype chain is not maintained. Though, not maintaining the prototype chain in a mutating decorator for a class constructor would have other negative side effects as well. @rbuckton
|
||||
* This is mitigated if the mutating decorator returns a class expression that extends from the target, or returns a proxy for the decorator. @rbuckton
|
||||
* Metadata for a method is attached to the class (or prototype) via the property key. It would not then be available if trying to read metadata on the function of the method (e.g. "tearing-off" the method from the class). @rbuckton
|
||||
|
||||
[Metadata-Spec]: https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md
|
||||
[Decorators]: https://github.com/jonathandturner/decorators/blob/master/README.md
|
962
node_modules/reflect-metadata/Reflect.js
generated
vendored
Normal file
962
node_modules/reflect-metadata/Reflect.js
generated
vendored
Normal file
@ -0,0 +1,962 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (C) Microsoft. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
"use strict";
|
||||
var Reflect;
|
||||
(function (Reflect) {
|
||||
// Load global or shim versions of Map, Set, and WeakMap
|
||||
var functionPrototype = Object.getPrototypeOf(Function);
|
||||
var _Map = typeof Map === "function" ? Map : CreateMapPolyfill();
|
||||
var _Set = typeof Set === "function" ? Set : CreateSetPolyfill();
|
||||
var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
|
||||
// [[Metadata]] internal slot
|
||||
var __Metadata__ = new _WeakMap();
|
||||
/**
|
||||
* Applies a set of decorators to a property of a target object.
|
||||
* @param decorators An array of decorators.
|
||||
* @param target The target object.
|
||||
* @param targetKey (Optional) The property key to decorate.
|
||||
* @param targetDescriptor (Optional) The property descriptor for the target key
|
||||
* @remarks Decorators are applied in reverse order.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* C = Reflect.decorate(decoratorsArray, C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* Reflect.decorate(decoratorsArray, C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* Reflect.decorate(decoratorsArray, C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* Object.defineProperty(C, "staticMethod",
|
||||
* Reflect.decorate(decoratorsArray, C, "staticMethod",
|
||||
* Object.getOwnPropertyDescriptor(C, "staticMethod")));
|
||||
*
|
||||
* // method (on prototype)
|
||||
* Object.defineProperty(C.prototype, "method",
|
||||
* Reflect.decorate(decoratorsArray, C.prototype, "method",
|
||||
* Object.getOwnPropertyDescriptor(C.prototype, "method")));
|
||||
*
|
||||
*/
|
||||
function decorate(decorators, target, targetKey, targetDescriptor) {
|
||||
if (!IsUndefined(targetDescriptor)) {
|
||||
if (!IsArray(decorators)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (IsUndefined(targetKey)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsObject(targetDescriptor)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
return DecoratePropertyWithDescriptor(decorators, target, targetKey, targetDescriptor);
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
if (!IsArray(decorators)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
return DecoratePropertyWithoutDescriptor(decorators, target, targetKey);
|
||||
}
|
||||
else {
|
||||
if (!IsArray(decorators)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsConstructor(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
return DecorateConstructor(decorators, target);
|
||||
}
|
||||
}
|
||||
Reflect.decorate = decorate;
|
||||
/**
|
||||
* A default metadata decorator factory that can be used on a class, class member, or parameter.
|
||||
* @param metadataKey The key for the metadata entry.
|
||||
* @param metadataValue The value for the metadata entry.
|
||||
* @returns A decorator function.
|
||||
* @remarks
|
||||
* If `metadataKey` is already defined for the target and target key, the
|
||||
* metadataValue for that key will be overwritten.
|
||||
* @example
|
||||
*
|
||||
* // constructor
|
||||
* @Reflect.metadata(key, value)
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // property (on constructor, TypeScript only)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* static staticProperty;
|
||||
* }
|
||||
*
|
||||
* // property (on prototype, TypeScript only)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* property;
|
||||
* }
|
||||
*
|
||||
* // method (on constructor)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* static staticMethod() { }
|
||||
* }
|
||||
*
|
||||
* // method (on prototype)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* method() { }
|
||||
* }
|
||||
*
|
||||
*/
|
||||
function metadata(metadataKey, metadataValue) {
|
||||
function decorator(target, targetKey) {
|
||||
if (!IsUndefined(targetKey)) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);
|
||||
}
|
||||
else {
|
||||
if (!IsConstructor(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, undefined);
|
||||
}
|
||||
}
|
||||
return decorator;
|
||||
}
|
||||
Reflect.metadata = metadata;
|
||||
/**
|
||||
* Define a unique metadata entry on the target.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param metadataValue A value that contains attached metadata.
|
||||
* @param target The target object on which to define metadata.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* Reflect.defineMetadata("custom:annotation", options, C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* Reflect.defineMetadata("custom:annotation", options, C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* Reflect.defineMetadata("custom:annotation", options, C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* Reflect.defineMetadata("custom:annotation", options, C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* Reflect.defineMetadata("custom:annotation", options, C.prototype, "method");
|
||||
*
|
||||
* // decorator factory as metadata-producing annotation.
|
||||
* function MyAnnotation(options): Decorator {
|
||||
* return (target, key?) => Reflect.defineMetadata("custom:annotation", options, target, key);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
function defineMetadata(metadataKey, metadataValue, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);
|
||||
}
|
||||
Reflect.defineMetadata = defineMetadata;
|
||||
/**
|
||||
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.hasMetadata("custom:annotation", C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function hasMetadata(metadataKey, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryHasMetadata(metadataKey, target, targetKey);
|
||||
}
|
||||
Reflect.hasMetadata = hasMetadata;
|
||||
/**
|
||||
* Gets a value indicating whether the target object has the provided metadata key defined.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function hasOwnMetadata(metadataKey, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryHasOwnMetadata(metadataKey, target, targetKey);
|
||||
}
|
||||
Reflect.hasOwnMetadata = hasOwnMetadata;
|
||||
/**
|
||||
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getMetadata("custom:annotation", C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getMetadata(metadataKey, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryGetMetadata(metadataKey, target, targetKey);
|
||||
}
|
||||
Reflect.getMetadata = getMetadata;
|
||||
/**
|
||||
* Gets the metadata value for the provided metadata key on the target object.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getOwnMetadata(metadataKey, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryGetOwnMetadata(metadataKey, target, targetKey);
|
||||
}
|
||||
Reflect.getOwnMetadata = getOwnMetadata;
|
||||
/**
|
||||
* Gets the metadata keys defined on the target object or its prototype chain.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns An array of unique metadata keys.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getMetadataKeys(C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getMetadataKeys(C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getMetadataKeys(C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getMetadataKeys(C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getMetadataKeys(C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getMetadataKeys(target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryMetadataKeys(target, targetKey);
|
||||
}
|
||||
Reflect.getMetadataKeys = getMetadataKeys;
|
||||
/**
|
||||
* Gets the unique metadata keys defined on the target object.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns An array of unique metadata keys.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getOwnMetadataKeys(C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getOwnMetadataKeys(C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getOwnMetadataKeys(C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getOwnMetadataKeys(C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getOwnMetadataKeys(C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getOwnMetadataKeys(target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryOwnMetadataKeys(target, targetKey);
|
||||
}
|
||||
Reflect.getOwnMetadataKeys = getOwnMetadataKeys;
|
||||
/**
|
||||
* Deletes the metadata entry from the target object with the provided key.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns `true` if the metadata entry was found and deleted; otherwise, false.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function deleteMetadata(metadataKey, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#deletemetadata-metadatakey-p-
|
||||
var metadataMap = GetOrCreateMetadataMap(target, targetKey, false);
|
||||
if (IsUndefined(metadataMap)) {
|
||||
return false;
|
||||
}
|
||||
if (!metadataMap.delete(metadataKey)) {
|
||||
return false;
|
||||
}
|
||||
if (metadataMap.size > 0) {
|
||||
return true;
|
||||
}
|
||||
var targetMetadata = __Metadata__.get(target);
|
||||
targetMetadata.delete(targetKey);
|
||||
if (targetMetadata.size > 0) {
|
||||
return true;
|
||||
}
|
||||
__Metadata__.delete(target);
|
||||
return true;
|
||||
}
|
||||
Reflect.deleteMetadata = deleteMetadata;
|
||||
function DecorateConstructor(decorators, target) {
|
||||
for (var i = decorators.length - 1; i >= 0; --i) {
|
||||
var decorator = decorators[i];
|
||||
var decorated = decorator(target);
|
||||
if (!IsUndefined(decorated)) {
|
||||
if (!IsConstructor(decorated)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
target = decorated;
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
function DecoratePropertyWithDescriptor(decorators, target, propertyKey, descriptor) {
|
||||
for (var i = decorators.length - 1; i >= 0; --i) {
|
||||
var decorator = decorators[i];
|
||||
var decorated = decorator(target, propertyKey, descriptor);
|
||||
if (!IsUndefined(decorated)) {
|
||||
if (!IsObject(decorated)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
descriptor = decorated;
|
||||
}
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
function DecoratePropertyWithoutDescriptor(decorators, target, propertyKey) {
|
||||
for (var i = decorators.length - 1; i >= 0; --i) {
|
||||
var decorator = decorators[i];
|
||||
decorator(target, propertyKey);
|
||||
}
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#getorcreatemetadatamap--o-p-create-
|
||||
function GetOrCreateMetadataMap(target, targetKey, create) {
|
||||
var targetMetadata = __Metadata__.get(target);
|
||||
if (!targetMetadata) {
|
||||
if (!create) {
|
||||
return undefined;
|
||||
}
|
||||
targetMetadata = new _Map();
|
||||
__Metadata__.set(target, targetMetadata);
|
||||
}
|
||||
var keyMetadata = targetMetadata.get(targetKey);
|
||||
if (!keyMetadata) {
|
||||
if (!create) {
|
||||
return undefined;
|
||||
}
|
||||
keyMetadata = new _Map();
|
||||
targetMetadata.set(targetKey, keyMetadata);
|
||||
}
|
||||
return keyMetadata;
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasmetadata--metadatakey-o-p-
|
||||
function OrdinaryHasMetadata(MetadataKey, O, P) {
|
||||
var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
|
||||
if (hasOwn) {
|
||||
return true;
|
||||
}
|
||||
var parent = GetPrototypeOf(O);
|
||||
if (parent !== null) {
|
||||
return OrdinaryHasMetadata(MetadataKey, parent, P);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasownmetadata--metadatakey-o-p-
|
||||
function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
|
||||
var metadataMap = GetOrCreateMetadataMap(O, P, false);
|
||||
if (metadataMap === undefined) {
|
||||
return false;
|
||||
}
|
||||
return Boolean(metadataMap.has(MetadataKey));
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetmetadata--metadatakey-o-p-
|
||||
function OrdinaryGetMetadata(MetadataKey, O, P) {
|
||||
var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
|
||||
if (hasOwn) {
|
||||
return OrdinaryGetOwnMetadata(MetadataKey, O, P);
|
||||
}
|
||||
var parent = GetPrototypeOf(O);
|
||||
if (parent !== null) {
|
||||
return OrdinaryGetMetadata(MetadataKey, parent, P);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetownmetadata--metadatakey-o-p-
|
||||
function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
|
||||
var metadataMap = GetOrCreateMetadataMap(O, P, false);
|
||||
if (metadataMap === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return metadataMap.get(MetadataKey);
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarydefineownmetadata--metadatakey-metadatavalue-o-p-
|
||||
function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
|
||||
var metadataMap = GetOrCreateMetadataMap(O, P, true);
|
||||
metadataMap.set(MetadataKey, MetadataValue);
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarymetadatakeys--o-p-
|
||||
function OrdinaryMetadataKeys(O, P) {
|
||||
var ownKeys = OrdinaryOwnMetadataKeys(O, P);
|
||||
var parent = GetPrototypeOf(O);
|
||||
if (parent === null) {
|
||||
return ownKeys;
|
||||
}
|
||||
var parentKeys = OrdinaryMetadataKeys(parent, P);
|
||||
if (parentKeys.length <= 0) {
|
||||
return ownKeys;
|
||||
}
|
||||
if (ownKeys.length <= 0) {
|
||||
return parentKeys;
|
||||
}
|
||||
var set = new _Set();
|
||||
var keys = [];
|
||||
for (var _i = 0; _i < ownKeys.length; _i++) {
|
||||
var key = ownKeys[_i];
|
||||
var hasKey = set.has(key);
|
||||
if (!hasKey) {
|
||||
set.add(key);
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
for (var _a = 0; _a < parentKeys.length; _a++) {
|
||||
var key = parentKeys[_a];
|
||||
var hasKey = set.has(key);
|
||||
if (!hasKey) {
|
||||
set.add(key);
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryownmetadatakeys--o-p-
|
||||
function OrdinaryOwnMetadataKeys(target, targetKey) {
|
||||
var metadataMap = GetOrCreateMetadataMap(target, targetKey, false);
|
||||
var keys = [];
|
||||
if (metadataMap) {
|
||||
metadataMap.forEach(function (_, key) { return keys.push(key); });
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-undefined-type
|
||||
function IsUndefined(x) {
|
||||
return x === undefined;
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray
|
||||
function IsArray(x) {
|
||||
return Array.isArray(x);
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-type
|
||||
function IsObject(x) {
|
||||
return typeof x === "object" ? x !== null : typeof x === "function";
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
|
||||
function IsConstructor(x) {
|
||||
return typeof x === "function";
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-symbol-type
|
||||
function IsSymbol(x) {
|
||||
return typeof x === "symbol";
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey
|
||||
function ToPropertyKey(value) {
|
||||
if (IsSymbol(value)) {
|
||||
return value;
|
||||
}
|
||||
return String(value);
|
||||
}
|
||||
function GetPrototypeOf(O) {
|
||||
var proto = Object.getPrototypeOf(O);
|
||||
if (typeof O !== "function" || O === functionPrototype) {
|
||||
return proto;
|
||||
}
|
||||
// TypeScript doesn't set __proto__ in ES5, as it's non-standard.
|
||||
// Try to determine the superclass constructor. Compatible implementations
|
||||
// must either set __proto__ on a subclass constructor to the superclass constructor,
|
||||
// or ensure each class has a valid `constructor` property on its prototype that
|
||||
// points back to the constructor.
|
||||
// If this is not the same as Function.[[Prototype]], then this is definately inherited.
|
||||
// This is the case when in ES6 or when using __proto__ in a compatible browser.
|
||||
if (proto !== functionPrototype) {
|
||||
return proto;
|
||||
}
|
||||
// If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.
|
||||
var prototype = O.prototype;
|
||||
var prototypeProto = Object.getPrototypeOf(prototype);
|
||||
if (prototypeProto == null || prototypeProto === Object.prototype) {
|
||||
return proto;
|
||||
}
|
||||
// if the constructor was not a function, then we cannot determine the heritage.
|
||||
var constructor = prototypeProto.constructor;
|
||||
if (typeof constructor !== "function") {
|
||||
return proto;
|
||||
}
|
||||
// if we have some kind of self-reference, then we cannot determine the heritage.
|
||||
if (constructor === O) {
|
||||
return proto;
|
||||
}
|
||||
// we have a pretty good guess at the heritage.
|
||||
return constructor;
|
||||
}
|
||||
// naive Map shim
|
||||
function CreateMapPolyfill() {
|
||||
var cacheSentinel = {};
|
||||
function Map() {
|
||||
this._keys = [];
|
||||
this._values = [];
|
||||
this._cache = cacheSentinel;
|
||||
}
|
||||
Map.prototype = {
|
||||
get size() {
|
||||
return this._keys.length;
|
||||
},
|
||||
has: function (key) {
|
||||
if (key === this._cache) {
|
||||
return true;
|
||||
}
|
||||
if (this._find(key) >= 0) {
|
||||
this._cache = key;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
get: function (key) {
|
||||
var index = this._find(key);
|
||||
if (index >= 0) {
|
||||
this._cache = key;
|
||||
return this._values[index];
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
set: function (key, value) {
|
||||
this.delete(key);
|
||||
this._keys.push(key);
|
||||
this._values.push(value);
|
||||
this._cache = key;
|
||||
return this;
|
||||
},
|
||||
delete: function (key) {
|
||||
var index = this._find(key);
|
||||
if (index >= 0) {
|
||||
this._keys.splice(index, 1);
|
||||
this._values.splice(index, 1);
|
||||
this._cache = cacheSentinel;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
clear: function () {
|
||||
this._keys.length = 0;
|
||||
this._values.length = 0;
|
||||
this._cache = cacheSentinel;
|
||||
},
|
||||
forEach: function (callback, thisArg) {
|
||||
var size = this.size;
|
||||
for (var i = 0; i < size; ++i) {
|
||||
var key = this._keys[i];
|
||||
var value = this._values[i];
|
||||
this._cache = key;
|
||||
callback.call(this, value, key, this);
|
||||
}
|
||||
},
|
||||
_find: function (key) {
|
||||
var keys = this._keys;
|
||||
var size = keys.length;
|
||||
for (var i = 0; i < size; ++i) {
|
||||
if (keys[i] === key) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
return Map;
|
||||
}
|
||||
// naive Set shim
|
||||
function CreateSetPolyfill() {
|
||||
var cacheSentinel = {};
|
||||
function Set() {
|
||||
this._map = new _Map();
|
||||
}
|
||||
Set.prototype = {
|
||||
get size() {
|
||||
return this._map.length;
|
||||
},
|
||||
has: function (value) {
|
||||
return this._map.has(value);
|
||||
},
|
||||
add: function (value) {
|
||||
this._map.set(value, value);
|
||||
return this;
|
||||
},
|
||||
delete: function (value) {
|
||||
return this._map.delete(value);
|
||||
},
|
||||
clear: function () {
|
||||
this._map.clear();
|
||||
},
|
||||
forEach: function (callback, thisArg) {
|
||||
this._map.forEach(callback, thisArg);
|
||||
}
|
||||
};
|
||||
return Set;
|
||||
}
|
||||
// naive WeakMap shim
|
||||
function CreateWeakMapPolyfill() {
|
||||
var UUID_SIZE = 16;
|
||||
var isNode = typeof global !== "undefined" && Object.prototype.toString.call(global.process) === '[object process]';
|
||||
var nodeCrypto = isNode && require("crypto");
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
||||
var keys = {};
|
||||
var rootKey = CreateUniqueKey();
|
||||
function WeakMap() {
|
||||
this._key = CreateUniqueKey();
|
||||
}
|
||||
WeakMap.prototype = {
|
||||
has: function (target) {
|
||||
var table = GetOrCreateWeakMapTable(target, false);
|
||||
if (table) {
|
||||
return this._key in table;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
get: function (target) {
|
||||
var table = GetOrCreateWeakMapTable(target, false);
|
||||
if (table) {
|
||||
return table[this._key];
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
set: function (target, value) {
|
||||
var table = GetOrCreateWeakMapTable(target, true);
|
||||
table[this._key] = value;
|
||||
return this;
|
||||
},
|
||||
delete: function (target) {
|
||||
var table = GetOrCreateWeakMapTable(target, false);
|
||||
if (table && this._key in table) {
|
||||
return delete table[this._key];
|
||||
}
|
||||
return false;
|
||||
},
|
||||
clear: function () {
|
||||
// NOTE: not a real clear, just makes the previous data unreachable
|
||||
this._key = CreateUniqueKey();
|
||||
}
|
||||
};
|
||||
function FillRandomBytes(buffer, size) {
|
||||
for (var i = 0; i < size; ++i) {
|
||||
buffer[i] = Math.random() * 255 | 0;
|
||||
}
|
||||
}
|
||||
function GenRandomBytes(size) {
|
||||
if (nodeCrypto) {
|
||||
var data = nodeCrypto.randomBytes(size);
|
||||
return data;
|
||||
}
|
||||
else if (typeof Uint8Array === "function") {
|
||||
var data = new Uint8Array(size);
|
||||
if (typeof crypto !== "undefined") {
|
||||
crypto.getRandomValues(data);
|
||||
}
|
||||
else if (typeof msCrypto !== "undefined") {
|
||||
msCrypto.getRandomValues(data);
|
||||
}
|
||||
else {
|
||||
FillRandomBytes(data, size);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
else {
|
||||
var data = new Array(size);
|
||||
FillRandomBytes(data, size);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
function CreateUUID() {
|
||||
var data = GenRandomBytes(UUID_SIZE);
|
||||
// mark as random - RFC 4122 § 4.4
|
||||
data[6] = data[6] & 0x4f | 0x40;
|
||||
data[8] = data[8] & 0xbf | 0x80;
|
||||
var result = "";
|
||||
for (var offset = 0; offset < UUID_SIZE; ++offset) {
|
||||
var byte = data[offset];
|
||||
if (offset === 4 || offset === 6 || offset === 8) {
|
||||
result += "-";
|
||||
}
|
||||
if (byte < 16) {
|
||||
result += "0";
|
||||
}
|
||||
result += byte.toString(16).toLowerCase();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function CreateUniqueKey() {
|
||||
var key;
|
||||
do {
|
||||
key = "@@WeakMap@@" + CreateUUID();
|
||||
} while (hasOwn.call(keys, key));
|
||||
keys[key] = true;
|
||||
return key;
|
||||
}
|
||||
function GetOrCreateWeakMapTable(target, create) {
|
||||
if (!hasOwn.call(target, rootKey)) {
|
||||
if (!create) {
|
||||
return undefined;
|
||||
}
|
||||
Object.defineProperty(target, rootKey, { value: Object.create(null) });
|
||||
}
|
||||
return target[rootKey];
|
||||
}
|
||||
return WeakMap;
|
||||
}
|
||||
// hook global Reflect
|
||||
(function (__global) {
|
||||
if (typeof __global.Reflect !== "undefined") {
|
||||
if (__global.Reflect !== Reflect) {
|
||||
for (var p in Reflect) {
|
||||
__global.Reflect[p] = Reflect[p];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
__global.Reflect = Reflect;
|
||||
}
|
||||
})(typeof window !== "undefined" ? window :
|
||||
typeof WorkerGlobalScope !== "undefined" ? self :
|
||||
typeof global !== "undefined" ? global :
|
||||
Function("return this;")());
|
||||
})(Reflect || (Reflect = {}));
|
||||
//# sourceMappingURL=Reflect.js.map
|
1
node_modules/reflect-metadata/Reflect.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/Reflect.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1489
node_modules/reflect-metadata/Reflect.ts
generated
vendored
Normal file
1489
node_modules/reflect-metadata/Reflect.ts
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
35
node_modules/reflect-metadata/bower.json
generated
vendored
Normal file
35
node_modules/reflect-metadata/bower.json
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "reflect-metadata",
|
||||
"version": "0.1.2",
|
||||
"description": "Polyfill for Metadata Reflection API",
|
||||
"homepage": "https://github.com/rbuckton/ReflectDecorators",
|
||||
"authors": [
|
||||
"Ron Buckton <ron.buckton@microsoft.com>"
|
||||
],
|
||||
"main": "Reflect.js",
|
||||
"moduleType": [
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"decorator",
|
||||
"metadata",
|
||||
"javascript",
|
||||
"reflect"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"devDependencies": {
|
||||
"typescript": ">=1.5.0-alpha"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rbuckton/ReflectDecorators.git"
|
||||
}
|
||||
}
|
91
node_modules/reflect-metadata/package.json
generated
vendored
Normal file
91
node_modules/reflect-metadata/package.json
generated
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"reflect-metadata@0.1.2",
|
||||
"C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton"
|
||||
]
|
||||
],
|
||||
"_from": "reflect-metadata@0.1.2",
|
||||
"_id": "reflect-metadata@0.1.2",
|
||||
"_inCache": true,
|
||||
"_location": "/reflect-metadata",
|
||||
"_nodeVersion": "4.0.0",
|
||||
"_npmUser": {
|
||||
"email": "rbuckton@chronicles.org",
|
||||
"name": "rbuckton"
|
||||
},
|
||||
"_npmVersion": "2.14.2",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "reflect-metadata",
|
||||
"raw": "reflect-metadata@0.1.2",
|
||||
"rawSpec": "0.1.2",
|
||||
"scope": null,
|
||||
"spec": "0.1.2",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.2.tgz",
|
||||
"_shasum": "ea23e5823dc830f292822bd3da9b89fd57bffb03",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "reflect-metadata@0.1.2",
|
||||
"_where": "C:\\Users\\x2mjbyrn\\Source\\Repos\\Skeleton",
|
||||
"author": {
|
||||
"email": "ron.buckton@microsoft.com",
|
||||
"name": "Ron Buckton",
|
||||
"url": "http://github.com/rbuckton"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/rbuckton/ReflectDecorators/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Polyfill for Metadata Reflection API",
|
||||
"devDependencies": {
|
||||
"typescript": ">=1.5.0-alpha"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "ea23e5823dc830f292822bd3da9b89fd57bffb03",
|
||||
"tarball": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.2.tgz"
|
||||
},
|
||||
"gitHead": "07dcd99c807a402b255065979d9485fbdc69924b",
|
||||
"homepage": "http://rbuckton.github.io/ReflectDecorators",
|
||||
"installable": true,
|
||||
"keywords": [
|
||||
"decorator",
|
||||
"javascript",
|
||||
"metadata",
|
||||
"reflect"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"licenses": [
|
||||
{
|
||||
"license": "Apache-2.0",
|
||||
"url": "http://github.com/rbuckton/ReflectDecorators/raw/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"main": "Reflect.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "rbuckton",
|
||||
"email": "rbuckton@chronicles.org"
|
||||
}
|
||||
],
|
||||
"name": "reflect-metadata",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rbuckton/ReflectDecorators.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc.cmd",
|
||||
"build-test": "tsc.cmd --project ./test/",
|
||||
"test": "npm run-script build-test & node ./temp/test/run.js"
|
||||
},
|
||||
"typescript": {
|
||||
"definition": "reflect-metadata.d.ts"
|
||||
},
|
||||
"version": "0.1.2"
|
||||
}
|
486
node_modules/reflect-metadata/reflect-metadata.d.ts
generated
vendored
Normal file
486
node_modules/reflect-metadata/reflect-metadata.d.ts
generated
vendored
Normal file
@ -0,0 +1,486 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (C) Microsoft. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
declare module "reflect-metadata" {
|
||||
// The "reflect-metadata" module has no imports or exports, but can be used by modules to load the polyfill.
|
||||
}
|
||||
|
||||
declare module Reflect {
|
||||
/**
|
||||
* Applies a set of decorators to a target object.
|
||||
* @param decorators An array of decorators.
|
||||
* @param target The target object.
|
||||
* @returns The result of applying the provided decorators.
|
||||
* @remarks Decorators are applied in reverse order of their positions in the array.
|
||||
* @example
|
||||
*
|
||||
* class C { }
|
||||
*
|
||||
* // constructor
|
||||
* C = Reflect.decorate(decoratorsArray, C);
|
||||
*
|
||||
*/
|
||||
function decorate(decorators: ClassDecorator[], target: Function): Function;
|
||||
/**
|
||||
* Applies a set of decorators to a property of a target object.
|
||||
* @param decorators An array of decorators.
|
||||
* @param target The target object.
|
||||
* @param targetKey The property key to decorate.
|
||||
* @param descriptor A property descriptor
|
||||
* @remarks Decorators are applied in reverse order.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* static staticMethod() { }
|
||||
* method() { }
|
||||
* }
|
||||
*
|
||||
* // property (on constructor)
|
||||
* Reflect.decorate(decoratorsArray, C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* Reflect.decorate(decoratorsArray, C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* Object.defineProperty(C, "staticMethod",
|
||||
* Reflect.decorate(decoratorsArray, C, "staticMethod",
|
||||
* Object.getOwnPropertyDescriptor(C, "staticMethod")));
|
||||
*
|
||||
* // method (on prototype)
|
||||
* Object.defineProperty(C.prototype, "method",
|
||||
* Reflect.decorate(decoratorsArray, C.prototype, "method",
|
||||
* Object.getOwnPropertyDescriptor(C.prototype, "method")));
|
||||
*
|
||||
*/
|
||||
function decorate(decorators: (PropertyDecorator | MethodDecorator)[], target: Object, targetKey: string | symbol, descriptor?: PropertyDescriptor): PropertyDescriptor;
|
||||
/**
|
||||
* A default metadata decorator factory that can be used on a class, class member, or parameter.
|
||||
* @param metadataKey The key for the metadata entry.
|
||||
* @param metadataValue The value for the metadata entry.
|
||||
* @returns A decorator function.
|
||||
* @remarks
|
||||
* If `metadataKey` is already defined for the target and target key, the
|
||||
* metadataValue for that key will be overwritten.
|
||||
* @example
|
||||
*
|
||||
* // constructor
|
||||
* @Reflect.metadata(key, value)
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // property (on constructor, TypeScript only)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* static staticProperty;
|
||||
* }
|
||||
*
|
||||
* // property (on prototype, TypeScript only)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* property;
|
||||
* }
|
||||
*
|
||||
* // method (on constructor)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* static staticMethod() { }
|
||||
* }
|
||||
*
|
||||
* // method (on prototype)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* method() { }
|
||||
* }
|
||||
*
|
||||
*/
|
||||
function metadata(metadataKey: any, metadataValue: any): ClassDecorator | MethodDecorator | PropertyDecorator;
|
||||
/**
|
||||
* Define a unique metadata entry on the target.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param metadataValue A value that contains attached metadata.
|
||||
* @param target The target object on which to define metadata.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* Reflect.defineMetadata("custom:annotation", options, C);
|
||||
*
|
||||
* // decorator factory as metadata-producing annotation.
|
||||
* function MyAnnotation(options): ClassDecorator {
|
||||
* return target => Reflect.defineMetadata("custom:annotation", options, target);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
function defineMetadata(metadataKey: any, metadataValue: any, target: Object): void;
|
||||
/**
|
||||
* Define a unique metadata entry on the target.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param metadataValue A value that contains attached metadata.
|
||||
* @param target The target object on which to define metadata.
|
||||
* @param targetKey The property key for the target.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // property (on constructor)
|
||||
* Reflect.defineMetadata("custom:annotation", Number, C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* Reflect.defineMetadata("custom:annotation", Number, C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* Reflect.defineMetadata("custom:annotation", Number, C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* Reflect.defineMetadata("custom:annotation", Number, C.prototype, "method");
|
||||
*
|
||||
* // decorator factory as metadata-producing annotation.
|
||||
* function MyAnnotation(options): PropertyDecorator {
|
||||
* return (target, key) => Reflect.defineMetadata("custom:annotation", options, target, key);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
function defineMetadata(metadataKey: any, metadataValue: any, target: Object, targetKey: string | symbol): void;
|
||||
/**
|
||||
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.hasMetadata("custom:annotation", C);
|
||||
*
|
||||
*/
|
||||
function hasMetadata(metadataKey: any, target: Object): boolean;
|
||||
/**
|
||||
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey The property key for the target.
|
||||
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function hasMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean;
|
||||
/**
|
||||
* Gets a value indicating whether the target object has the provided metadata key defined.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C);
|
||||
*
|
||||
*/
|
||||
function hasOwnMetadata(metadataKey: any, target: Object): boolean;
|
||||
/**
|
||||
* Gets a value indicating whether the target object has the provided metadata key defined.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey The property key for the target.
|
||||
* @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function hasOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean;
|
||||
/**
|
||||
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getMetadata("custom:annotation", C);
|
||||
*
|
||||
*/
|
||||
function getMetadata(metadataKey: any, target: Object): any;
|
||||
/**
|
||||
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey The property key for the target.
|
||||
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any;
|
||||
/**
|
||||
* Gets the metadata value for the provided metadata key on the target object.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C);
|
||||
*
|
||||
*/
|
||||
function getOwnMetadata(metadataKey: any, target: Object): any;
|
||||
/**
|
||||
* Gets the metadata value for the provided metadata key on the target object.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey The property key for the target.
|
||||
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getOwnMetadata(metadataKey: any, target: Object, targetKey: string | symbol): any;
|
||||
/**
|
||||
* Gets the metadata keys defined on the target object or its prototype chain.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @returns An array of unique metadata keys.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getMetadataKeys(C);
|
||||
*
|
||||
*/
|
||||
function getMetadataKeys(target: Object): any[];
|
||||
/**
|
||||
* Gets the metadata keys defined on the target object or its prototype chain.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey The property key for the target.
|
||||
* @returns An array of unique metadata keys.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getMetadataKeys(C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getMetadataKeys(C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getMetadataKeys(C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getMetadataKeys(C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getMetadataKeys(target: Object, targetKey: string | symbol): any[];
|
||||
/**
|
||||
* Gets the unique metadata keys defined on the target object.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @returns An array of unique metadata keys.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getOwnMetadataKeys(C);
|
||||
*
|
||||
*/
|
||||
function getOwnMetadataKeys(target: Object): any[];
|
||||
/**
|
||||
* Gets the unique metadata keys defined on the target object.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey The property key for the target.
|
||||
* @returns An array of unique metadata keys.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getOwnMetadataKeys(C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getOwnMetadataKeys(C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getOwnMetadataKeys(C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getOwnMetadataKeys(C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getOwnMetadataKeys(target: Object, targetKey: string | symbol): any[];
|
||||
/**
|
||||
* Deletes the metadata entry from the target object with the provided key.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @returns `true` if the metadata entry was found and deleted; otherwise, false.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C);
|
||||
*
|
||||
*/
|
||||
function deleteMetadata(metadataKey: any, target: Object): boolean;
|
||||
/**
|
||||
* Deletes the metadata entry from the target object with the provided key.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey The property key for the target.
|
||||
* @returns `true` if the metadata entry was found and deleted; otherwise, false.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function deleteMetadata(metadataKey: any, target: Object, targetKey: string | symbol): boolean;
|
||||
}
|
6
node_modules/reflect-metadata/spec/biblio.json
generated
vendored
Normal file
6
node_modules/reflect-metadata/spec/biblio.json
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"http://people.mozilla.org/~jorendorff/es6-draft.html": {
|
||||
"abstract operations": {
|
||||
}
|
||||
}
|
||||
}
|
234
node_modules/reflect-metadata/spec/css/elements.css
generated
vendored
Normal file
234
node_modules/reflect-metadata/spec/css/elements.css
generated
vendored
Normal file
@ -0,0 +1,234 @@
|
||||
body {
|
||||
font-size: 18px;
|
||||
line-height: 1.5;
|
||||
font-family: Cambria, Palatino Linotype, Palatino, Liberation Serif, serif;
|
||||
margin: 0 20%;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
a:link {
|
||||
text-decoration: none;
|
||||
color: #3333bb;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
color: blue;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
code {
|
||||
font-weight: bold;
|
||||
font-family: Consolas, Monaco, monospace;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
pre code {
|
||||
font-weight: inherit;
|
||||
}
|
||||
|
||||
pre code.hljs {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
ol.toc {
|
||||
list-style: none;
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
ol.toc ol.toc {
|
||||
padding-left: 2ex;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
emu-val {
|
||||
font-weight: bold;
|
||||
}
|
||||
emu-alg ol, emu-alg ol ol ol ol {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
|
||||
emu-alg ol ol, emu-alg ol ol ol ol ol {
|
||||
list-style-type: lower-alpha;
|
||||
}
|
||||
|
||||
emu-alg ol ol ol, ol ol ol ol ol ol {
|
||||
list-style-type: lower-roman;
|
||||
}
|
||||
|
||||
emu-note {
|
||||
display: block;
|
||||
margin-left: 5em;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
emu-note span.note {
|
||||
text-transform: uppercase;
|
||||
margin-left: -5em;
|
||||
display: block;
|
||||
float: left;
|
||||
}
|
||||
|
||||
emu-production {
|
||||
display: block;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
margin-left: 5ex;
|
||||
}
|
||||
|
||||
emu-production.inline {
|
||||
display: inline;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
emu-production.inline emu-rhs {
|
||||
display: inline;
|
||||
padding-left: 1ex;
|
||||
}
|
||||
emu-constraints {
|
||||
font-size: .75em;
|
||||
margin-right: 1ex;
|
||||
}
|
||||
|
||||
emu-gann {
|
||||
margin-right: 1ex;
|
||||
}
|
||||
|
||||
emu-gann emu-t:last-child,
|
||||
emu-gann emu-nt:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
emu-geq {
|
||||
margin-left: 1ex;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
emu-oneof {
|
||||
font-weight: bold;
|
||||
margin-left: 1ex;
|
||||
}
|
||||
|
||||
emu-nt {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
emu-rhs emu-nt {
|
||||
margin-right: 1ex;
|
||||
}
|
||||
|
||||
emu-t {
|
||||
font-family: monospace;
|
||||
font-weight: bold;
|
||||
margin-right: 1ex;
|
||||
}
|
||||
|
||||
emu-rhs {
|
||||
display: block;
|
||||
padding-left: 50px;
|
||||
}
|
||||
|
||||
emu-mods {
|
||||
font-size: .75em;
|
||||
vertical-align: sub;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
emu-gprose {
|
||||
font-size: 0.9em;
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
position: relative;
|
||||
}
|
||||
h1 .secnum {
|
||||
position: absolute;
|
||||
text-align: right;
|
||||
right: 100%;
|
||||
margin-right: 1ex;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
h1 { font-size: 2.67em; }
|
||||
h2 { font-size: 2em; }
|
||||
h3 { font-size: 1.56em; }
|
||||
h4 { font-size: 1.25em; }
|
||||
h5 { font-size: 1.11em; }
|
||||
h6 { font-size: 1em; }
|
||||
|
||||
emu-intro h1, emu-clause h1, emu-annex h1 { font-size: 2em; }
|
||||
emu-intro h2, emu-clause h2, emu-annex h2 { font-size: 1.56em; }
|
||||
emu-intro h3, emu-clause h3, emu-annex h3 { font-size: 1.25em; }
|
||||
emu-intro h4, emu-clause h4, emu-annex h4 { font-size: 1.11em; }
|
||||
emu-intro h5, emu-clause h5, emu-annex h5 { font-size: 1em; }
|
||||
emu-intro h6, emu-clause h6, emu-annex h6 { font-size: 0.9em; }
|
||||
emu-intro emu-intro h1, emu-clause emu-clause h1, emu-annex emu-annex h1 { font-size: 1.56em; }
|
||||
emu-intro emu-intro h2, emu-clause emu-clause h2, emu-annex emu-annex h2 { font-size: 1.25em; }
|
||||
emu-intro emu-intro h3, emu-clause emu-clause h3, emu-annex emu-annex h3 { font-size: 1.11em; }
|
||||
emu-intro emu-intro h4, emu-clause emu-clause h4, emu-annex emu-annex h4 { font-size: 1em; }
|
||||
emu-intro emu-intro h5, emu-clause emu-clause h5, emu-annex emu-annex h5 { font-size: 0.9em; }
|
||||
emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex h1 { font-size: 1.25em; }
|
||||
emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex h2 { font-size: 1.11em; }
|
||||
emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex h3 { font-size: 1em; }
|
||||
emu-intro emu-intro emu-intro h4, emu-clause emu-clause emu-clause h4, emu-annex emu-annex emu-annex h4 { font-size: 0.9em; }
|
||||
emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex h1 { font-size: 1.11em; }
|
||||
emu-intro emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex emu-annex h2 { font-size: 1em; }
|
||||
emu-intro emu-intro emu-intro emu-intro h3, emu-clause emu-clause emu-clause emu-clause h3, emu-annex emu-annex emu-annex emu-annex h3 { font-size: 0.9em; }
|
||||
emu-intro emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex emu-annex h1 { font-size: 1em; }
|
||||
emu-intro emu-intro emu-intro emu-intro emu-intro h2, emu-clause emu-clause emu-clause emu-clause emu-clause h2, emu-annex emu-annex emu-annex emu-annex emu-annex h2 { font-size: 0.9em; }
|
||||
emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro h1, emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause h1, emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex h1 { font-size: 0.9em }
|
||||
|
||||
emu-clause {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Figures and tables */
|
||||
figure { display: block; margin: 1em 0 3em 0; }
|
||||
figure object { display: block; margin: 0 auto; }
|
||||
figure table.real-table { margin: 0 auto; }
|
||||
figure figcaption {
|
||||
display: block;
|
||||
color: #555555;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table.real-table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.real-table td, table.real-table th {
|
||||
border: 1px solid black;
|
||||
padding: 0.4em;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
table.real-table th {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
/* Note: the left content edges of table.lightweight-table >tbody >tr >td
|
||||
and div.display line up. */
|
||||
table.lightweight-table {
|
||||
border-collapse: collapse;
|
||||
margin: 0 0 0 1.5em;
|
||||
}
|
||||
table.lightweight-table td, table.lightweight-table th {
|
||||
border: none;
|
||||
padding: 0 0.5em;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
/* diff styles */
|
||||
ins {
|
||||
background-color: #e0f8e0;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid #396;
|
||||
}
|
||||
|
||||
del {
|
||||
background-color: #fee;
|
||||
}
|
||||
|
662
node_modules/reflect-metadata/spec/index-out.html
generated
vendored
Normal file
662
node_modules/reflect-metadata/spec/index-out.html
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
605
node_modules/reflect-metadata/spec/index.html
generated
vendored
Normal file
605
node_modules/reflect-metadata/spec/index.html
generated
vendored
Normal file
@ -0,0 +1,605 @@
|
||||
<meta charset="utf8">
|
||||
<title>Decorators</title>
|
||||
<link rel="stylesheet" href="./css/elements.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
|
||||
<emu-biblio href="./biblio.json"></emu-biblio>
|
||||
|
||||
<h1>Decorators Proposal - ECMAScript</h1>
|
||||
<emu-intro id="introduction">
|
||||
<h1>Introduction</h1>
|
||||
<p>Proposal to add Decorators to ECMAScript.</p>
|
||||
<p>For the TypeScript specific proposal, see <a href="typescript.html">http://rbuckton.github.io/reflectdecorators/typescript.html</a></p>
|
||||
</emu-intro>
|
||||
|
||||
<emu-clause id="proposal-terms">
|
||||
<h1>Terms</h1>
|
||||
<emu-clause id="proposal-terms-decorator">
|
||||
<h1>Decorator</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> is an expression that is evaluated after a class has been defined, that can be used to annotate or modify the class in some fashion. This expression must evaluate to a <code>function</code>, which is executed by the runtime to apply the decoration.</p>
|
||||
<pre><code class="javascript">@decoratorExpression
|
||||
class C {
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-classdecoratorfunction">
|
||||
<h1>Class Decorator Function</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>class decorator function</em> is a function that accepts a constructor function as its argument, and returns either <code>undefined</code>, the provided constructor function, or a new constructor function. Returning <code>undefined</code> is equivalent to returning the provided constructor function.</p>
|
||||
<pre><code class="javascript">// A class decorator function
|
||||
function dec(target) {
|
||||
// modify, annotate, or replace target...
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-propertydecoratorfunction">
|
||||
<h1>Property/Method Decorator Function</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>property decorator function</em> is a function that accepts three arguments: The object that owns the property, the key for the property (a <code>string</code> or a <code>symbol</code>), and optionally the property descriptor of the property. The function must return either <code>undefined</code>, the provided property descriptor, or a new property descriptor. Returning <code>undefined</code> is equivalent to returning the provided property descriptor.</p>
|
||||
<pre><code class="javascript">// A property (or method/accessor) decorator function
|
||||
function dec(target, key, descriptor) {
|
||||
// annotate the target and key; or modify or replace the descriptor...
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-decoratorfactory">
|
||||
<h1>Decorator Factory</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator factory</em> is a function that can accept any number of arguments, and must return one of the above types of decorator function.</p>
|
||||
<pre><code class="javascript">// a class decorator factory function
|
||||
function dec(x, y) {
|
||||
// the class decorator function
|
||||
return function (target) {
|
||||
// modify, annotate, or replace target...
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratortargets">
|
||||
<h1>Decorator Targets</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> <strong>can</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class declaration</li>
|
||||
<li>A class property initializer (static or prototype)</li>
|
||||
<li>A class method declaration (static or prototype)</li>
|
||||
<li>A class get or set accessor declaration (static or prototype)</li>
|
||||
</ul>
|
||||
<p>Please note that a <em>decorator</em> currently <strong>cannot</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class constructor - This is to reduce ambiguity between where you can apply a decorator (on the class or on its constructor) and which of the above decorator function forms is called.</li>
|
||||
<li>A function declaration - Decorators on a function declaration would introduce a TDZ (Temporal Dead Zone), which would make the function unreachable until its declaration is executed. This could cause confusion as an undecorated function declaration is hoisted and can be used in a statement preceeding the declaration.</li>
|
||||
<li>A function expression - This is to reduce confusion and maintain parity with disallowing decorators on a function declaration.</li>
|
||||
<li>An arrow function - This is to reduce confusion and maintain parity with disallowing decorators on a function expression.</li>
|
||||
</ul>
|
||||
<p>This list may change in the future.</p>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratoreval">
|
||||
<h1>Decorator Evaluation and Application Order</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>Decorators are <em>evaluated</em> in the order they appear preceeding their target declaration, to preserve side-effects due to evaluation order. Decorators are <em>applied</em> to their target declaration in reverse order, starting with the decorator closest to the declaration. This behavior is specified to preserve the expected behavior of decorators without a declarative syntax.</p>
|
||||
<pre><code class="javascript">@F
|
||||
@G
|
||||
class C {
|
||||
}
|
||||
</code></pre>
|
||||
<p>For example, the above listing could be approximately written without decorators in the following fashion:</p>
|
||||
<pre><code class="javascript">C = F(G(C))</code></pre>
|
||||
<p>In the above example, the expression <code>F</code> is evaluated first, followed by the expression <code>G</code>. <code>G</code> is then called with the constructor function as its argument, followed by calling <code>F</code> with the result. The actual process of applying decorators is more complex than the above example however, though you may still imperatively apply decorators with a reflection API.</p>
|
||||
<p>If a class declaration has decorators on both the class and any of its members or parameters, the decorators are applied using the following pseudocode:</p>
|
||||
<pre>
|
||||
for each member M of class C
|
||||
if M is an accessor then
|
||||
let accessor = first accessor (get or set, in declaration order) of M
|
||||
let memberDecorators = decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
|
||||
let accessor = second accessor (get or set, in declaration order) of M
|
||||
if accessor then
|
||||
let memberDecorators = memberDecorators + decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
end if
|
||||
else if M is a method
|
||||
let memberDecorators = decorators of M
|
||||
for each parameter of M
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, M, paramIndex)
|
||||
next parameter
|
||||
else
|
||||
let memberDecorators = decorators of M
|
||||
end if
|
||||
|
||||
let name = name of M
|
||||
let target = C.prototype if M is on the prototype; otherwise, C if M is static
|
||||
Reflect.decorate(memberDecorators, C, name)
|
||||
next member
|
||||
|
||||
for each parameter of C
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, C, paramIndex)
|
||||
next parameter
|
||||
|
||||
let classDecorators = decorators of C
|
||||
let C = Reflect.decorate(classDecorators, C)
|
||||
</pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="operations">
|
||||
<h1>Abstract Operations</h1>
|
||||
<emu-clause id="operations-decoration">
|
||||
<h1>Decorator Operations</h1>
|
||||
<emu-clause id="operations-decoration-decorate">
|
||||
<h1>Decorate ( Decorators, O, P, desc )</h1>
|
||||
<p>When the abstract operation Decorate is called with ECMAScript language value <var>Decorators</var>, Object <var>O</var>, property key <var>P</var>, and property descriptor <var>desc</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="Decorate">
|
||||
1. If _P_ is *undefined* and _desc_ is *undefined*, then
|
||||
1. If IsCallable(_O_) is not *true*, throw a *TypeError* exception.
|
||||
2. Return DecorateConstructor(_Decorators_, _O_).
|
||||
2. Else
|
||||
1. Return DecorateProperty(_Decorators_, _O_, _P_, _desc_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="operations-decoration-decorateconstructor">
|
||||
<h1>DecorateConstructor ( Decorators, F )</h1>
|
||||
<p>When the abstract operation DecorateConstructor is called with ECMAScript language value <var>Decorators</var> and Object <var>F</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="DecorateConstructor">
|
||||
1. Let _result_ be _F_.
|
||||
2. Let _iterator_ be GetIterator(_Decorators_).
|
||||
3. Let _list_ be CreateListFromIterator(_iterator_, «Object»).
|
||||
4. For each _decorator_ in _list_ in reverse order
|
||||
1. Let _decorated_ be Call(_decorator_, *null*, _result_).
|
||||
2. ReturnIfAbrupt(_decorated_).
|
||||
3. If IsCallable(_decorated_), then
|
||||
1. Set _result_ to be _decorated_.
|
||||
4. Else if _decorated_ is not *undefined*, throw a *TypeError* exception.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="operations-decoration-decorateproperty">
|
||||
<h1>DecorateProperty ( Decorators, O, P, desc )</h1>
|
||||
<p>When the abstract operation DecorateProperty is called with ECMAScript language value <var>Decorators</var>, Object <var>O</var>, property key <var>P</var>, and property descriptor <var>desc</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="DecorateProperty">
|
||||
1. Let _result_ be _desc_.
|
||||
2. Let _key_ be ToPropertyKey(_P_).
|
||||
3. Let _iterator_ be GetIterator(_Decorators_).
|
||||
4. Let _list_ be CreateListFromIterator(_iterator_, «Object»).
|
||||
5. For each _decorator_ in _list_ in reverse order
|
||||
6. Let _decorated_ be Call(_decorator_, *null*, _O_, _key_, _result_).
|
||||
7. ReturnIfAbrupt(_decorated_).
|
||||
8. If Type(_decorated_) is Object, then
|
||||
1. Set _result_ to be _decorated_.
|
||||
9. Else if _decorated_ is not *undefined*, throw a *TypeError* exception.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
<emu-clause id="operations-object">
|
||||
<h1>Operations on Objects</h1>
|
||||
<emu-clause id="createlistfromiterator">
|
||||
<h1>CreateListFromIterator ( iterator [, elementTypes] )</h1>
|
||||
<p>When the abstract operation CreateListFromIterator is called with ECMAScript language value <var>iterator</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="CreateListFromIterator">
|
||||
1. ReturnIfAbrupt(_iterator_).
|
||||
2. If _elementTypes_ was not passed, let _elementTypes_ be (Undefined, Null, Boolean, String, Symbol, Number, Object).
|
||||
3. Let _list_ be an empty List.
|
||||
4. Repeat
|
||||
1. Let _next_ be IteratorStep(_iterator_).
|
||||
2. ReturnIfAbrupt(_next_).
|
||||
3. If _next_ is *false*, return _list_.
|
||||
4. Let _nextValue_ be IteratorValue(_next_).
|
||||
5. ReturnIfAbrupt(_nextValue_).
|
||||
6. If Type(_nextValue_) is not an element of _elementTypes_, then
|
||||
1. Return IteratorClose(_iterator_, Completion{[[type]]: throw, [[value]]: a newly created *TypeError* object, [[target]: empty}).
|
||||
7. Append _nextValue_ as the last element of _list_.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="getorcreatemetadatamap">
|
||||
<h1>GetOrCreateMetadataMap ( O, P, Create )</h1>
|
||||
<p>When the abstract operation GetOrCreateMetadataMap is called with Object <var>O</var>, property key <var>P</var>, and Boolean <var>Create</var> the following steps are taken:</p>
|
||||
<emu-alg aoid="GetOrCreateMetadataMap">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _metadataMap_ be *undefined*.
|
||||
3. Let _succeeded_ be *true*.
|
||||
4. Let _targetMetadata_ be the value of _O_'s [[Metadata]] internal slot.
|
||||
5. If _targetMetadata_ is *undefined*, then
|
||||
1. If _Create_ is *false*, return *undefined*.
|
||||
2. Set _targetMetadata_ to be a newly created *Map* object.
|
||||
3. Set the [[Metadata]] internal slot of _O_ to _targetMetadata_.
|
||||
6. Let _metadataMap_ be Invoke(_targetMetadata_, "get", _P_).
|
||||
7. ReturnIfAbrupt(_metadataMap_).
|
||||
8. If _metadataMap_ is *undefined*, then
|
||||
1. If _Create_ is *false*, return *undefined*.
|
||||
2. Set _metadataMap_ to be a newly created *Map* object.
|
||||
3. Let _setStatus_ be Invoke(_targetMetadata_, "set", _P_, _metadataMap_).
|
||||
4. ReturnIfAbrupt(_setStatus_).
|
||||
9. Return _metadataMap_.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="hasmetadata">
|
||||
<h1>[[HasMetadata]] ( MetadataKey, P )</h1>
|
||||
<p>When the [[HasMetadata]] internal method of _O_ is called with ECMAScript language value <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryHasMetadata(_MetadataKey_, _O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinaryhasmetadata">
|
||||
<h1>OrdinaryHasMetadata ( MetadataKey, O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryHasMetadata is called with ECMAScript language value <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryHasMetadata">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _hasOwn_ be OrdinaryHasOwnMetadata(_MetadataKey_, _O_, _P_).
|
||||
3. If _hasOwn_ is *true*, return *true*.
|
||||
4. Let _parent_ be _O_.[[GetPrototypeOf]]().
|
||||
5. ReturnIfAbrupt(_parent_).
|
||||
6. If _parent_ is not *null*, then
|
||||
1. return <var>parent</var>.[[HasMetadata]](_MetadataKey_, _P_).
|
||||
7. Return *false*.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="hasownmetadata">
|
||||
<h1>[[HasOwnMetadata]] ( MetadataKey, P )</h1>
|
||||
<p>When the [[HasOwnMetadata]] internal method of _O_ is called with ECMAScript language value <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryHasOwnMetadata(_MetadataKey_, _O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinaryhasownmetadata">
|
||||
<h1>OrdinaryHasOwnMetadata ( MetadataKey, O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryHasOwnMetadata is called with ECMAScript language value <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryHasOwnMetadata">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _metadataMap_ be GetOrCreateMetadataMap(_O_, _P_, *false*).
|
||||
3. ReturnIfAbrupt(_metadataMap_).
|
||||
4. If _metadataMap_ is *undefined*, return *false*.
|
||||
5. Return Invoke(_metadataMap_, "has", _MetadataKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="getmetadata">
|
||||
<h1>[[GetMetadata]] ( MetadataKey, P )</h1>
|
||||
<p>When the [[GetMatadata]] internal method of _O_ is called with ECMAScript language value <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryGetMetadata(_MetadataKey_, _O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinarygetmetadata">
|
||||
<h1>OrdinaryGetMetadata ( MetadataKey, O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryGetMetadata is called with ECMAScript language value <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryGetMetadata">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _hasOwn_ be OrdinaryHasOwnMetadata(_MetadataKey_, _O_, _P_).
|
||||
3. If _hasOwn_ is *true*, then
|
||||
1. return OrdinaryGetOwnMetadata(_MetadataKey_, _O_, _P_).
|
||||
4. Let _parent_ be _O_.[[GetPrototypeOf]]().
|
||||
5. ReturnIfAbrupt(_parent_).
|
||||
6. If _parent_ is not *null*, then
|
||||
1. return <var>parent</var>.[[GetMetadata]](_MetadataKey_, _P_).
|
||||
7. Return *undefined*.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="getownmetadata">
|
||||
<h1>[[GetOwnMetadata]] ( MetadataKey, P, ParamIndex )</h1>
|
||||
<p>When the [[GetOwnMetadata]] internal method of _O_ is called with ECMAScript language value <var>MetadataKey</var> and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryGetOwnMetadata(_MetadataKey_, _O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinarygetownmetadata">
|
||||
<h1>OrdinaryGetOwnMetadata ( MetadataKey, O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryGetOwnMetadata is called with ECMAScript language value <var>MetadataKey</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryGetOwnMetadata">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _metadataMap_ be GetOrCreateMetadataMap(_O_, _P_, *false*).
|
||||
3. ReturnIfAbrupt(_metadataMap_).
|
||||
4. If _metadataMap_ is *undefined*, return *undefined*.
|
||||
5. Return Invoke(_metadataMap_, "get", _MetadataKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="defineownmetadata">
|
||||
<h1>[[DefineOwnMetadata]] ( MetadataKey, MetadataValue, P )</h1>
|
||||
<p>When the [[DefineOwnMetadata]] internal method of _O_ is called with ECMAScript language value <var>MetadataKey</var>, ECMAScript language value <var>MetadataValue</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryDefineOwnMetadata(_MetadataKey_, _MetadataValue_, _O_, _P_)
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinarydefineownmetadata">
|
||||
<h1>OrdinaryDefineOwnMetadata ( MetadataKey, MetadataValue, O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryDefineOwnProperty is called with ECMAScript language value <var>MetadataKey</var>, ECMAScript language value <var>MetadataValue</var>, Object <var>O</var>, and property key <var>P</var>, the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryDefineOwnMetadata">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _metadataMap_ be GetOrCreateMetadataMap(_O_, _P_, *true*).
|
||||
3. ReturnIfAbrupt(_metadataMap_).
|
||||
4. Return Invoke(_metadataMap_, "set", _MetadataKey_, _MetadataValue_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="metadatakeys">
|
||||
<h1>[[MetadataKeys]] ( P )</h1>
|
||||
<p>When the [[MetadataKeys]] internal method of <var>O</var> is called with property key <var>P</var> the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryMetadataKeys(_O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinarymetadatakeys">
|
||||
<h1>OrdinaryMetadataKeys ( O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryMetadataKeys is called with Object <var>O</var> and property key <var>P</var> the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryMetadataKeys">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _ownKeys_ be OrdinaryOwnMetadataKeys(_O_, _P_).
|
||||
3. Let _parent_ = _O_.[[GetPrototypeOf]]().
|
||||
4. ReturnIfAbrupt(_parent_).
|
||||
5. If _parent_ is *null*, then return _ownKeys_.
|
||||
6. Let _parentKeys_ be <var>O</var>.[[OrdinaryMetadataKeys]](_P_).
|
||||
7. ReturnIfAbrupt(_parentKeys_).
|
||||
8. Let _ownKeysLen_ = Get(_ownKeys_, "length").
|
||||
9. ReturnIfAbrupt(_ownKeysLen_).
|
||||
10. If _ownKeysLen_ is 0, return _parentKeys_.
|
||||
11. Let _parentKeysLen_ = Get(_parentKeys_, "length").
|
||||
12. ReturnIfAbrupt(_parentKeysLen_).
|
||||
13. If _parentKeysLen_ is 0, return _ownKeys_.
|
||||
14. Let _set_ be a newly created *Set* object.
|
||||
15. Let _keys_ be ArrayCreate(0).
|
||||
16. Let _k_ be 0.
|
||||
17. For each element _key_ of _ownKeys_
|
||||
1. Let _hasKey_ be Invoke(_set_, "has", _key_).
|
||||
2. ReturnIfAbrupt(_hasKey_).
|
||||
3. If _hasKey_ is *false*, then
|
||||
1. Let _Pk_ be ToString(_k_).
|
||||
2. Let _addStatus_ be Invoke(_set_, "add", _key_).
|
||||
3. ReturnIfAbrupt(_addStatus_).
|
||||
4. Let _defineStatus_ be CreateDataPropertyOrThrow(_keys_, _Pk_, _key_).
|
||||
5. ReturnIfAbrupt(_defineStatus_).
|
||||
6. Increase _k_ by 1.
|
||||
18. For each element _key_ of _parentKeys_
|
||||
1. Let _hasKey_ be Invoke(_set_, "has", _key_).
|
||||
2. ReturnIfAbrupt(_hasKey_).
|
||||
3. If _hasKey_ is *false*, then
|
||||
1. Let _Pk_ be ToString(_k_).
|
||||
2. Let _addStatus_ be Invoke(_set_, "add", _key_).
|
||||
3. ReturnIfAbrupt(_addStatus_).
|
||||
4. Let _defineStatus_ be CreateDataPropertyOrThrow(_keys_, _Pk_, _key_).
|
||||
5. ReturnIfAbrupt(_defineStatus_).
|
||||
6. Increase _k_ by 1.
|
||||
19. Let _setStatus_ be Set(_keys_, "length", _k_).
|
||||
20. ReturnIfAbrupt(_setStatus_).
|
||||
21. return _keys_.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ownmetadatakeys">
|
||||
<h1>[[OwnMetadataKeys]] ( P )</h1>
|
||||
<p>When the [[OwnMetadataKeys]] internal method of <var>O</var> is called with property key <var>P</var> the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Return OrdinaryOwnMetadataKeys(_O_, _P_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="ordinaryownmetadatakeys">
|
||||
<h1>OrdinaryOwnMetadataKeys ( O, P )</h1>
|
||||
<p>When the abstract operation OrdinaryOwnMetadataKeys is called with Object <var>O</var> and property key <var>P</var> the following steps are taken:</p>
|
||||
<emu-alg aoid="OrdinaryOwnMetadataKeys">
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _keys_ be ArrayCreate(0).
|
||||
3. Let _metadataMap_ be GetOrCreateMetadataMap(_O_, _P_, *false*).
|
||||
4. ReturnIfAbrupt(_metadataMap_).
|
||||
5. If _metadataMap_ is *undefined*, return _keys_.
|
||||
6. Let _keysObj_ be Invoke(_metadataMap_, "keys").
|
||||
7. ReturnIfAbrupt(_keysObj_).
|
||||
8. Let _iterator_ be GetIterator(_keysObj_).
|
||||
9. ReturnIfAbrupt(_iterator_).
|
||||
10. Let _k_ be 0.
|
||||
11. Repeat
|
||||
1. Let _Pk_ be ToString(k).
|
||||
2. Let _next_ be IteratorStep(_iterator_).
|
||||
3. ReturnIfAbrupt(_next_).
|
||||
4. If _next_ is *false*, then
|
||||
1. Let _setStatus_ be Set(_keys_, "length", _k_, _true_).
|
||||
2. ReturnIfAbrupt(_setStatus_).
|
||||
3. Return _keys_.
|
||||
5. Let _nextValue_ be IteratorValue(_next_).
|
||||
6. ReturnIfAbrupt(_nextValue_).
|
||||
7. Let _defineStatus_ be CreateDataPropertyOrThrow(_keys_, _Pk_, _nextValue_).
|
||||
8. If _defineStatus_ is an abrupt completion, return IteratorClose(_iterator_, _defineStatus_).
|
||||
9. Increase _k_ by 1.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="deletemetadata">
|
||||
<h1>[[DeleteMetadata]]( MetadataKey, P )</h1>
|
||||
<p>When the [[DeleteMetadata]] internal method of <var>O</var> is called with ECMAScript language value <var>MetadataKey</var> and property key <var>P</var> the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Assert: _P_ is *undefined* or IsPropertyKey(_P_) is *true*.
|
||||
2. Let _metadataMap_ be GetOrCreateMetadataMap(_O_, _P_, *false*).
|
||||
3. ReturnIfAbrupt(_metadataMap_).
|
||||
4. If _metadataMap_ is *undefined*, return *false*.
|
||||
5. Return Invoke(_metadataMap_, "delete", _MetadataKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="reflection">
|
||||
<h1>Reflection</h1>
|
||||
<emu-clause id="reflect">
|
||||
<h1>The Reflect Object</h1>
|
||||
<p>This section contains amendments to the Reflect object.</p>
|
||||
<emu-note>A shim for this API can be found here: <a href="https://github.com/rbuckton/ReflectDecorators">https://github.com/rbuckton/ReflectDecorators</a></emu-note>
|
||||
<emu-clause id="reflect-metadatadecoratorfunctions">
|
||||
<h1>Metadata Decorator Functions</h1>
|
||||
<p>A metadata decorator function is an anonymous built-in function that has [[MetadataKey]] and [[MetadataValue]] internal slots.</p>
|
||||
<p>When a metadata decorator function <var>F</var> is called with arguments <var>target</var> and <var>key</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Assert: _F_ has a [[MetadataKey]] internal slot whose value is an ECMAScript language value, or *undefined*.
|
||||
2. Assert: _F_ has a [[MetadataValue]] internal slot whose value is an ECMAScript language value, or *undefined*.
|
||||
3. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
4. If _key_ is not *undefined* and IsPropertyKey(_key_) is *false*, throw a *TypeError* exception.
|
||||
5. Let _metadataKey_ be the value of _F_'s [[MetadataKey]] internal slot.
|
||||
6. Let _metadataValue_ be the value of _F_'s [[MetadataValue]] internal slot.
|
||||
7. Return <var>target</var>.[[DefineMetadata]](_metadataKey_, _metadataValue_, _target_, _key_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-decorate">
|
||||
<h1>Reflect.decorate ( decorators, target, propertyKey, attributes )</h1>
|
||||
<p>When the <code>decorator</code> function is called with arguments <var>decorators</var>, <var>target</var>, <var>propertyKey</var>, and <var>attributes</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_decorators_) is not Object, throw a *TypeError* exception.
|
||||
2. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
3. Let _key_ be ToPropertyKey(_propertyKey_).
|
||||
4. ReturnIfAbrupt(_propertyKey_).
|
||||
5. Let _desc_ be ToPropertyDescriptor(_attributes_).
|
||||
6. ReturnIfAbrupt(_desc_).
|
||||
7. Return Decorate(_decorators_, _target_, _propertyKey_, _desc_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-metadata">
|
||||
<h1>Reflect.metadata ( metadataKey, metadataValue )</h1>
|
||||
<p>When the <code>metadata</code> function is called with arguments <var>metadataKey</var> and <var>metadataValue</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. Let _decorator_ be a new built-in function object as defined in Metadata Decorator Functions.
|
||||
2. Set the [[MetadataKey]] internal slot of _decorator_ to _metadataKey_.
|
||||
3. Set the [[MetadataValue]] internal slot of _decorator_ to _metadataValue_.
|
||||
4. return _decorator_.
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-definemetadata">
|
||||
<h1>Reflect.defineMetadata ( metadataKey, metadataValue, target, propertyKey )</h1>
|
||||
<p>When the <code>defineMetadata</code> function is called with arguments <var>metadataKey</var>, <var>metadataValue</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[DefineMetadata]](_metadataKey_, _metadataValue_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-hasmetadata">
|
||||
<h1>Reflect.hasMetadata ( metadataKey, target, propertyKey )</h1>
|
||||
<p>When the <code>hasMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[HasMetadata]](_metadataKey_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-hasownmetadata">
|
||||
<h1>Reflect.hasOwnMetadata ( metadataKey, target, propertyKey )</h1>
|
||||
<p>When the <code>hasOwnMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[HasOwn]](_metadataKey_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-getmetadata">
|
||||
<h1>Reflect.getMetadata ( metadataKey, target, propertyKey )</h1>
|
||||
<p>When the <code>getMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[GetMetadata]](_metadataKey_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-getownmetadata">
|
||||
<h1>Reflect.getOwnMetadata ( metadataKey, target, propertyKey )</h1>
|
||||
<p>When the <code>getOwnMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[GetOwnMetadata]](_metadataKey_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-getmetadatakeys">
|
||||
<h1>Reflect.getMetadataKeys ( target, propertyKey )</h1>
|
||||
<p>When the <code>getMetadataKeys</code> function is called with arguments <var>target</var> and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[GetMetadataKeys]](_propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-getownmetadata">
|
||||
<h1>Reflect.getOwnMetadataKeys ( target, propertyKey )</h1>
|
||||
<p>When the <code>getOwnMetadataKeys</code> function is called with arguments <var>target</var> and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[GetOwnMetadataKeys]](_propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
<emu-clause id="reflect-deletemetadata">
|
||||
<h1>Reflect.deleteMetadata ( metadataKey, target, propertyKey )</h1>
|
||||
<p>When the <code>deleteMetadata</code> function is called with arguments <var>metadataKey</var>, <var>target</var>, and <var>propertyKey</var>, the following steps are taken:</p>
|
||||
<emu-alg>
|
||||
1. If Type(_target_) is not Object, throw a *TypeError* exception.
|
||||
2. return <var>target</var>.[[DeleteMetadata]](_metadataKey_, _propertyKey_).
|
||||
</emu-alg>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
<emu-annex id="grammar">
|
||||
<h1>Grammar</h1>
|
||||
<emu-annex id="grammar-expressions">
|
||||
<h1>Expressions</h1>
|
||||
<emu-production id="grammar-memberexpression" name="MemberExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield">PrimaryExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression</emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-t>.</emu-t><emu-nt>IdentifierName</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-nt params="?Yield">TemplateLiteral</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">SuperProperty</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>MetaProperty</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-superproperty" name="SuperProperty" params="Yield, Decorator">
|
||||
<emu-rhs constraints="~Decorator"><emu-t>super</emu-t><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression</emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-newexpression" name="NewExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">NewExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-callexpression" name="CallExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt> <emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield">SuperCall</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-nt params="?Yield">CallExpression</emu-nt> <emu-t>[</emu-t> <emu-nt params="In, ?Yield">Expression</emu-nt> <emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-t>.</emu-t> <emu-nt>IdentifierName</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-nt params="?Yield">TemplateLiteral</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-lefthandsideexpression" name="LeftHandSideExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">NewExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="functions-and-classes">
|
||||
<h1>Functions and Classes</h1>
|
||||
<emu-production id="grammar-classdeclaration" name="ClassDeclaration" params="Yield, Default">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield">BindingIdentifier</emu-nt> <emu-nt params="?Yield">ClassTail</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+Default"><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield">ClassTail</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classexpression" name="ClassExpression" params="Yield, GeneratorParameter">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield" optional>BindingIdentifier</emu-nt> <emu-nt params="?Yield, ?GeneratorParameter">ClassTail</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classelement" name="ClassElement" params="Yield">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-nt params="?Yield">MethodDefinition</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>static</emu-t> <emu-nt params="?Yield">MethodDefinition</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>;</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decoratorlist" name="DecoratorList" params="Yield">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-nt params="?Yield">Decorator</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decorator" name="Decorator" params="Yield">
|
||||
<emu-rhs><emu-t>@</emu-t> <emu-nt params="Decorator, ?Yield">LeftHandSideExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="scripts-and-modules">
|
||||
<h1>Scripts and Modules</h1>
|
||||
<emu-production id="grammar-exportdeclaration" name="ExportDeclaration">
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>*</emu-t> <emu-nt>FromClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>ExportClause</emu-nt> <emu-nt>FromClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>ExportClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>VariableStatement</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt>Declaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-nt params="Default">HoistableDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt params="Default">ClassDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ∉ { <emu-t>function</emu-t>, <emu-t>class</emu-t>, <emu-t>@</emu-t> }</emu-gann> <emu-nt>AssignmentExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList</emu-nt> <emu-t>export</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt>ClassDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList</emu-nt> <emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt params="Default">ClassDeclaration</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
</emu-annex>
|
441
node_modules/reflect-metadata/spec/typescript-out.html
generated
vendored
Normal file
441
node_modules/reflect-metadata/spec/typescript-out.html
generated
vendored
Normal file
@ -0,0 +1,441 @@
|
||||
<!doctype html>
|
||||
<head><meta charset="utf8">
|
||||
<title>Decorators</title>
|
||||
<link rel="stylesheet" href="./css/elements.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
|
||||
</head><body><emu-biblio href="./biblio.json"></emu-biblio>
|
||||
|
||||
<h1>Decorators Proposal - TypeScript</h1>
|
||||
<div><h2>Table of Contents</h2><ol class="toc"><li><a href="#introduction"><span class="secnum"></span> Introduction</a></li><li><a href="#proposal-terms"><span class="secnum">1</span> Terms</a><ol class="toc"><li><a href="#proposal-terms-decorator"><span class="secnum">1.1</span> Decorator</a></li><li><a href="#proposal-terms-classdecoratorfunction"><span class="secnum">1.2</span> Class Decorator Function</a></li><li><a href="#proposal-terms-propertydecoratorfunction"><span class="secnum">1.3</span> Property/Method Decorator Function</a></li><li><a href="#proposal-terms-parameterdecoratorfunction"><span class="secnum">1.4</span> Parameter Decorator Function</a></li><li><a href="#proposal-terms-decoratorfactory"><span class="secnum">1.5</span> Decorator Factory</a></li></ol></li><li><a href="#proposal-decoratortargets"><span class="secnum">2</span> Decorator Targets</a></li><li><a href="#proposal-decoratoreval"><span class="secnum">3</span> Decorator Evaluation and Application Order</a></li><li><a href="#reflect"><span class="secnum">4</span> Reflect API</a></li><li><a href="#transpile"><span class="secnum">5</span> Transformation</a><ol class="toc"><li><a href="#transpile-class"><span class="secnum">5.1</span> Class Declaration</a></li><li><a href="#transpile-exportclass"><span class="secnum">5.2</span> Class Declaration (Exported)</a></li><li><a href="#transpile-exportdefaultclass"><span class="secnum">5.3</span> Class Declaration (Default, Exported)</a></li><li><a href="#transpile-classmethod"><span class="secnum">5.4</span> Class Method Declaration</a></li><li><a href="#transpile-classaccessor"><span class="secnum">5.5</span> Class Accessor Declaration</a></li><li><a href="#transpile-classproperty"><span class="secnum">5.6</span> Class Property Declaration</a></li><li><a href="#transpile-classconstructorparameter"><span class="secnum">5.7</span> Class Constructor Parameter Declaration</a></li><li><a href="#transpile-classmethodparameter"><span class="secnum">5.8</span> Class Method Parameter Declaration</a></li><li><a href="#transpile-classaccessorparameter"><span class="secnum">5.9</span> Class Set Accessor Parameter Declaration</a></li></ol></li><li><a href="#grammar"><span class="secnum">A</span> Grammar</a><ol class="toc"><li><a href="#grammar-expressions"><span class="secnum">A.1</span> Expressions</a></li><li><a href="#functions-and-classes"><span class="secnum">A.2</span> Functions and Classes</a></li><li><a href="#scripts-and-modules"><span class="secnum">A.3</span> Scripts and Modules</a></li></ol></li><li><a href="#typescript"><span class="secnum">B</span> TypeScript</a><ol class="toc"><li><a href="#typescript-definitions"><span class="secnum">B.1</span> TypeScript Definitions</a></li></ol></li></ol></div><emu-intro id="introduction">
|
||||
<h1><span class="secnum"></span>Introduction</h1>
|
||||
<p>Proposal to add Decorators to TypeScript.</p>
|
||||
<p>For the ECMAScript specific proposal, see <a href="index.html">http://rbuckton.github.io/reflectdecorators/index.html</a></p>
|
||||
</emu-intro>
|
||||
|
||||
<emu-clause id="proposal-terms">
|
||||
<h1><span class="secnum">1</span>Terms</h1>
|
||||
<emu-clause id="proposal-terms-decorator">
|
||||
<h1><span class="secnum">1.1</span>Decorator</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> is an expression that is evaluated after a class has been defined, that can be used to annotate or modify the class in some fashion. This expression must evaluate to a <code>function</code>, which is executed by the runtime to apply the decoration.</p>
|
||||
<pre><code class="typescript hljs">@decoratorExpression
|
||||
<span class="hljs-keyword">class</span> C {
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-classdecoratorfunction">
|
||||
<h1><span class="secnum">1.2</span>Class Decorator Function</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>class decorator function</em> is a function that accepts a constructor function as its argument, and returns either <code>undefined</code>, the provided constructor function, or a new constructor function. Returning <code>undefined</code> is equivalent to returning the provided constructor function.</p>
|
||||
<pre><code class="typescript hljs"><span class="hljs-comment">// A class decorator function</span>
|
||||
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">dec</span><span class="hljs-params">(target)</span> </span>{
|
||||
<span class="hljs-comment">// modify, annotate, or replace target...</span>
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-propertydecoratorfunction">
|
||||
<h1><span class="secnum">1.3</span>Property/Method Decorator Function</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>property decorator function</em> is a function that accepts three arguments: The object that owns the property, the key for the property (a <code>string</code> or a <code>symbol</code>), and optionally the property descriptor of the property. The function must return either <code>undefined</code>, the provided property descriptor, or a new property descriptor. Returning <code>undefined</code> is equivalent to returning the provided property descriptor.</p>
|
||||
<pre><code class="typescript hljs"><span class="hljs-comment">// A property (or method/accessor) decorator function</span>
|
||||
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">dec</span><span class="hljs-params">(target, key, descriptor)</span> </span>{
|
||||
<span class="hljs-comment">// annotate the target and key; or modify or replace the descriptor...</span>
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-parameterdecoratorfunction">
|
||||
<h1><span class="secnum">1.4</span>Parameter Decorator Function</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>parameter decorator function</em> is a function that accepts three arguments: The function that contains the decorated parameter, the property key of the member (or <code>undefined</code> for a parameter of the constructor), and the ordinal index of the parameter. The return value of this decorator is ignored.</p>
|
||||
<pre><code class="typescript hljs">
|
||||
<span class="hljs-comment">// A parameter decorator</span>
|
||||
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">dec</span><span class="hljs-params">(target, paramIndex)</span> </span>{
|
||||
<span class="hljs-comment">// annotate the target and index</span>
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-decoratorfactory">
|
||||
<h1><span class="secnum">1.5</span>Decorator Factory</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator factory</em> is a function that can accept any number of arguments, and must return one of the above types of decorator function.</p>
|
||||
<pre><code class="typescript hljs"><span class="hljs-comment">// a class decorator factory function</span>
|
||||
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">dec</span><span class="hljs-params">(x, y)</span> </span>{
|
||||
<span class="hljs-comment">// the class decorator function</span>
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-params">(target)</span> </span>{
|
||||
<span class="hljs-comment">// modify, annotate, or replace target...</span>
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratortargets">
|
||||
<h1><span class="secnum">2</span>Decorator Targets</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> <strong>can</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class declaration</li>
|
||||
<li>A class property initializer (static or prototype)</li>
|
||||
<li>A class method declaration (static or prototype)</li>
|
||||
<li>A class get or set accessor declaration (static or prototype)</li>
|
||||
<li>A parameter of a class constructor</li>
|
||||
<li>A parameter of a class method (static or prototype)</li>
|
||||
<li>A parameter of a class get or set accessor (static or prototype)</li>
|
||||
</ul>
|
||||
<p>Please note that a <em>decorator</em> currently <strong>cannot</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class constructor - This is to reduce ambiguity between where you can apply a decorator (on the class or on its constructor) and which of the above decorator function forms is called.</li>
|
||||
<li>A function declaration - Decorators on a function declaration would introduce a TDZ (Temporal Dead Zone), which would make the function unreachable until its declaration is executed. This could cause confusion as an undecorated function declaration is hoisted and can be used in a statement preceeding the declaration.</li>
|
||||
<li>A function expression - This is to reduce confusion and maintain parity with disallowing decorators on a function declaration.</li>
|
||||
<li>An arrow function - This is to reduce confusion and maintain parity with disallowing decorators on a function expression.</li>
|
||||
</ul>
|
||||
<p>This list may change in the future.</p>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratoreval">
|
||||
<h1><span class="secnum">3</span>Decorator Evaluation and Application Order</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>Decorators are <em>evaluated</em> in the order they appear preceeding their target declaration, to preserve side-effects due to evaluation order. Decorators are <em>applied</em> to their target declaration in reverse order, starting with the decorator closest to the declaration. This behavior is specified to preserve the expected behavior of decorators without a declarative syntax.</p>
|
||||
<pre><code class="typescript hljs">@F
|
||||
@G
|
||||
<span class="hljs-keyword">class</span> C {
|
||||
}
|
||||
</code></pre>
|
||||
<p>For example, the above listing could be approximately written without decorators in the following fashion:</p>
|
||||
<pre><code class="typescript hljs">C = F(G(C))</code></pre>
|
||||
<p>In the above example, the expression <code>F</code> is evaluated first, followed by the expression <code>G</code>. <code>G</code> is then called with the constructor function as its argument, followed by calling <code>F</code> with the result. The actual process of applying decorators is more complex than the above example however, though you may still imperatively apply decorators with a reflection API.</p>
|
||||
<p>If a class declaration has decorators on both the class and any of its members or parameters, the decorators are applied using the following pseudocode:</p>
|
||||
<pre>for each member M of class C
|
||||
if M is an accessor then
|
||||
let accessor = first accessor (get or set, in declaration order) of M
|
||||
let memberDecorators = decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
|
||||
let accessor = second accessor (get or set, in declaration order) of M
|
||||
if accessor then
|
||||
let memberDecorators = memberDecorators + decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
end if
|
||||
else if M is a method
|
||||
let memberDecorators = decorators of M
|
||||
for each parameter of M
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, M, paramIndex)
|
||||
next parameter
|
||||
else
|
||||
let memberDecorators = decorators of M
|
||||
end if
|
||||
|
||||
let name = name of M
|
||||
let target = C.prototype if M is on the prototype; otherwise, C if M is static
|
||||
Reflect.decorate(memberDecorators, C, name)
|
||||
next member
|
||||
|
||||
for each parameter of C
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, C, paramIndex)
|
||||
next parameter
|
||||
|
||||
let classDecorators = decorators of C
|
||||
let C = Reflect.decorate(classDecorators, C)
|
||||
</pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="reflect">
|
||||
<h1><span class="secnum">4</span>Reflect API</h1>
|
||||
<emu-note><span class="note">Note</span>This section is non-normative.</emu-note>
|
||||
<p>In addition to a declarative approach to defining decorators, it is necessary to also include an imperative API capable of applying decorators, as well as defining, reflecting over, and removing decorator metadata from an object, property, or parameter.</p>
|
||||
<p>A shim for this API can be found here: <a href="https://github.com/rbuckton/ReflectDecorators">https://github.com/rbuckton/ReflectDecorators</a></p>
|
||||
<pre><code class="typescript hljs">Reflect.decorate(decorators, target, propertyKey?, descriptor?)</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile">
|
||||
<h1><span class="secnum">5</span>Transformation</h1>
|
||||
<p>The following are examples of how decorators can be desugared to ES6 (through a transpiler such as TypeScript). These examples levarage an imperative reflection API.</p>
|
||||
<emu-clause id="transpile-class">
|
||||
<h1><span class="secnum">5.1</span>Class Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs">@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
<span class="hljs-keyword">class</span> C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">let</span> C = <span class="hljs-keyword">class</span> {
|
||||
}
|
||||
<span class="hljs-built_in">Object</span>.defineProperty(C, <span class="hljs-string">"name"</span>, { value: <span class="hljs-string">"C"</span>, configurable: <span class="hljs-literal">true</span> });
|
||||
C = __decorate([F(<span class="hljs-string">"color"</span>), G], C);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-exportclass">
|
||||
<h1><span class="secnum">5.2</span>Class Declaration (Exported)</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs">@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
<span class="hljs-keyword">export</span> <span class="hljs-keyword">class</span> C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs">export <span class="hljs-keyword">let</span> C = <span class="hljs-keyword">class</span> {
|
||||
}
|
||||
<span class="hljs-built_in">Object</span>.defineProperty(C, <span class="hljs-string">"name"</span>, { value: <span class="hljs-string">"C"</span>, configurable: <span class="hljs-literal">true</span> });
|
||||
C = __decorate([F(<span class="hljs-string">"color"</span>), G], C);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-exportdefaultclass">
|
||||
<h1><span class="secnum">5.3</span>Class Declaration (Default, Exported)</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs">@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> <span class="hljs-keyword">class</span> C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">let</span> C = <span class="hljs-keyword">class</span> {
|
||||
}
|
||||
<span class="hljs-built_in">Object</span>.defineProperty(C, <span class="hljs-string">"name"</span>, { value: <span class="hljs-string">"C"</span>, configurable: <span class="hljs-literal">true</span> });
|
||||
C = __decorate([F(<span class="hljs-string">"color"</span>), G], C);
|
||||
export <span class="hljs-keyword">default</span> C;
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classmethod">
|
||||
<h1><span class="secnum">5.4</span>Class Method Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
method() { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
method() { }
|
||||
}
|
||||
<span class="hljs-built_in">Object</span>.defineProperty(C.prototype, <span class="hljs-string">"method"</span>,
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C.prototype, <span class="hljs-string">"method"</span>, <span class="hljs-built_in">Object</span>.getOwnPropertyDescriptor(C.prototype, <span class="hljs-string">"method"</span>)));
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classaccessor">
|
||||
<h1><span class="secnum">5.5</span>Class Accessor Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
<span class="hljs-keyword">get</span> accessor() { }
|
||||
<span class="hljs-keyword">set</span> accessor(value) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
get accessor() { }
|
||||
set accessor(value) { }
|
||||
}
|
||||
<span class="hljs-built_in">Object</span>.defineProperty(C.prototype, <span class="hljs-string">"accessor"</span>,
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C.prototype, <span class="hljs-string">"accessor"</span>, <span class="hljs-built_in">Object</span>.getOwnPropertyDescriptor(C.prototype, <span class="hljs-string">"accessor"</span>)));
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classproperty">
|
||||
<h1><span class="secnum">5.6</span>Class Property Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
@F(<span class="hljs-string">"color"</span>)
|
||||
@G
|
||||
property = <span class="hljs-number">1</span>;
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
constructor() {
|
||||
<span class="hljs-keyword">this</span>.property = <span class="hljs-number">1</span>;
|
||||
}
|
||||
}
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C.prototype, <span class="hljs-string">"property"</span>);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classconstructorparameter">
|
||||
<h1><span class="secnum">5.7</span>Class Constructor Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
<span class="hljs-constructor"><span class="hljs-keyword">constructor</span>(@F("color") @G p) </span>{ }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
constructor(p) { }
|
||||
}
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C, <span class="hljs-keyword">void</span> <span class="hljs-number">0</span>, <span class="hljs-number">0</span>);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classmethodparameter">
|
||||
<h1><span class="secnum">5.8</span>Class Method Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
method(@F(<span class="hljs-string">"color"</span>) @G p) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
method(p) { }
|
||||
}
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C.prototype, <span class="hljs-string">"method"</span>, <span class="hljs-number">0</span>);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classaccessorparameter">
|
||||
<h1><span class="secnum">5.9</span>Class Set Accessor Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript hljs"><span class="hljs-keyword">class</span> C {
|
||||
<span class="hljs-keyword">set</span> accessor(@F(<span class="hljs-string">"color"</span>) @G p) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript hljs"><span class="hljs-keyword">class</span> C {
|
||||
set accessor(p) { }
|
||||
}
|
||||
__decorate([F(<span class="hljs-string">"color"</span>), G], C.prototype, <span class="hljs-string">"accessor"</span>, <span class="hljs-number">0</span>);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
</emu-clause>
|
||||
|
||||
<emu-annex id="grammar">
|
||||
<h1><span class="secnum">A</span>Grammar</h1>
|
||||
<emu-annex id="grammar-expressions">
|
||||
<h1><span class="secnum">A.1</span>Expressions</h1>
|
||||
<emu-production id="grammar-memberexpression" name="MemberExpression" params="Yield, Decorator">
|
||||
<emu-nt>MemberExpression<emu-mods> [Yield, Decorator]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield">PrimaryExpression<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-constraints>[~Decorator]</emu-constraints><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression<emu-mods> [In, ?Yield]</emu-mods></emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-t>.</emu-t><emu-nt>IdentifierName<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-nt params="?Yield">TemplateLiteral<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">SuperProperty<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>MetaProperty<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-nt params="?Yield">Arguments<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-superproperty" name="SuperProperty" params="Yield, Decorator">
|
||||
<emu-nt>SuperProperty<emu-mods> [Yield, Decorator]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs constraints="~Decorator"><emu-constraints>[~Decorator]</emu-constraints><emu-t>super</emu-t><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression<emu-mods> [In, ?Yield]</emu-mods></emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-newexpression" name="NewExpression" params="Yield, Decorator">
|
||||
<emu-nt>NewExpression<emu-mods> [Yield, Decorator]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">NewExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-callexpression" name="CallExpression" params="Yield, Decorator">
|
||||
<emu-nt>CallExpression<emu-mods> [Yield, Decorator]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-nt params="?Yield">Arguments<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield">SuperCall<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-nt params="?Yield">Arguments<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-constraints>[~Decorator]</emu-constraints><emu-nt params="?Yield">CallExpression<emu-mods> [?Yield]</emu-mods></emu-nt><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression<emu-mods> [In, ?Yield]</emu-mods></emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-t>.</emu-t><emu-nt>IdentifierName<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt><emu-nt params="?Yield">TemplateLiteral<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-lefthandsideexpression" name="LeftHandSideExpression" params="Yield, Decorator">
|
||||
<emu-nt>LeftHandSideExpression<emu-mods> [Yield, Decorator]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?Decorator">NewExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression<emu-mods> [?Yield, ?Decorator]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="functions-and-classes">
|
||||
<h1><span class="secnum">A.2</span>Functions and Classes</h1>
|
||||
<emu-production id="grammar-strictformalparameters" name="StrictFormalParameters" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-nt>StrictFormalParameters<emu-mods> [Yield, GeneratorParameter, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameters<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameters" name="FormalParameters" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-nt>FormalParameters<emu-mods> [Yield, GeneratorParameter, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-prose>[empty]</emu-prose></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameterList<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameterlist" name="FormalParameterList" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-nt>FormalParameterList<emu-mods> [Yield, GeneratorParameter, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?ClassParameter">FunctionRestParameter<emu-mods> [?Yield, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt><emu-t>,</emu-t><emu-nt params="?Yield, ?ClassParameter">FunctionRestParameter<emu-mods> [?Yield, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalslist" name="FormalsList" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-nt>FormalsList<emu-mods> [Yield, GeneratorParameter, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameter<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt><emu-t>,</emu-t><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameter<emu-mods> [?Yield, ?GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-functionrestparameter" name="FunctionRestParameter" params="Yield, ClassParameter">
|
||||
<emu-nt>FunctionRestParameter<emu-mods> [Yield, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield">BindingRestElement<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+ClassParameter"><emu-constraints>[+ClassParameter]</emu-constraints><emu-nt>DecoratorList<emu-mods></emu-mods></emu-nt><emu-nt params="?Yield">BindingRestElement<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameter" name="FormalParameter" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-nt>FormalParameter<emu-mods> [Yield, GeneratorParameter, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield, ?GeneratorParameter">BindingElement<emu-mods> [?Yield, ?GeneratorParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+ClassParameter"><emu-constraints>[+ClassParameter]</emu-constraints><emu-nt>DecoratorList<emu-mods></emu-mods></emu-nt><emu-nt params="?Yield, ?GeneratorParameter">BindingElement<emu-mods> [?Yield, ?GeneratorParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-methoddefinition" name="MethodDefinition" params="Yield, ClassParameter">
|
||||
<emu-nt>MethodDefinition<emu-mods> [Yield, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield">PropertyName<emu-mods> [?Yield]</emu-mods></emu-nt><emu-t>(</emu-t><emu-nt params="?ClassParameter">StrictFormalParameters<emu-mods> [?ClassParameter]</emu-mods></emu-nt><emu-t>)</emu-t><emu-t>{</emu-t><emu-nt>FunctionBody<emu-mods></emu-mods></emu-nt><emu-t>}</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?ClassParameter">GeneratorMethod<emu-mods> [?Yield, ?ClassParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>get</emu-t><emu-nt params="?Yield">PropertyName<emu-mods> [?Yield]</emu-mods></emu-nt><emu-t>(</emu-t><emu-t>)</emu-t><emu-t>{</emu-t><emu-nt>FunctionBody<emu-mods></emu-mods></emu-nt><emu-t>}</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>set</emu-t><emu-nt params="?Yield">PropertyName<emu-mods> [?Yield]</emu-mods></emu-nt><emu-t>(</emu-t><emu-nt params="?ClassParameter">PropertySetParameterList<emu-mods> [?ClassParameter]</emu-mods></emu-nt><emu-t>)</emu-t><emu-t>{</emu-t><emu-nt>FunctionBody<emu-mods></emu-mods></emu-nt><emu-t>}</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-generatormethod" name="GeneratorMethod" params="Yield, ClassParameter">
|
||||
<emu-nt>GeneratorMethod<emu-mods> [Yield, ClassParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-t>*</emu-t><emu-nt params="?Yield">PropertyName<emu-mods> [?Yield]</emu-mods></emu-nt><emu-t>(</emu-t><emu-nt params="Yield, GeneratorParameter, ?ClassParameter">StrictFormalParameters<emu-mods> [Yield, GeneratorParameter, ?ClassParameter]</emu-mods></emu-nt><emu-t>)</emu-t><emu-t>{</emu-t><emu-nt>GeneratorBody<emu-mods></emu-mods></emu-nt><emu-t>}</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classdeclaration" name="ClassDeclaration" params="Yield, Default">
|
||||
<emu-nt>ClassDeclaration<emu-mods> [Yield, Default]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-t>class</emu-t><emu-nt params="?Yield">BindingIdentifier<emu-mods> [?Yield]</emu-mods></emu-nt><emu-nt params="?Yield">ClassTail<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+Default"><emu-constraints>[+Default]</emu-constraints><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-t>class</emu-t><emu-nt params="?Yield">ClassTail<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classexpression" name="ClassExpression" params="Yield, GeneratorParameter">
|
||||
<emu-nt>ClassExpression<emu-mods> [Yield, GeneratorParameter]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-t>class</emu-t><emu-nt params="?Yield" optional="">BindingIdentifier<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-nt params="?Yield, ?GeneratorParameter">ClassTail<emu-mods> [?Yield, ?GeneratorParameter]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classelement" name="ClassElement" params="Yield">
|
||||
<emu-nt>ClassElement<emu-mods> [Yield]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-nt params="ClassParameter, ?Yield">MethodDefinition<emu-mods> [ClassParameter, ?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-t>static</emu-t><emu-nt params="ClassParameter, ?Yield">MethodDefinition<emu-mods> [ClassParameter, ?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-t optional="">static</emu-t><emu-nt>PropertyName<emu-mods></emu-mods></emu-nt><emu-nt params="In, ?Yield" optional="">Initializer<emu-mods> [In, ?Yield] opt</emu-mods></emu-nt><emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>;</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decoratorlist" name="DecoratorList" params="Yield">
|
||||
<emu-nt>DecoratorList<emu-mods> [Yield]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-nt params="?Yield" optional="">DecoratorList<emu-mods> [?Yield] opt</emu-mods></emu-nt><emu-nt params="?Yield">Decorator<emu-mods> [?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decorator" name="Decorator" params="Yield">
|
||||
<emu-nt>Decorator<emu-mods> [Yield]</emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-t>@</emu-t><emu-nt params="Decorator, ?Yield">LeftHandSideExpression<emu-mods> [Decorator, ?Yield]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="scripts-and-modules">
|
||||
<h1><span class="secnum">A.3</span>Scripts and Modules</h1>
|
||||
<emu-production id="grammar-exportdeclaration" name="ExportDeclaration">
|
||||
<emu-nt>ExportDeclaration<emu-mods></emu-mods><emu-mods></emu-mods></emu-nt><emu-geq>:</emu-geq><emu-rhs><emu-t>export</emu-t><emu-t>*</emu-t><emu-nt>FromClause<emu-mods></emu-mods></emu-nt><emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-nt>ExportClause<emu-mods></emu-mods></emu-nt><emu-nt>FromClause<emu-mods></emu-mods></emu-nt><emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-nt>ExportClause<emu-mods></emu-mods></emu-nt><emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-nt>VariableStatement<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-gann>[lookahead ≠ <emu-t>@</emu-t>]</emu-gann><emu-nt>Declaration<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-t>default</emu-t><emu-nt params="Default">HoistableDeclaration<emu-mods> [Default]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-t>default</emu-t><emu-gann>[lookahead ≠ <emu-t>@</emu-t>]</emu-gann><emu-nt params="Default">ClassDeclaration<emu-mods> [Default]</emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t><emu-t>default</emu-t><emu-gann>[lookahead ∉ { <emu-t>function</emu-t>, <emu-t>class</emu-t>, <emu-t>@</emu-t> }]</emu-gann><emu-nt>AssignmentExpression<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList<emu-mods></emu-mods></emu-nt><emu-t>export</emu-t><emu-gann>[lookahead ≠ <emu-t>@</emu-t>]</emu-gann><emu-nt>ClassDeclaration<emu-mods></emu-mods></emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList<emu-mods></emu-mods></emu-nt><emu-t>export</emu-t><emu-t>default</emu-t><emu-gann>[lookahead ≠ <emu-t>@</emu-t>]</emu-gann><emu-nt params="Default">ClassDeclaration<emu-mods> [Default]</emu-mods></emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
</emu-annex>
|
||||
<emu-annex id="typescript">
|
||||
<h1><span class="secnum">B</span>TypeScript</h1>
|
||||
<emu-annex id="typescript-definitions">
|
||||
<h1><span class="secnum">B.1</span>TypeScript Definitions</h1>
|
||||
<pre><code class="typescript hljs"><span class="hljs-interface"><span class="hljs-keyword">interface</span> TypedPropertyDescriptor<T> </span>{
|
||||
enumerable?: <span class="hljs-built_in">boolean</span>;
|
||||
configurable?: <span class="hljs-built_in">boolean</span>;
|
||||
writable?: <span class="hljs-built_in">boolean</span>;
|
||||
value?: T;
|
||||
<span class="hljs-keyword">get</span>?: () => T;
|
||||
<span class="hljs-keyword">set</span>?: (value: T) => <span class="hljs-built_in">void</span>;
|
||||
}
|
||||
|
||||
type ClassDecorator = <span class="xml"><span class="hljs-tag"><<span class="hljs-title">TFunction</span> <span class="hljs-attribute">extends</span> <span class="hljs-attribute">Function</span>></span>(target: TFunction): TFunction | void;
|
||||
type MethodDecorator = <span class="hljs-tag"><<span class="hljs-title">T</span>></span>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<span class="hljs-tag"><<span class="hljs-title">T</span>></span>): TypedPropertyDescriptor<span class="hljs-tag"><<span class="hljs-title">T</span>></span> | void;
|
||||
type PropertyDecorator = (target: Object, propertyKey: string | symbol): void;
|
||||
type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number): void;
|
||||
</span></code></pre>
|
||||
</emu-annex>
|
||||
</emu-annex></body>
|
441
node_modules/reflect-metadata/spec/typescript.html
generated
vendored
Normal file
441
node_modules/reflect-metadata/spec/typescript.html
generated
vendored
Normal file
@ -0,0 +1,441 @@
|
||||
<meta charset="utf8">
|
||||
<title>Decorators</title>
|
||||
<link rel="stylesheet" href="./css/elements.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
|
||||
<emu-biblio href="./biblio.json"></emu-biblio>
|
||||
|
||||
<h1>Decorators Proposal - TypeScript</h1>
|
||||
<emu-intro id="introduction">
|
||||
<h1>Introduction</h1>
|
||||
<p>Proposal to add Decorators to TypeScript.</p>
|
||||
<p>For the ECMAScript specific proposal, see <a href="index.html">http://rbuckton.github.io/reflectdecorators/index.html</a></p>
|
||||
</emu-intro>
|
||||
|
||||
<emu-clause id="proposal-terms">
|
||||
<h1>Terms</h1>
|
||||
<emu-clause id="proposal-terms-decorator">
|
||||
<h1>Decorator</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> is an expression that is evaluated after a class has been defined, that can be used to annotate or modify the class in some fashion. This expression must evaluate to a <code>function</code>, which is executed by the runtime to apply the decoration.</p>
|
||||
<pre><code class="typescript">@decoratorExpression
|
||||
class C {
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-classdecoratorfunction">
|
||||
<h1>Class Decorator Function</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>class decorator function</em> is a function that accepts a constructor function as its argument, and returns either <code>undefined</code>, the provided constructor function, or a new constructor function. Returning <code>undefined</code> is equivalent to returning the provided constructor function.</p>
|
||||
<pre><code class="typescript">// A class decorator function
|
||||
function dec(target) {
|
||||
// modify, annotate, or replace target...
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-propertydecoratorfunction">
|
||||
<h1>Property/Method Decorator Function</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>property decorator function</em> is a function that accepts three arguments: The object that owns the property, the key for the property (a <code>string</code> or a <code>symbol</code>), and optionally the property descriptor of the property. The function must return either <code>undefined</code>, the provided property descriptor, or a new property descriptor. Returning <code>undefined</code> is equivalent to returning the provided property descriptor.</p>
|
||||
<pre><code class="typescript">// A property (or method/accessor) decorator function
|
||||
function dec(target, key, descriptor) {
|
||||
// annotate the target and key; or modify or replace the descriptor...
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-parameterdecoratorfunction">
|
||||
<h1>Parameter Decorator Function</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>parameter decorator function</em> is a function that accepts three arguments: The function that contains the decorated parameter, the property key of the member (or <code>undefined</code> for a parameter of the constructor), and the ordinal index of the parameter. The return value of this decorator is ignored.</p>
|
||||
<pre><code class="typescript">
|
||||
// A parameter decorator
|
||||
function dec(target, paramIndex) {
|
||||
// annotate the target and index
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-terms-decoratorfactory">
|
||||
<h1>Decorator Factory</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator factory</em> is a function that can accept any number of arguments, and must return one of the above types of decorator function.</p>
|
||||
<pre><code class="typescript">// a class decorator factory function
|
||||
function dec(x, y) {
|
||||
// the class decorator function
|
||||
return function (target) {
|
||||
// modify, annotate, or replace target...
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratortargets">
|
||||
<h1>Decorator Targets</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>A <em>decorator</em> <strong>can</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class declaration</li>
|
||||
<li>A class property initializer (static or prototype)</li>
|
||||
<li>A class method declaration (static or prototype)</li>
|
||||
<li>A class get or set accessor declaration (static or prototype)</li>
|
||||
<li>A parameter of a class constructor</li>
|
||||
<li>A parameter of a class method (static or prototype)</li>
|
||||
<li>A parameter of a class get or set accessor (static or prototype)</li>
|
||||
</ul>
|
||||
<p>Please note that a <em>decorator</em> currently <strong>cannot</strong> be legally applied to any of the following:</p>
|
||||
<ul>
|
||||
<li>A class constructor - This is to reduce ambiguity between where you can apply a decorator (on the class or on its constructor) and which of the above decorator function forms is called.</li>
|
||||
<li>A function declaration - Decorators on a function declaration would introduce a TDZ (Temporal Dead Zone), which would make the function unreachable until its declaration is executed. This could cause confusion as an undecorated function declaration is hoisted and can be used in a statement preceeding the declaration.</li>
|
||||
<li>A function expression - This is to reduce confusion and maintain parity with disallowing decorators on a function declaration.</li>
|
||||
<li>An arrow function - This is to reduce confusion and maintain parity with disallowing decorators on a function expression.</li>
|
||||
</ul>
|
||||
<p>This list may change in the future.</p>
|
||||
</emu-clause>
|
||||
<emu-clause id="proposal-decoratoreval">
|
||||
<h1>Decorator Evaluation and Application Order</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>Decorators are <em>evaluated</em> in the order they appear preceeding their target declaration, to preserve side-effects due to evaluation order. Decorators are <em>applied</em> to their target declaration in reverse order, starting with the decorator closest to the declaration. This behavior is specified to preserve the expected behavior of decorators without a declarative syntax.</p>
|
||||
<pre><code class="typescript">@F
|
||||
@G
|
||||
class C {
|
||||
}
|
||||
</code></pre>
|
||||
<p>For example, the above listing could be approximately written without decorators in the following fashion:</p>
|
||||
<pre><code class="typescript">C = F(G(C))</code></pre>
|
||||
<p>In the above example, the expression <code>F</code> is evaluated first, followed by the expression <code>G</code>. <code>G</code> is then called with the constructor function as its argument, followed by calling <code>F</code> with the result. The actual process of applying decorators is more complex than the above example however, though you may still imperatively apply decorators with a reflection API.</p>
|
||||
<p>If a class declaration has decorators on both the class and any of its members or parameters, the decorators are applied using the following pseudocode:</p>
|
||||
<pre>
|
||||
for each member M of class C
|
||||
if M is an accessor then
|
||||
let accessor = first accessor (get or set, in declaration order) of M
|
||||
let memberDecorators = decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
|
||||
let accessor = second accessor (get or set, in declaration order) of M
|
||||
if accessor then
|
||||
let memberDecorators = memberDecorators + decorators of accessor
|
||||
for each parameter of accessor
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, accessor, paramIndex)
|
||||
next parameter
|
||||
end if
|
||||
else if M is a method
|
||||
let memberDecorators = decorators of M
|
||||
for each parameter of M
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, M, paramIndex)
|
||||
next parameter
|
||||
else
|
||||
let memberDecorators = decorators of M
|
||||
end if
|
||||
|
||||
let name = name of M
|
||||
let target = C.prototype if M is on the prototype; otherwise, C if M is static
|
||||
Reflect.decorate(memberDecorators, C, name)
|
||||
next member
|
||||
|
||||
for each parameter of C
|
||||
let paramDecorators = decorators of parameter
|
||||
let paramIndex = ordinal index of parameter
|
||||
Reflect.decorate(paramDecorators, C, paramIndex)
|
||||
next parameter
|
||||
|
||||
let classDecorators = decorators of C
|
||||
let C = Reflect.decorate(classDecorators, C)
|
||||
</pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="reflect">
|
||||
<h1>Reflect API</h1>
|
||||
<emu-note>This section is non-normative.</emu-note>
|
||||
<p>In addition to a declarative approach to defining decorators, it is necessary to also include an imperative API capable of applying decorators, as well as defining, reflecting over, and removing decorator metadata from an object, property, or parameter.</p>
|
||||
<p>A shim for this API can be found here: <a href="https://github.com/rbuckton/ReflectDecorators">https://github.com/rbuckton/ReflectDecorators</a></p>
|
||||
<pre><code class="typescript">Reflect.decorate(decorators, target, propertyKey?, descriptor?)</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile">
|
||||
<h1>Transformation</h1>
|
||||
<p>The following are examples of how decorators can be desugared to ES6 (through a transpiler such as TypeScript). These examples levarage an imperative reflection API.</p>
|
||||
<emu-clause id="transpile-class">
|
||||
<h1>Class Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">@F("color")
|
||||
@G
|
||||
class C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">let C = class {
|
||||
}
|
||||
Object.defineProperty(C, "name", { value: "C", configurable: true });
|
||||
C = __decorate([F("color"), G], C);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-exportclass">
|
||||
<h1>Class Declaration (Exported)</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">@F("color")
|
||||
@G
|
||||
export class C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">export let C = class {
|
||||
}
|
||||
Object.defineProperty(C, "name", { value: "C", configurable: true });
|
||||
C = __decorate([F("color"), G], C);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-exportdefaultclass">
|
||||
<h1>Class Declaration (Default, Exported)</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">@F("color")
|
||||
@G
|
||||
export default class C {
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">let C = class {
|
||||
}
|
||||
Object.defineProperty(C, "name", { value: "C", configurable: true });
|
||||
C = __decorate([F("color"), G], C);
|
||||
export default C;
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classmethod">
|
||||
<h1>Class Method Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
@F("color")
|
||||
@G
|
||||
method() { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
method() { }
|
||||
}
|
||||
Object.defineProperty(C.prototype, "method",
|
||||
__decorate([F("color"), G], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classaccessor">
|
||||
<h1>Class Accessor Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
@F("color")
|
||||
@G
|
||||
get accessor() { }
|
||||
set accessor(value) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
get accessor() { }
|
||||
set accessor(value) { }
|
||||
}
|
||||
Object.defineProperty(C.prototype, "accessor",
|
||||
__decorate([F("color"), G], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classproperty">
|
||||
<h1>Class Property Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
@F("color")
|
||||
@G
|
||||
property = 1;
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
constructor() {
|
||||
this.property = 1;
|
||||
}
|
||||
}
|
||||
__decorate([F("color"), G], C.prototype, "property");
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classconstructorparameter">
|
||||
<h1>Class Constructor Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
constructor(@F("color") @G p) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
constructor(p) { }
|
||||
}
|
||||
__decorate([F("color"), G], C, void 0, 0);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classmethodparameter">
|
||||
<h1>Class Method Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
method(@F("color") @G p) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
method(p) { }
|
||||
}
|
||||
__decorate([F("color"), G], C.prototype, "method", 0);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
<emu-clause id="transpile-classaccessorparameter">
|
||||
<h1>Class Set Accessor Parameter Declaration</h1>
|
||||
<h2>Syntax</h2>
|
||||
<pre><code class="typescript">class C {
|
||||
set accessor(@F("color") @G p) { }
|
||||
}
|
||||
</code></pre>
|
||||
<h2>ES6 Transformation</h2>
|
||||
<pre><code class="javascript">class C {
|
||||
set accessor(p) { }
|
||||
}
|
||||
__decorate([F("color"), G], C.prototype, "accessor", 0);
|
||||
</code></pre>
|
||||
</emu-clause>
|
||||
|
||||
</emu-clause>
|
||||
|
||||
<emu-annex id="grammar">
|
||||
<h1>Grammar</h1>
|
||||
<emu-annex id="grammar-expressions">
|
||||
<h1>Expressions</h1>
|
||||
<emu-production id="grammar-memberexpression" name="MemberExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield">PrimaryExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression</emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-t>.</emu-t><emu-nt>IdentifierName</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-nt params="?Yield">TemplateLiteral</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">SuperProperty</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>MetaProperty</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt><emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-superproperty" name="SuperProperty" params="Yield, Decorator">
|
||||
<emu-rhs constraints="~Decorator"><emu-t>super</emu-t><emu-t>[</emu-t><emu-nt params="In, ?Yield">Expression</emu-nt><emu-t>]</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-newexpression" name="NewExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>new</emu-t><emu-nt params="?Yield, ?Decorator">NewExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-callexpression" name="CallExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">MemberExpression</emu-nt> <emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield">SuperCall</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-nt params="?Yield">Arguments</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="~Decorator"><emu-nt params="?Yield">CallExpression</emu-nt> <emu-t>[</emu-t> <emu-nt params="In, ?Yield">Expression</emu-nt> <emu-t>]</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-t>.</emu-t> <emu-nt>IdentifierName</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt> <emu-nt params="?Yield">TemplateLiteral</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-lefthandsideexpression" name="LeftHandSideExpression" params="Yield, Decorator">
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">NewExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?Decorator">CallExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="functions-and-classes">
|
||||
<h1>Functions and Classes</h1>
|
||||
<emu-production id="grammar-strictformalparameters" name="StrictFormalParameters" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameters</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameters" name="FormalParameters" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-rhs><emu-prose>[empty]</emu-prose></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameterList</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameterlist" name="FormalParameterList" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield, ?ClassParameter">FunctionRestParameter</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList</emu-nt><emu-t>,</emu-t><emu-nt params="?Yield, ?ClassParameter">FunctionRestParameter</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalslist" name="FormalsList" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameter</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalsList</emu-nt><emu-t>,</emu-t><emu-nt params="?Yield, ?GeneratorParameter, ?ClassParameter">FormalParameter</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-functionrestparameter" name="FunctionRestParameter" params="Yield, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield">BindingRestElement</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+ClassParameter"><emu-nt>DecoratorList</emu-nt><emu-nt params="?Yield">BindingRestElement</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-formalparameter" name="FormalParameter" params="Yield, GeneratorParameter, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield, ?GeneratorParameter">BindingElement</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+ClassParameter"><emu-nt>DecoratorList</emu-nt><emu-nt params="?Yield, ?GeneratorParameter">BindingElement</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-methoddefinition" name="MethodDefinition" params="Yield, ClassParameter">
|
||||
<emu-rhs><emu-nt params="?Yield">PropertyName</emu-nt> <emu-t>(</emu-t> <emu-nt params="?ClassParameter">StrictFormalParameters</emu-nt> <emu-t>)</emu-t> <emu-t>{</emu-t> <emu-nt>FunctionBody</emu-nt> <emu-t>}</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield, ?ClassParameter">GeneratorMethod</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>get</emu-t><emu-nt params="?Yield">PropertyName</emu-nt> <emu-t>(</emu-t> <emu-t>)</emu-t> <emu-t>{</emu-t> <emu-nt>FunctionBody</emu-nt> <emu-t>}</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>set</emu-t><emu-nt params="?Yield">PropertyName</emu-nt> <emu-t>(</emu-t> <emu-nt params="?ClassParameter">PropertySetParameterList</emu-nt> <emu-t>)</emu-t> <emu-t>{</emu-t> <emu-nt>FunctionBody</emu-nt> <emu-t>}</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-generatormethod" name="GeneratorMethod" params="Yield, ClassParameter">
|
||||
<emu-rhs><emu-t>*</emu-t><emu-nt params="?Yield">PropertyName</emu-nt> <emu-t>(</emu-t> <emu-nt params="Yield, GeneratorParameter, ?ClassParameter">StrictFormalParameters</emu-nt> <emu-t>)</emu-t> <emu-t>{</emu-t> <emu-nt>GeneratorBody</emu-nt> <emu-t>}</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classdeclaration" name="ClassDeclaration" params="Yield, Default">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield">BindingIdentifier</emu-nt> <emu-nt params="?Yield">ClassTail</emu-nt></emu-rhs>
|
||||
<emu-rhs constraints="+Default"><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield">ClassTail</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classexpression" name="ClassExpression" params="Yield, GeneratorParameter">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>class</emu-t> <emu-nt params="?Yield" optional>BindingIdentifier</emu-nt> <emu-nt params="?Yield, ?GeneratorParameter">ClassTail</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-classelement" name="ClassElement" params="Yield">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-nt params="ClassParameter, ?Yield">MethodDefinition</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t>static</emu-t> <emu-nt params="ClassParameter, ?Yield">MethodDefinition</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-t optional>static</emu-t> <emu-nt>PropertyName</emu-nt> <emu-nt params="In, ?Yield" optional>Initializer</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>;</emu-t></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decoratorlist" name="DecoratorList" params="Yield">
|
||||
<emu-rhs><emu-nt params="?Yield" optional>DecoratorList</emu-nt> <emu-nt params="?Yield">Decorator</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
<emu-production id="grammar-decorator" name="Decorator" params="Yield">
|
||||
<emu-rhs><emu-t>@</emu-t> <emu-nt params="Decorator, ?Yield">LeftHandSideExpression</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
|
||||
<emu-annex id="scripts-and-modules">
|
||||
<h1>Scripts and Modules</h1>
|
||||
<emu-production id="grammar-exportdeclaration" name="ExportDeclaration">
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>*</emu-t> <emu-nt>FromClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>ExportClause</emu-nt> <emu-nt>FromClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>ExportClause</emu-nt> <emu-t>;</emu-t></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-nt>VariableStatement</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt>Declaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-nt params="Default">HoistableDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt params="Default">ClassDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ∉ { <emu-t>function</emu-t>, <emu-t>class</emu-t>, <emu-t>@</emu-t> }</emu-gann> <emu-nt>AssignmentExpression</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList</emu-nt> <emu-t>export</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt>ClassDeclaration</emu-nt></emu-rhs>
|
||||
<emu-rhs><emu-nt>DecoratorList</emu-nt> <emu-t>export</emu-t> <emu-t>default</emu-t> <emu-gann>lookahead ≠ <emu-t>@</emu-t></emu-gann> <emu-nt params="Default">ClassDeclaration</emu-nt></emu-rhs>
|
||||
</emu-production>
|
||||
</emu-annex>
|
||||
</emu-annex>
|
||||
<emu-annex id="typescript">
|
||||
<h1>TypeScript</h1>
|
||||
<emu-annex id="typescript-definitions">
|
||||
<h1>TypeScript Definitions</h1>
|
||||
<pre><code class="typescript">interface TypedPropertyDescriptor<T> {
|
||||
enumerable?: boolean;
|
||||
configurable?: boolean;
|
||||
writable?: boolean;
|
||||
value?: T;
|
||||
get?: () => T;
|
||||
set?: (value: T) => void;
|
||||
}
|
||||
|
||||
type ClassDecorator = <TFunction extends Function>(target: TFunction): TFunction | void;
|
||||
type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void;
|
||||
type PropertyDecorator = (target: Object, propertyKey: string | symbol): void;
|
||||
type ParameterDecorator = (target: Object, propertyKey: string | symbol, parameterIndex: number): void;
|
||||
</code></pre>
|
||||
</emu-annex>
|
||||
</emu-annex>
|
964
node_modules/reflect-metadata/temp/Reflect.js
generated
vendored
Normal file
964
node_modules/reflect-metadata/temp/Reflect.js
generated
vendored
Normal file
@ -0,0 +1,964 @@
|
||||
/*! *****************************************************************************
|
||||
Copyright (C) Microsoft. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
***************************************************************************** */
|
||||
"use strict";
|
||||
var Reflect;
|
||||
(function (Reflect) {
|
||||
// Load global or shim versions of Map, Set, and WeakMap
|
||||
var functionPrototype = Object.getPrototypeOf(Function);
|
||||
var _Map = typeof Map === "function" ? Map : CreateMapPolyfill();
|
||||
var _Set = typeof Set === "function" ? Set : CreateSetPolyfill();
|
||||
var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
|
||||
// [[Metadata]] internal slot
|
||||
var __Metadata__ = new _WeakMap();
|
||||
/**
|
||||
* Applies a set of decorators to a property of a target object.
|
||||
* @param decorators An array of decorators.
|
||||
* @param target The target object.
|
||||
* @param targetKey (Optional) The property key to decorate.
|
||||
* @param targetDescriptor (Optional) The property descriptor for the target key
|
||||
* @remarks Decorators are applied in reverse order.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* C = Reflect.decorate(decoratorsArray, C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* Reflect.decorate(decoratorsArray, C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* Reflect.decorate(decoratorsArray, C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* Object.defineProperty(C, "staticMethod",
|
||||
* Reflect.decorate(decoratorsArray, C, "staticMethod",
|
||||
* Object.getOwnPropertyDescriptor(C, "staticMethod")));
|
||||
*
|
||||
* // method (on prototype)
|
||||
* Object.defineProperty(C.prototype, "method",
|
||||
* Reflect.decorate(decoratorsArray, C.prototype, "method",
|
||||
* Object.getOwnPropertyDescriptor(C.prototype, "method")));
|
||||
*
|
||||
*/
|
||||
function decorate(decorators, target, targetKey, targetDescriptor) {
|
||||
if (!IsUndefined(targetDescriptor)) {
|
||||
if (!IsArray(decorators)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (IsUndefined(targetKey)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsObject(targetDescriptor)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
return DecoratePropertyWithDescriptor(decorators, target, targetKey, targetDescriptor);
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
if (!IsArray(decorators)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
return DecoratePropertyWithoutDescriptor(decorators, target, targetKey);
|
||||
}
|
||||
else {
|
||||
if (!IsArray(decorators)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsConstructor(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
return DecorateConstructor(decorators, target);
|
||||
}
|
||||
}
|
||||
Reflect.decorate = decorate;
|
||||
/**
|
||||
* A default metadata decorator factory that can be used on a class, class member, or parameter.
|
||||
* @param metadataKey The key for the metadata entry.
|
||||
* @param metadataValue The value for the metadata entry.
|
||||
* @returns A decorator function.
|
||||
* @remarks
|
||||
* If `metadataKey` is already defined for the target and target key, the
|
||||
* metadataValue for that key will be overwritten.
|
||||
* @example
|
||||
*
|
||||
* // constructor
|
||||
* @Reflect.metadata(key, value)
|
||||
* class C {
|
||||
* }
|
||||
*
|
||||
* // property (on constructor, TypeScript only)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* static staticProperty;
|
||||
* }
|
||||
*
|
||||
* // property (on prototype, TypeScript only)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* property;
|
||||
* }
|
||||
*
|
||||
* // method (on constructor)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* static staticMethod() { }
|
||||
* }
|
||||
*
|
||||
* // method (on prototype)
|
||||
* class C {
|
||||
* @Reflect.metadata(key, value)
|
||||
* method() { }
|
||||
* }
|
||||
*
|
||||
*/
|
||||
function metadata(metadataKey, metadataValue) {
|
||||
function decorator(target, targetKey) {
|
||||
if (!IsUndefined(targetKey)) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);
|
||||
}
|
||||
else {
|
||||
if (!IsConstructor(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, undefined);
|
||||
}
|
||||
}
|
||||
return decorator;
|
||||
}
|
||||
Reflect.metadata = metadata;
|
||||
/**
|
||||
* Define a unique metadata entry on the target.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param metadataValue A value that contains attached metadata.
|
||||
* @param target The target object on which to define metadata.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* Reflect.defineMetadata("custom:annotation", options, C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* Reflect.defineMetadata("custom:annotation", options, C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* Reflect.defineMetadata("custom:annotation", options, C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* Reflect.defineMetadata("custom:annotation", options, C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* Reflect.defineMetadata("custom:annotation", options, C.prototype, "method");
|
||||
*
|
||||
* // decorator factory as metadata-producing annotation.
|
||||
* function MyAnnotation(options): Decorator {
|
||||
* return (target, key?) => Reflect.defineMetadata("custom:annotation", options, target, key);
|
||||
* }
|
||||
*
|
||||
*/
|
||||
function defineMetadata(metadataKey, metadataValue, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey);
|
||||
}
|
||||
Reflect.defineMetadata = defineMetadata;
|
||||
/**
|
||||
* Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.hasMetadata("custom:annotation", C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.hasMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function hasMetadata(metadataKey, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryHasMetadata(metadataKey, target, targetKey);
|
||||
}
|
||||
Reflect.hasMetadata = hasMetadata;
|
||||
/**
|
||||
* Gets a value indicating whether the target object has the provided metadata key defined.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns `true` if the metadata key was defined on the target object; otherwise, `false`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function hasOwnMetadata(metadataKey, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryHasOwnMetadata(metadataKey, target, targetKey);
|
||||
}
|
||||
Reflect.hasOwnMetadata = hasOwnMetadata;
|
||||
/**
|
||||
* Gets the metadata value for the provided metadata key on the target object or its prototype chain.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getMetadata("custom:annotation", C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getMetadata(metadataKey, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryGetMetadata(metadataKey, target, targetKey);
|
||||
}
|
||||
Reflect.getMetadata = getMetadata;
|
||||
/**
|
||||
* Gets the metadata value for the provided metadata key on the target object.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns The metadata value for the metadata key if found; otherwise, `undefined`.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getOwnMetadata(metadataKey, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryGetOwnMetadata(metadataKey, target, targetKey);
|
||||
}
|
||||
Reflect.getOwnMetadata = getOwnMetadata;
|
||||
/**
|
||||
* Gets the metadata keys defined on the target object or its prototype chain.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns An array of unique metadata keys.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getMetadataKeys(C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getMetadataKeys(C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getMetadataKeys(C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getMetadataKeys(C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getMetadataKeys(C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getMetadataKeys(target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryMetadataKeys(target, targetKey);
|
||||
}
|
||||
Reflect.getMetadataKeys = getMetadataKeys;
|
||||
/**
|
||||
* Gets the unique metadata keys defined on the target object.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns An array of unique metadata keys.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.getOwnMetadataKeys(C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.getOwnMetadataKeys(C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.getOwnMetadataKeys(C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.getOwnMetadataKeys(C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.getOwnMetadataKeys(C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function getOwnMetadataKeys(target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
return OrdinaryOwnMetadataKeys(target, targetKey);
|
||||
}
|
||||
Reflect.getOwnMetadataKeys = getOwnMetadataKeys;
|
||||
/**
|
||||
* Deletes the metadata entry from the target object with the provided key.
|
||||
* @param metadataKey A key used to store and retrieve metadata.
|
||||
* @param target The target object on which the metadata is defined.
|
||||
* @param targetKey (Optional) The property key for the target.
|
||||
* @returns `true` if the metadata entry was found and deleted; otherwise, false.
|
||||
* @example
|
||||
*
|
||||
* class C {
|
||||
* // property declarations are not part of ES6, though they are valid in TypeScript:
|
||||
* // static staticProperty;
|
||||
* // property;
|
||||
*
|
||||
* constructor(p) { }
|
||||
* static staticMethod(p) { }
|
||||
* method(p) { }
|
||||
* }
|
||||
*
|
||||
* // constructor
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C);
|
||||
*
|
||||
* // property (on constructor)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C, "staticProperty");
|
||||
*
|
||||
* // property (on prototype)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C.prototype, "property");
|
||||
*
|
||||
* // method (on constructor)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C, "staticMethod");
|
||||
*
|
||||
* // method (on prototype)
|
||||
* result = Reflect.deleteMetadata("custom:annotation", C.prototype, "method");
|
||||
*
|
||||
*/
|
||||
function deleteMetadata(metadataKey, target, targetKey) {
|
||||
if (!IsObject(target)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
else if (!IsUndefined(targetKey)) {
|
||||
targetKey = ToPropertyKey(targetKey);
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#deletemetadata-metadatakey-p-
|
||||
var metadataMap = GetOrCreateMetadataMap(target, targetKey, false);
|
||||
if (IsUndefined(metadataMap)) {
|
||||
return false;
|
||||
}
|
||||
if (!metadataMap.delete(metadataKey)) {
|
||||
return false;
|
||||
}
|
||||
if (metadataMap.size > 0) {
|
||||
return true;
|
||||
}
|
||||
var targetMetadata = __Metadata__.get(target);
|
||||
targetMetadata.delete(targetKey);
|
||||
if (targetMetadata.size > 0) {
|
||||
return true;
|
||||
}
|
||||
__Metadata__.delete(target);
|
||||
return true;
|
||||
}
|
||||
Reflect.deleteMetadata = deleteMetadata;
|
||||
function DecorateConstructor(decorators, target) {
|
||||
for (var i = decorators.length - 1; i >= 0; --i) {
|
||||
var decorator = decorators[i];
|
||||
var decorated = decorator(target);
|
||||
if (!IsUndefined(decorated)) {
|
||||
if (!IsConstructor(decorated)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
target = decorated;
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
function DecoratePropertyWithDescriptor(decorators, target, propertyKey, descriptor) {
|
||||
for (var i = decorators.length - 1; i >= 0; --i) {
|
||||
var decorator = decorators[i];
|
||||
var decorated = decorator(target, propertyKey, descriptor);
|
||||
if (!IsUndefined(decorated)) {
|
||||
if (!IsObject(decorated)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
descriptor = decorated;
|
||||
}
|
||||
}
|
||||
return descriptor;
|
||||
}
|
||||
function DecoratePropertyWithoutDescriptor(decorators, target, propertyKey) {
|
||||
for (var i = decorators.length - 1; i >= 0; --i) {
|
||||
var decorator = decorators[i];
|
||||
decorator(target, propertyKey);
|
||||
}
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#getorcreatemetadatamap--o-p-create-
|
||||
function GetOrCreateMetadataMap(target, targetKey, create) {
|
||||
var targetMetadata = __Metadata__.get(target);
|
||||
if (!targetMetadata) {
|
||||
if (!create) {
|
||||
return undefined;
|
||||
}
|
||||
targetMetadata = new _Map();
|
||||
__Metadata__.set(target, targetMetadata);
|
||||
}
|
||||
var keyMetadata = targetMetadata.get(targetKey);
|
||||
if (!keyMetadata) {
|
||||
if (!create) {
|
||||
return undefined;
|
||||
}
|
||||
keyMetadata = new _Map();
|
||||
targetMetadata.set(targetKey, keyMetadata);
|
||||
}
|
||||
return keyMetadata;
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasmetadata--metadatakey-o-p-
|
||||
function OrdinaryHasMetadata(MetadataKey, O, P) {
|
||||
var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
|
||||
if (hasOwn) {
|
||||
return true;
|
||||
}
|
||||
var parent = GetPrototypeOf(O);
|
||||
if (parent !== null) {
|
||||
return OrdinaryHasMetadata(MetadataKey, parent, P);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasownmetadata--metadatakey-o-p-
|
||||
function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
|
||||
var metadataMap = GetOrCreateMetadataMap(O, P, false);
|
||||
if (metadataMap === undefined) {
|
||||
return false;
|
||||
}
|
||||
return Boolean(metadataMap.has(MetadataKey));
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetmetadata--metadatakey-o-p-
|
||||
function OrdinaryGetMetadata(MetadataKey, O, P) {
|
||||
var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);
|
||||
if (hasOwn) {
|
||||
return OrdinaryGetOwnMetadata(MetadataKey, O, P);
|
||||
}
|
||||
var parent = GetPrototypeOf(O);
|
||||
if (parent !== null) {
|
||||
return OrdinaryGetMetadata(MetadataKey, parent, P);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetownmetadata--metadatakey-o-p-
|
||||
function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
|
||||
var metadataMap = GetOrCreateMetadataMap(O, P, false);
|
||||
if (metadataMap === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return metadataMap.get(MetadataKey);
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarydefineownmetadata--metadatakey-metadatavalue-o-p-
|
||||
function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
|
||||
var metadataMap = GetOrCreateMetadataMap(O, P, true);
|
||||
metadataMap.set(MetadataKey, MetadataValue);
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarymetadatakeys--o-p-
|
||||
function OrdinaryMetadataKeys(O, P) {
|
||||
var ownKeys = OrdinaryOwnMetadataKeys(O, P);
|
||||
var parent = GetPrototypeOf(O);
|
||||
if (parent === null) {
|
||||
return ownKeys;
|
||||
}
|
||||
var parentKeys = OrdinaryMetadataKeys(parent, P);
|
||||
if (parentKeys.length <= 0) {
|
||||
return ownKeys;
|
||||
}
|
||||
if (ownKeys.length <= 0) {
|
||||
return parentKeys;
|
||||
}
|
||||
var set = new _Set();
|
||||
var keys = [];
|
||||
for (var _i = 0; _i < ownKeys.length; _i++) {
|
||||
var key = ownKeys[_i];
|
||||
var hasKey = set.has(key);
|
||||
if (!hasKey) {
|
||||
set.add(key);
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
for (var _a = 0; _a < parentKeys.length; _a++) {
|
||||
var key = parentKeys[_a];
|
||||
var hasKey = set.has(key);
|
||||
if (!hasKey) {
|
||||
set.add(key);
|
||||
keys.push(key);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
// https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryownmetadatakeys--o-p-
|
||||
function OrdinaryOwnMetadataKeys(target, targetKey) {
|
||||
var metadataMap = GetOrCreateMetadataMap(target, targetKey, false);
|
||||
var keys = [];
|
||||
if (metadataMap) {
|
||||
metadataMap.forEach(function (_, key) { return keys.push(key); });
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-undefined-type
|
||||
function IsUndefined(x) {
|
||||
return x === undefined;
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray
|
||||
function IsArray(x) {
|
||||
return Array.isArray(x);
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-type
|
||||
function IsObject(x) {
|
||||
return typeof x === "object" ? x !== null : typeof x === "function";
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor
|
||||
function IsConstructor(x) {
|
||||
return typeof x === "function";
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-symbol-type
|
||||
function IsSymbol(x) {
|
||||
return typeof x === "symbol";
|
||||
}
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey
|
||||
function ToPropertyKey(value) {
|
||||
if (IsSymbol(value)) {
|
||||
return value;
|
||||
}
|
||||
return String(value);
|
||||
}
|
||||
function GetPrototypeOf(O) {
|
||||
var proto = Object.getPrototypeOf(O);
|
||||
if (typeof O !== "function" || O === functionPrototype) {
|
||||
return proto;
|
||||
}
|
||||
// TypeScript doesn't set __proto__ in ES5, as it's non-standard.
|
||||
// Try to determine the superclass constructor. Compatible implementations
|
||||
// must either set __proto__ on a subclass constructor to the superclass constructor,
|
||||
// or ensure each class has a valid `constructor` property on its prototype that
|
||||
// points back to the constructor.
|
||||
// If this is not the same as Function.[[Prototype]], then this is definately inherited.
|
||||
// This is the case when in ES6 or when using __proto__ in a compatible browser.
|
||||
if (proto !== functionPrototype) {
|
||||
return proto;
|
||||
}
|
||||
// If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.
|
||||
var prototype = O.prototype;
|
||||
var prototypeProto = Object.getPrototypeOf(prototype);
|
||||
if (prototypeProto == null || prototypeProto === Object.prototype) {
|
||||
return proto;
|
||||
}
|
||||
// if the constructor was not a function, then we cannot determine the heritage.
|
||||
var constructor = prototypeProto.constructor;
|
||||
if (typeof constructor !== "function") {
|
||||
return proto;
|
||||
}
|
||||
// if we have some kind of self-reference, then we cannot determine the heritage.
|
||||
if (constructor === O) {
|
||||
return proto;
|
||||
}
|
||||
// we have a pretty good guess at the heritage.
|
||||
return constructor;
|
||||
}
|
||||
// naive Map shim
|
||||
function CreateMapPolyfill() {
|
||||
var cacheSentinel = {};
|
||||
function Map() {
|
||||
this._keys = [];
|
||||
this._values = [];
|
||||
this._cache = cacheSentinel;
|
||||
}
|
||||
Map.prototype = {
|
||||
get size() {
|
||||
return this._keys.length;
|
||||
},
|
||||
has: function (key) {
|
||||
if (key === this._cache) {
|
||||
return true;
|
||||
}
|
||||
if (this._find(key) >= 0) {
|
||||
this._cache = key;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
get: function (key) {
|
||||
var index = this._find(key);
|
||||
if (index >= 0) {
|
||||
this._cache = key;
|
||||
return this._values[index];
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
set: function (key, value) {
|
||||
this.delete(key);
|
||||
this._keys.push(key);
|
||||
this._values.push(value);
|
||||
this._cache = key;
|
||||
return this;
|
||||
},
|
||||
delete: function (key) {
|
||||
var index = this._find(key);
|
||||
if (index >= 0) {
|
||||
this._keys.splice(index, 1);
|
||||
this._values.splice(index, 1);
|
||||
this._cache = cacheSentinel;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
clear: function () {
|
||||
this._keys.length = 0;
|
||||
this._values.length = 0;
|
||||
this._cache = cacheSentinel;
|
||||
},
|
||||
forEach: function (callback, thisArg) {
|
||||
var size = this.size;
|
||||
for (var i = 0; i < size; ++i) {
|
||||
var key = this._keys[i];
|
||||
var value = this._values[i];
|
||||
this._cache = key;
|
||||
callback.call(this, value, key, this);
|
||||
}
|
||||
},
|
||||
_find: function (key) {
|
||||
var keys = this._keys;
|
||||
var size = keys.length;
|
||||
for (var i = 0; i < size; ++i) {
|
||||
if (keys[i] === key) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
return Map;
|
||||
}
|
||||
// naive Set shim
|
||||
function CreateSetPolyfill() {
|
||||
var cacheSentinel = {};
|
||||
function Set() {
|
||||
this._map = new _Map();
|
||||
}
|
||||
Set.prototype = {
|
||||
get size() {
|
||||
return this._map.length;
|
||||
},
|
||||
has: function (value) {
|
||||
return this._map.has(value);
|
||||
},
|
||||
add: function (value) {
|
||||
this._map.set(value, value);
|
||||
return this;
|
||||
},
|
||||
delete: function (value) {
|
||||
return this._map.delete(value);
|
||||
},
|
||||
clear: function () {
|
||||
this._map.clear();
|
||||
},
|
||||
forEach: function (callback, thisArg) {
|
||||
this._map.forEach(callback, thisArg);
|
||||
}
|
||||
};
|
||||
return Set;
|
||||
}
|
||||
// naive WeakMap shim
|
||||
function CreateWeakMapPolyfill() {
|
||||
var UUID_SIZE = 16;
|
||||
var isNode = typeof global !== "undefined" &&
|
||||
typeof module === "object" &&
|
||||
typeof module.exports === "object" &&
|
||||
typeof require === "function";
|
||||
var nodeCrypto = isNode && require("crypto");
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
||||
var keys = {};
|
||||
var rootKey = CreateUniqueKey();
|
||||
function WeakMap() {
|
||||
this._key = CreateUniqueKey();
|
||||
}
|
||||
WeakMap.prototype = {
|
||||
has: function (target) {
|
||||
var table = GetOrCreateWeakMapTable(target, false);
|
||||
if (table) {
|
||||
return this._key in table;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
get: function (target) {
|
||||
var table = GetOrCreateWeakMapTable(target, false);
|
||||
if (table) {
|
||||
return table[this._key];
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
set: function (target, value) {
|
||||
var table = GetOrCreateWeakMapTable(target, true);
|
||||
table[this._key] = value;
|
||||
return this;
|
||||
},
|
||||
delete: function (target) {
|
||||
var table = GetOrCreateWeakMapTable(target, false);
|
||||
if (table && this._key in table) {
|
||||
return delete table[this._key];
|
||||
}
|
||||
return false;
|
||||
},
|
||||
clear: function () {
|
||||
// NOTE: not a real clear, just makes the previous data unreachable
|
||||
this._key = CreateUniqueKey();
|
||||
}
|
||||
};
|
||||
function FillRandomBytes(buffer, size) {
|
||||
for (var i = 0; i < size; ++i) {
|
||||
buffer[i] = Math.random() * 255 | 0;
|
||||
}
|
||||
}
|
||||
function GenRandomBytes(size) {
|
||||
if (nodeCrypto) {
|
||||
var data = nodeCrypto.randomBytes(size);
|
||||
return data;
|
||||
}
|
||||
else if (typeof Uint8Array === "function") {
|
||||
var data = new Uint8Array(size);
|
||||
if (typeof crypto !== "undefined") {
|
||||
crypto.getRandomValues(data);
|
||||
}
|
||||
else if (typeof msCrypto !== "undefined") {
|
||||
msCrypto.getRandomValues(data);
|
||||
}
|
||||
else {
|
||||
FillRandomBytes(data, size);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
else {
|
||||
var data = new Array(size);
|
||||
FillRandomBytes(data, size);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
function CreateUUID() {
|
||||
var data = GenRandomBytes(UUID_SIZE);
|
||||
// mark as random - RFC 4122 § 4.4
|
||||
data[6] = data[6] & 0x4f | 0x40;
|
||||
data[8] = data[8] & 0xbf | 0x80;
|
||||
var result = "";
|
||||
for (var offset = 0; offset < UUID_SIZE; ++offset) {
|
||||
var byte = data[offset];
|
||||
if (offset === 4 || offset === 6 || offset === 8) {
|
||||
result += "-";
|
||||
}
|
||||
if (byte < 16) {
|
||||
result += "0";
|
||||
}
|
||||
result += byte.toString(16).toLowerCase();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function CreateUniqueKey() {
|
||||
var key;
|
||||
do {
|
||||
key = "@@WeakMap@@" + CreateUUID();
|
||||
} while (hasOwn.call(keys, key));
|
||||
keys[key] = true;
|
||||
return key;
|
||||
}
|
||||
function GetOrCreateWeakMapTable(target, create) {
|
||||
if (!hasOwn.call(target, rootKey)) {
|
||||
if (!create) {
|
||||
return undefined;
|
||||
}
|
||||
Object.defineProperty(target, rootKey, { value: Object.create(null) });
|
||||
}
|
||||
return target[rootKey];
|
||||
}
|
||||
return WeakMap;
|
||||
}
|
||||
// hook global Reflect
|
||||
(function (__global) {
|
||||
if (typeof __global.Reflect !== "undefined") {
|
||||
if (__global.Reflect !== Reflect) {
|
||||
for (var p in Reflect) {
|
||||
__global.Reflect[p] = Reflect[p];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
__global.Reflect = Reflect;
|
||||
}
|
||||
})(typeof window !== "undefined" ? window :
|
||||
typeof WorkerGlobalScope !== "undefined" ? self :
|
||||
typeof global !== "undefined" ? global :
|
||||
Function("return this;")());
|
||||
})(Reflect || (Reflect = {}));
|
||||
//# sourceMappingURL=Reflect.js.map
|
1
node_modules/reflect-metadata/temp/Reflect.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/Reflect.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
36
node_modules/reflect-metadata/temp/test/harness.js
generated
vendored
Normal file
36
node_modules/reflect-metadata/temp/test/harness.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
function runTests(fixture) {
|
||||
var results = { passed: [], failed: [] };
|
||||
for (var testName in fixture) {
|
||||
var test = fixture[testName];
|
||||
if (typeof test === "function") {
|
||||
try {
|
||||
test();
|
||||
results.passed.push(testName);
|
||||
}
|
||||
catch (e) {
|
||||
results.failed.push([testName, e]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
exports.runTests = runTests;
|
||||
function printResults(results) {
|
||||
for (var _i = 0, _a = results.failed; _i < _a.length; _i++) {
|
||||
var _b = _a[_i], testName = _b[0], error = _b[1];
|
||||
var message_1 = "stack" in error ? error.stack : String(error);
|
||||
console.error(testName + " failed.\n" + message_1);
|
||||
}
|
||||
var passedCount = results.passed.length;
|
||||
var failedCount = results.failed.length;
|
||||
var totalCount = passedCount + failedCount;
|
||||
var message = "Run " + (failedCount > 0 ? "failed" : "succeeded") + ": passed: " + passedCount + ", failed: " + failedCount + ", total: " + totalCount + ".";
|
||||
if (results.failed.length) {
|
||||
console.error(message);
|
||||
}
|
||||
else {
|
||||
console.log(message);
|
||||
}
|
||||
}
|
||||
exports.printResults = printResults;
|
||||
//# sourceMappingURL=harness.js.map
|
1
node_modules/reflect-metadata/temp/test/harness.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/harness.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"harness.js","sourceRoot":"","sources":["../../test/harness.ts"],"names":["runTests","printResults"],"mappings":"AAKA,kBAAyB,OAAY;IACjCA,IAAIA,OAAOA,GAAgBA,EAAEA,MAAMA,EAAEA,EAAEA,EAAEA,MAAMA,EAAEA,EAAEA,EAAEA,CAACA;IACtDA,GAAGA,CAACA,CAACA,GAAGA,CAACA,QAAQA,IAAIA,OAAOA,CAACA,CAACA,CAACA;QAC3BA,IAAIA,IAAIA,GAAGA,OAAOA,CAACA,QAAQA,CAACA,CAACA;QAC7BA,EAAEA,CAACA,CAACA,OAAOA,IAAIA,KAAKA,UAAUA,CAACA,CAACA,CAACA;YAC7BA,IAAIA,CAACA;gBACDA,IAAIA,EAAEA,CAACA;gBACPA,OAAOA,CAACA,MAAMA,CAACA,IAAIA,CAACA,QAAQA,CAACA,CAACA;YAClCA,CACAA;YAAAA,KAAKA,CAACA,CAACA,CAACA,CAACA,CAACA,CAACA;gBACPA,OAAOA,CAACA,MAAMA,CAACA,IAAIA,CAACA,CAACA,QAAQA,EAAEA,CAACA,CAACA,CAACA,CAACA;YACvCA,CAACA;QACLA,CAACA;IACLA,CAACA;IACDA,MAAMA,CAACA,OAAOA,CAACA;AACnBA,CAACA;AAfe,gBAAQ,WAevB,CAAA;AAED,sBAA6B,OAAoB;IAC7CC,GAAGA,CAACA,CAA0BA,UAAcA,EAAdA,KAAAA,OAAOA,CAACA,MAAMA,EAAvCA,cAAqBA,EAArBA,IAAuCA,CAACA;QAAxCA,iBAAKA,QAAQA,UAAEA,KAAKA,QAACA;QACtBA,IAAIA,SAAOA,GAAGA,OAAOA,IAAIA,KAAKA,GAAGA,KAAKA,CAACA,KAAKA,GAAGA,MAAMA,CAACA,KAAKA,CAACA,CAACA;QAC7DA,OAAOA,CAACA,KAAKA,CAAIA,QAAQA,kBAAaA,SAASA,CAACA,CAACA;KACpDA;IAEDA,IAAIA,WAAWA,GAAGA,OAAOA,CAACA,MAAMA,CAACA,MAAMA,CAACA;IACxCA,IAAIA,WAAWA,GAAGA,OAAOA,CAACA,MAAMA,CAACA,MAAMA,CAACA;IACxCA,IAAIA,UAAUA,GAAGA,WAAWA,GAAGA,WAAWA,CAACA;IAE3CA,IAAIA,OAAOA,GAAGA,UAAOA,WAAWA,GAAGA,CAACA,GAAGA,QAAQA,GAAGA,WAAWA,mBAAcA,WAAWA,kBAAaA,WAAWA,iBAAYA,UAAUA,MAAGA,CAACA;IACxIA,EAAEA,CAACA,CAACA,OAAOA,CAACA,MAAMA,CAACA,MAAMA,CAACA,CAACA,CAACA;QACxBA,OAAOA,CAACA,KAAKA,CAACA,OAAOA,CAACA,CAACA;IAC3BA,CAACA;IACDA,IAAIA,CAACA,CAACA;QACFA,OAAOA,CAACA,GAAGA,CAACA,OAAOA,CAACA,CAACA;IACzBA,CAACA;AACLA,CAACA;AAjBe,oBAAY,eAiB3B,CAAA"}
|
208
node_modules/reflect-metadata/temp/test/reflect/reflect-decorate.js
generated
vendored
Normal file
208
node_modules/reflect-metadata/temp/test/reflect/reflect-decorate.js
generated
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
// Reflect.decorate ( decorators, target [, propertyKey [, descriptor] ] )
|
||||
require("../../Reflect");
|
||||
var assert = require("assert");
|
||||
function ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForFunctionOverload() {
|
||||
var target = function () { };
|
||||
assert.throws(function () { return Reflect.decorate(undefined, target, undefined, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForFunctionOverload = ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForFunctionOverload;
|
||||
function ReflectDecorateThrowsIfTargetArgumentNotFunctionForFunctionOverload() {
|
||||
var decorators = [];
|
||||
var target = {};
|
||||
assert.throws(function () { return Reflect.decorate(decorators, target, undefined, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectDecorateThrowsIfTargetArgumentNotFunctionForFunctionOverload = ReflectDecorateThrowsIfTargetArgumentNotFunctionForFunctionOverload;
|
||||
function ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForPropertyOverload() {
|
||||
var target = {};
|
||||
var name = "name";
|
||||
assert.throws(function () { return Reflect.decorate(undefined, target, name, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForPropertyOverload = ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForPropertyOverload;
|
||||
function ReflectDecorateThrowsIfTargetArgumentNotObjectForPropertyOverload() {
|
||||
var decorators = [];
|
||||
var target = 1;
|
||||
var name = "name";
|
||||
assert.throws(function () { return Reflect.decorate(decorators, target, name, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectDecorateThrowsIfTargetArgumentNotObjectForPropertyOverload = ReflectDecorateThrowsIfTargetArgumentNotObjectForPropertyOverload;
|
||||
function ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForPropertyDescriptorOverload() {
|
||||
var target = {};
|
||||
var name = "name";
|
||||
var descriptor = {};
|
||||
assert.throws(function () { return Reflect.decorate(undefined, target, name, descriptor); }, TypeError);
|
||||
}
|
||||
exports.ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForPropertyDescriptorOverload = ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForPropertyDescriptorOverload;
|
||||
function ReflectDecorateThrowsIfTargetArgumentNotObjectForPropertyDescriptorOverload() {
|
||||
var decorators = [];
|
||||
var target = 1;
|
||||
var name = "name";
|
||||
var descriptor = {};
|
||||
assert.throws(function () { return Reflect.decorate(decorators, target, name, descriptor); }, TypeError);
|
||||
}
|
||||
exports.ReflectDecorateThrowsIfTargetArgumentNotObjectForPropertyDescriptorOverload = ReflectDecorateThrowsIfTargetArgumentNotObjectForPropertyDescriptorOverload;
|
||||
function ReflectDecorateExecutesDecoratorsInReverseOrderForFunctionOverload() {
|
||||
var order = [];
|
||||
var decorators = [
|
||||
function (target) { order.push(0); },
|
||||
function (target) { order.push(1); }
|
||||
];
|
||||
var target = function () { };
|
||||
Reflect.decorate(decorators, target);
|
||||
assert.deepEqual(order, [1, 0]);
|
||||
}
|
||||
exports.ReflectDecorateExecutesDecoratorsInReverseOrderForFunctionOverload = ReflectDecorateExecutesDecoratorsInReverseOrderForFunctionOverload;
|
||||
function ReflectDecorateExecutesDecoratorsInReverseOrderForPropertyOverload() {
|
||||
var order = [];
|
||||
var decorators = [
|
||||
function (target, name) { order.push(0); },
|
||||
function (target, name) { order.push(1); }
|
||||
];
|
||||
var target = {};
|
||||
var name = "name";
|
||||
Reflect.decorate(decorators, target, name, undefined);
|
||||
assert.deepEqual(order, [1, 0]);
|
||||
}
|
||||
exports.ReflectDecorateExecutesDecoratorsInReverseOrderForPropertyOverload = ReflectDecorateExecutesDecoratorsInReverseOrderForPropertyOverload;
|
||||
function ReflectDecorateExecutesDecoratorsInReverseOrderForPropertyDescriptorOverload() {
|
||||
var order = [];
|
||||
var decorators = [
|
||||
function (target, name) { order.push(0); },
|
||||
function (target, name) { order.push(1); }
|
||||
];
|
||||
var target = {};
|
||||
var name = "name";
|
||||
var descriptor = {};
|
||||
Reflect.decorate(decorators, target, name, descriptor);
|
||||
assert.deepEqual(order, [1, 0]);
|
||||
}
|
||||
exports.ReflectDecorateExecutesDecoratorsInReverseOrderForPropertyDescriptorOverload = ReflectDecorateExecutesDecoratorsInReverseOrderForPropertyDescriptorOverload;
|
||||
function ReflectDecoratorPipelineForFunctionOverload() {
|
||||
var A = function A() { };
|
||||
var B = function B() { };
|
||||
var decorators = [
|
||||
function (target) { return undefined; },
|
||||
function (target) { return A; },
|
||||
function (target) { return B; }
|
||||
];
|
||||
var target = function () { };
|
||||
var result = Reflect.decorate(decorators, target);
|
||||
assert.strictEqual(result, A);
|
||||
}
|
||||
exports.ReflectDecoratorPipelineForFunctionOverload = ReflectDecoratorPipelineForFunctionOverload;
|
||||
function ReflectDecoratorPipelineForPropertyOverload() {
|
||||
var A = {};
|
||||
var B = {};
|
||||
var decorators = [
|
||||
function (target, name) { return undefined; },
|
||||
function (target, name) { return A; },
|
||||
function (target, name) { return B; }
|
||||
];
|
||||
var target = {};
|
||||
var result = Reflect.decorate(decorators, target, "name", undefined);
|
||||
assert.strictEqual(result, undefined);
|
||||
}
|
||||
exports.ReflectDecoratorPipelineForPropertyOverload = ReflectDecoratorPipelineForPropertyOverload;
|
||||
function ReflectDecoratorPipelineForPropertyDescriptorOverload() {
|
||||
var A = {};
|
||||
var B = {};
|
||||
var C = {};
|
||||
var decorators = [
|
||||
function (target, name) { return undefined; },
|
||||
function (target, name) { return A; },
|
||||
function (target, name) { return B; }
|
||||
];
|
||||
var target = {};
|
||||
var result = Reflect.decorate(decorators, target, "name", C);
|
||||
assert.strictEqual(result, A);
|
||||
}
|
||||
exports.ReflectDecoratorPipelineForPropertyDescriptorOverload = ReflectDecoratorPipelineForPropertyDescriptorOverload;
|
||||
function ReflectDecoratorCorrectTargetInPipelineForFunctionOverload() {
|
||||
var sent = [];
|
||||
var A = function A() { };
|
||||
var B = function B() { };
|
||||
var decorators = [
|
||||
function (target) { sent.push(target); return undefined; },
|
||||
function (target) { sent.push(target); return undefined; },
|
||||
function (target) { sent.push(target); return A; },
|
||||
function (target) { sent.push(target); return B; }
|
||||
];
|
||||
var target = function () { };
|
||||
Reflect.decorate(decorators, target);
|
||||
assert.deepEqual(sent, [target, B, A, A]);
|
||||
}
|
||||
exports.ReflectDecoratorCorrectTargetInPipelineForFunctionOverload = ReflectDecoratorCorrectTargetInPipelineForFunctionOverload;
|
||||
function ReflectDecoratorCorrectTargetInPipelineForPropertyOverload() {
|
||||
var sent = [];
|
||||
var decorators = [
|
||||
function (target, name) { sent.push(target); },
|
||||
function (target, name) { sent.push(target); },
|
||||
function (target, name) { sent.push(target); },
|
||||
function (target, name) { sent.push(target); }
|
||||
];
|
||||
var target = {};
|
||||
Reflect.decorate(decorators, target, "name");
|
||||
assert.deepEqual(sent, [target, target, target, target]);
|
||||
}
|
||||
exports.ReflectDecoratorCorrectTargetInPipelineForPropertyOverload = ReflectDecoratorCorrectTargetInPipelineForPropertyOverload;
|
||||
function ReflectDecoratorCorrectNameInPipelineForPropertyOverload() {
|
||||
var sent = [];
|
||||
var decorators = [
|
||||
function (target, name) { sent.push(name); },
|
||||
function (target, name) { sent.push(name); },
|
||||
function (target, name) { sent.push(name); },
|
||||
function (target, name) { sent.push(name); }
|
||||
];
|
||||
var target = {};
|
||||
Reflect.decorate(decorators, target, "name");
|
||||
assert.deepEqual(sent, ["name", "name", "name", "name"]);
|
||||
}
|
||||
exports.ReflectDecoratorCorrectNameInPipelineForPropertyOverload = ReflectDecoratorCorrectNameInPipelineForPropertyOverload;
|
||||
function ReflectDecoratorCorrectTargetInPipelineForPropertyDescriptorOverload() {
|
||||
var sent = [];
|
||||
var A = {};
|
||||
var B = {};
|
||||
var C = {};
|
||||
var decorators = [
|
||||
function (target, name) { sent.push(target); return undefined; },
|
||||
function (target, name) { sent.push(target); return undefined; },
|
||||
function (target, name) { sent.push(target); return A; },
|
||||
function (target, name) { sent.push(target); return B; }
|
||||
];
|
||||
var target = {};
|
||||
Reflect.decorate(decorators, target, "name", C);
|
||||
assert.deepEqual(sent, [target, target, target, target]);
|
||||
}
|
||||
exports.ReflectDecoratorCorrectTargetInPipelineForPropertyDescriptorOverload = ReflectDecoratorCorrectTargetInPipelineForPropertyDescriptorOverload;
|
||||
function ReflectDecoratorCorrectNameInPipelineForPropertyDescriptorOverload() {
|
||||
var sent = [];
|
||||
var A = {};
|
||||
var B = {};
|
||||
var C = {};
|
||||
var decorators = [
|
||||
function (target, name) { sent.push(name); return undefined; },
|
||||
function (target, name) { sent.push(name); return undefined; },
|
||||
function (target, name) { sent.push(name); return A; },
|
||||
function (target, name) { sent.push(name); return B; }
|
||||
];
|
||||
var target = {};
|
||||
Reflect.decorate(decorators, target, "name", C);
|
||||
assert.deepEqual(sent, ["name", "name", "name", "name"]);
|
||||
}
|
||||
exports.ReflectDecoratorCorrectNameInPipelineForPropertyDescriptorOverload = ReflectDecoratorCorrectNameInPipelineForPropertyDescriptorOverload;
|
||||
function ReflectDecoratorCorrectDescriptorInPipelineForPropertyDescriptorOverload() {
|
||||
var sent = [];
|
||||
var A = {};
|
||||
var B = {};
|
||||
var C = {};
|
||||
var decorators = [
|
||||
function (target, name, descriptor) { sent.push(descriptor); return undefined; },
|
||||
function (target, name, descriptor) { sent.push(descriptor); return undefined; },
|
||||
function (target, name, descriptor) { sent.push(descriptor); return A; },
|
||||
function (target, name, descriptor) { sent.push(descriptor); return B; }
|
||||
];
|
||||
var target = {};
|
||||
Reflect.decorate(decorators, target, "name", C);
|
||||
assert.deepEqual(sent, [C, B, A, A]);
|
||||
}
|
||||
exports.ReflectDecoratorCorrectDescriptorInPipelineForPropertyDescriptorOverload = ReflectDecoratorCorrectDescriptorInPipelineForPropertyDescriptorOverload;
|
||||
//# sourceMappingURL=reflect-decorate.js.map
|
1
node_modules/reflect-metadata/temp/test/reflect/reflect-decorate.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/reflect/reflect-decorate.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
17
node_modules/reflect-metadata/temp/test/reflect/reflect-definemetadata.js
generated
vendored
Normal file
17
node_modules/reflect-metadata/temp/test/reflect/reflect-definemetadata.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Reflect.defineMetadata ( metadataKey, metadataValue, target, propertyKey )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectdefinemetadata--metadatakey-metadatavalue-target-propertykey-
|
||||
require("../../Reflect");
|
||||
var assert = require("assert");
|
||||
function ReflectDefineMetadataInvalidTarget() {
|
||||
assert.throws(function () { return Reflect.defineMetadata("key", "value", undefined, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectDefineMetadataInvalidTarget = ReflectDefineMetadataInvalidTarget;
|
||||
function ReflectDefineMetadataValidTargetWithoutTargetKey() {
|
||||
assert.doesNotThrow(function () { return Reflect.defineMetadata("key", "value", {}, undefined); });
|
||||
}
|
||||
exports.ReflectDefineMetadataValidTargetWithoutTargetKey = ReflectDefineMetadataValidTargetWithoutTargetKey;
|
||||
function ReflectDefineMetadataValidTargetWithTargetKey() {
|
||||
assert.doesNotThrow(function () { return Reflect.defineMetadata("key", "value", {}, "name"); });
|
||||
}
|
||||
exports.ReflectDefineMetadataValidTargetWithTargetKey = ReflectDefineMetadataValidTargetWithTargetKey;
|
||||
//# sourceMappingURL=reflect-definemetadata.js.map
|
1
node_modules/reflect-metadata/temp/test/reflect/reflect-definemetadata.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/reflect/reflect-definemetadata.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"reflect-definemetadata.js","sourceRoot":"","sources":["../../../test/reflect/reflect-definemetadata.ts"],"names":["ReflectDefineMetadataInvalidTarget","ReflectDefineMetadataValidTargetWithoutTargetKey","ReflectDefineMetadataValidTargetWithTargetKey"],"mappings":"AAAA,6EAA6E;AAC7E,yJAAyJ;AAEzJ,QAAO,eAAe,CAAC,CAAA;AACvB,IAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC;IACIA,MAAMA,CAACA,MAAMA,CAACA,cAAMA,OAAAA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,SAASA,CAACA,EAA5DA,CAA4DA,EAAEA,SAASA,CAACA,CAACA;AACjGA,CAACA;AAFe,0CAAkC,qCAEjD,CAAA;AAED;IACIC,MAAMA,CAACA,YAAYA,CAACA,cAAMA,OAAAA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,EAAGA,EAAEA,SAASA,CAACA,EAAtDA,CAAsDA,CAACA,CAACA;AACtFA,CAACA;AAFe,wDAAgD,mDAE/D,CAAA;AAED;IACIC,MAAMA,CAACA,YAAYA,CAACA,cAAMA,OAAAA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,EAAGA,EAAEA,MAAMA,CAACA,EAAnDA,CAAmDA,CAACA,CAACA;AACnFA,CAACA;AAFe,qDAA6C,gDAE5D,CAAA"}
|
38
node_modules/reflect-metadata/temp/test/reflect/reflect-deletemetadata.js
generated
vendored
Normal file
38
node_modules/reflect-metadata/temp/test/reflect/reflect-deletemetadata.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Reflect.deleteMetadata ( metadataKey, target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectdeletemetadata--metadatakey-target--propertykey-
|
||||
require("../../Reflect");
|
||||
var assert = require("assert");
|
||||
function ReflectDeleteMetadataInvalidTarget() {
|
||||
assert.throws(function () { return Reflect.deleteMetadata("key", undefined, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectDeleteMetadataInvalidTarget = ReflectDeleteMetadataInvalidTarget;
|
||||
function ReflectDeleteMetadataWhenNotDefinedWithoutTargetKey() {
|
||||
var obj = {};
|
||||
var result = Reflect.deleteMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
exports.ReflectDeleteMetadataWhenNotDefinedWithoutTargetKey = ReflectDeleteMetadataWhenNotDefinedWithoutTargetKey;
|
||||
function ReflectDeleteMetadataWhenDefinedWithoutTargetKey() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
var result = Reflect.deleteMetadata("key", obj, undefined);
|
||||
assert.equal(result, true);
|
||||
}
|
||||
exports.ReflectDeleteMetadataWhenDefinedWithoutTargetKey = ReflectDeleteMetadataWhenDefinedWithoutTargetKey;
|
||||
function ReflectDeleteMetadataWhenDefinedOnPrototypeWithoutTargetKey() {
|
||||
var prototype = {};
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
var obj = Object.create(prototype);
|
||||
var result = Reflect.deleteMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
exports.ReflectDeleteMetadataWhenDefinedOnPrototypeWithoutTargetKey = ReflectDeleteMetadataWhenDefinedOnPrototypeWithoutTargetKey;
|
||||
function ReflectHasOwnMetadataAfterDeleteMetadata() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
Reflect.deleteMetadata("key", obj, undefined);
|
||||
var result = Reflect.hasOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
exports.ReflectHasOwnMetadataAfterDeleteMetadata = ReflectHasOwnMetadataAfterDeleteMetadata;
|
||||
//# sourceMappingURL=reflect-deletemetadata.js.map
|
1
node_modules/reflect-metadata/temp/test/reflect/reflect-deletemetadata.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/reflect/reflect-deletemetadata.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"reflect-deletemetadata.js","sourceRoot":"","sources":["../../../test/reflect/reflect-deletemetadata.ts"],"names":["ReflectDeleteMetadataInvalidTarget","ReflectDeleteMetadataWhenNotDefinedWithoutTargetKey","ReflectDeleteMetadataWhenDefinedWithoutTargetKey","ReflectDeleteMetadataWhenDefinedOnPrototypeWithoutTargetKey","ReflectHasOwnMetadataAfterDeleteMetadata"],"mappings":"AAAA,iEAAiE;AACjE,wIAAwI;AAExI,QAAO,eAAe,CAAC,CAAA;AACvB,IAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC;IACIA,MAAMA,CAACA,MAAMA,CAACA,cAAMA,OAAAA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,SAASA,EAAEA,SAASA,CAACA,EAAnDA,CAAmDA,EAAEA,SAASA,CAACA,CAACA;AACxFA,CAACA;AAFe,0CAAkC,qCAEjD,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,KAAKA,CAACA,CAACA;AAChCA,CAACA;AAJe,2DAAmD,sDAIlE,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACvDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,IAAIA,CAACA,CAACA;AAC/BA,CAACA;AALe,wDAAgD,mDAK/D,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,SAASA,CAACA,CAACA;IAC7DA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,KAAKA,CAACA,CAACA;AAChCA,CAACA;AANe,mEAA2D,8DAM1E,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACvDA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC9CA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,KAAKA,CAACA,CAACA;AAChCA,CAACA;AANe,gDAAwC,2CAMvD,CAAA"}
|
51
node_modules/reflect-metadata/temp/test/reflect/reflect-getmetadata.js
generated
vendored
Normal file
51
node_modules/reflect-metadata/temp/test/reflect/reflect-getmetadata.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// Reflect.getMetadata ( metadataKey, target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectgetmetadata--metadatakey-target--propertykey-
|
||||
require("../../Reflect");
|
||||
var assert = require("assert");
|
||||
function ReflectGetMetadataInvalidTarget() {
|
||||
assert.throws(function () { return Reflect.getMetadata("key", undefined, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectGetMetadataInvalidTarget = ReflectGetMetadataInvalidTarget;
|
||||
function ReflectGetMetadataWithoutTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.getMetadata("key", obj, undefined);
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
exports.ReflectGetMetadataWithoutTargetKeyWhenNotDefined = ReflectGetMetadataWithoutTargetKeyWhenNotDefined;
|
||||
function ReflectGetMetadataWithoutTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
var result = Reflect.getMetadata("key", obj, undefined);
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
exports.ReflectGetMetadataWithoutTargetKeyWhenDefined = ReflectGetMetadataWithoutTargetKeyWhenDefined;
|
||||
function ReflectGetMetadataWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
var result = Reflect.getMetadata("key", obj, undefined);
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
exports.ReflectGetMetadataWithoutTargetKeyWhenDefinedOnPrototype = ReflectGetMetadataWithoutTargetKeyWhenDefinedOnPrototype;
|
||||
function ReflectGetMetadataWithTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.getMetadata("key", obj, "name");
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
exports.ReflectGetMetadataWithTargetKeyWhenNotDefined = ReflectGetMetadataWithTargetKeyWhenNotDefined;
|
||||
function ReflectGetMetadataWithTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
var result = Reflect.getMetadata("key", obj, "name");
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
exports.ReflectGetMetadataWithTargetKeyWhenDefined = ReflectGetMetadataWithTargetKeyWhenDefined;
|
||||
function ReflectGetMetadataWithTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
var result = Reflect.getMetadata("key", obj, "name");
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
exports.ReflectGetMetadataWithTargetKeyWhenDefinedOnPrototype = ReflectGetMetadataWithTargetKeyWhenDefinedOnPrototype;
|
||||
//# sourceMappingURL=reflect-getmetadata.js.map
|
1
node_modules/reflect-metadata/temp/test/reflect/reflect-getmetadata.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/reflect/reflect-getmetadata.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"reflect-getmetadata.js","sourceRoot":"","sources":["../../../test/reflect/reflect-getmetadata.ts"],"names":["ReflectGetMetadataInvalidTarget","ReflectGetMetadataWithoutTargetKeyWhenNotDefined","ReflectGetMetadataWithoutTargetKeyWhenDefined","ReflectGetMetadataWithoutTargetKeyWhenDefinedOnPrototype","ReflectGetMetadataWithTargetKeyWhenNotDefined","ReflectGetMetadataWithTargetKeyWhenDefined","ReflectGetMetadataWithTargetKeyWhenDefinedOnPrototype"],"mappings":"AAAA,8DAA8D;AAC9D,qIAAqI;AAErI,QAAO,eAAe,CAAC,CAAA;AACvB,IAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC;IACIA,MAAMA,CAACA,MAAMA,CAACA,cAAMA,OAAAA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,SAASA,EAAEA,SAASA,CAACA,EAAhDA,CAAgDA,EAAEA,SAASA,CAACA,CAACA;AACrFA,CAACA;AAFe,uCAA+B,kCAE9C,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,SAASA,CAACA,CAACA;AACpCA,CAACA;AAJe,wDAAgD,mDAI/D,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACvDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,OAAOA,CAACA,CAACA;AAClCA,CAACA;AALe,qDAA6C,gDAK5D,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,SAASA,CAACA,CAACA;IAC7DA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,OAAOA,CAACA,CAACA;AAClCA,CAACA;AANe,gEAAwD,2DAMvE,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,SAASA,CAACA,CAACA;AACpCA,CAACA;AAJe,qDAA6C,gDAI5D,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACpDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,OAAOA,CAACA,CAACA;AAClCA,CAACA;AALe,kDAA0C,6CAKzD,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,MAAMA,CAACA,CAACA;IAC1DA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,OAAOA,CAACA,CAACA;AAClCA,CAACA;AANe,6DAAqD,wDAMpE,CAAA"}
|
98
node_modules/reflect-metadata/temp/test/reflect/reflect-getmetadatakeys.js
generated
vendored
Normal file
98
node_modules/reflect-metadata/temp/test/reflect/reflect-getmetadatakeys.js
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
// Reflect.getMetadataKeys ( target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectgetmetadatakeys--target--propertykey-
|
||||
require("../../Reflect");
|
||||
var assert = require("assert");
|
||||
function ReflectGetMetadataKeysInvalidTarget() {
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
assert.throws(function () { return Reflect.getMetadataKeys(undefined, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysInvalidTarget = ReflectGetMetadataKeysInvalidTarget;
|
||||
function ReflectGetMetadataKeysWithoutTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysWithoutTargetKeyWhenNotDefined = ReflectGetMetadataKeysWithoutTargetKeyWhenNotDefined;
|
||||
function ReflectGetMetadataKeysWithoutTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
var result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysWithoutTargetKeyWhenDefined = ReflectGetMetadataKeysWithoutTargetKeyWhenDefined;
|
||||
function ReflectGetMetadataKeysWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
var result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysWithoutTargetKeyWhenDefinedOnPrototype = ReflectGetMetadataKeysWithoutTargetKeyWhenDefinedOnPrototype;
|
||||
function ReflectGetMetadataKeysOrderWithoutTargetKey() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key0", "value", obj, undefined);
|
||||
var result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysOrderWithoutTargetKey = ReflectGetMetadataKeysOrderWithoutTargetKey;
|
||||
function ReflectGetMetadataKeysOrderAfterRedefineWithoutTargetKey() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key0", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
var result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysOrderAfterRedefineWithoutTargetKey = ReflectGetMetadataKeysOrderAfterRedefineWithoutTargetKey;
|
||||
function ReflectGetMetadataKeysOrderWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
Reflect.defineMetadata("key2", "value", prototype, undefined);
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key0", "value", obj, undefined);
|
||||
var result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key1", "key0", "key2"]);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysOrderWithoutTargetKeyWhenDefinedOnPrototype = ReflectGetMetadataKeysOrderWithoutTargetKeyWhenDefinedOnPrototype;
|
||||
function ReflectGetMetadataKeysWithTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.getMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysWithTargetKeyWhenNotDefined = ReflectGetMetadataKeysWithTargetKeyWhenNotDefined;
|
||||
function ReflectGetMetadataKeysWithTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
var result = Reflect.getMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysWithTargetKeyWhenDefined = ReflectGetMetadataKeysWithTargetKeyWhenDefined;
|
||||
function ReflectGetMetadataKeysWithTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
var result = Reflect.getMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysWithTargetKeyWhenDefinedOnPrototype = ReflectGetMetadataKeysWithTargetKeyWhenDefinedOnPrototype;
|
||||
function ReflectGetMetadataKeysOrderAfterRedefineWithTargetKey() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, "name");
|
||||
Reflect.defineMetadata("key0", "value", obj, "name");
|
||||
Reflect.defineMetadata("key1", "value", obj, "name");
|
||||
var result = Reflect.getMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysOrderAfterRedefineWithTargetKey = ReflectGetMetadataKeysOrderAfterRedefineWithTargetKey;
|
||||
function ReflectGetMetadataKeysOrderWithTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
Reflect.defineMetadata("key2", "value", prototype, "name");
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key1", "value", obj, "name");
|
||||
Reflect.defineMetadata("key0", "value", obj, "name");
|
||||
var result = Reflect.getMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key1", "key0", "key2"]);
|
||||
}
|
||||
exports.ReflectGetMetadataKeysOrderWithTargetKeyWhenDefinedOnPrototype = ReflectGetMetadataKeysOrderWithTargetKeyWhenDefinedOnPrototype;
|
||||
//# sourceMappingURL=reflect-getmetadatakeys.js.map
|
1
node_modules/reflect-metadata/temp/test/reflect/reflect-getmetadatakeys.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/reflect/reflect-getmetadatakeys.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
51
node_modules/reflect-metadata/temp/test/reflect/reflect-getownmetadata.js
generated
vendored
Normal file
51
node_modules/reflect-metadata/temp/test/reflect/reflect-getownmetadata.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// Reflect.getOwnMetadata ( metadataKey, target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectgetownmetadata--metadatakey-target--propertykey-
|
||||
require("../../Reflect");
|
||||
var assert = require("assert");
|
||||
function ReflectGetOwnMetadataInvalidTarget() {
|
||||
assert.throws(function () { return Reflect.getOwnMetadata("key", undefined, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataInvalidTarget = ReflectGetOwnMetadataInvalidTarget;
|
||||
function ReflectGetOwnMetadataWithoutTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.getOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataWithoutTargetKeyWhenNotDefined = ReflectGetOwnMetadataWithoutTargetKeyWhenNotDefined;
|
||||
function ReflectGetOwnMetadataWithoutTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
var result = Reflect.getOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
exports.ReflectGetOwnMetadataWithoutTargetKeyWhenDefined = ReflectGetOwnMetadataWithoutTargetKeyWhenDefined;
|
||||
function ReflectGetOwnMetadataWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
var result = Reflect.getOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataWithoutTargetKeyWhenDefinedOnPrototype = ReflectGetOwnMetadataWithoutTargetKeyWhenDefinedOnPrototype;
|
||||
function ReflectGetOwnMetadataWithTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.getOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataWithTargetKeyWhenNotDefined = ReflectGetOwnMetadataWithTargetKeyWhenNotDefined;
|
||||
function ReflectGetOwnMetadataWithTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
var result = Reflect.getOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
exports.ReflectGetOwnMetadataWithTargetKeyWhenDefined = ReflectGetOwnMetadataWithTargetKeyWhenDefined;
|
||||
function ReflectGetOwnMetadataWithTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
var result = Reflect.getOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataWithTargetKeyWhenDefinedOnPrototype = ReflectGetOwnMetadataWithTargetKeyWhenDefinedOnPrototype;
|
||||
//# sourceMappingURL=reflect-getownmetadata.js.map
|
1
node_modules/reflect-metadata/temp/test/reflect/reflect-getownmetadata.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/reflect/reflect-getownmetadata.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"reflect-getownmetadata.js","sourceRoot":"","sources":["../../../test/reflect/reflect-getownmetadata.ts"],"names":["ReflectGetOwnMetadataInvalidTarget","ReflectGetOwnMetadataWithoutTargetKeyWhenNotDefined","ReflectGetOwnMetadataWithoutTargetKeyWhenDefined","ReflectGetOwnMetadataWithoutTargetKeyWhenDefinedOnPrototype","ReflectGetOwnMetadataWithTargetKeyWhenNotDefined","ReflectGetOwnMetadataWithTargetKeyWhenDefined","ReflectGetOwnMetadataWithTargetKeyWhenDefinedOnPrototype"],"mappings":"AAAA,iEAAiE;AACjE,wIAAwI;AAExI,QAAO,eAAe,CAAC,CAAA;AACvB,IAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC;IACIA,MAAMA,CAACA,MAAMA,CAACA,cAAMA,OAAAA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,SAASA,EAAEA,SAASA,CAACA,EAAnDA,CAAmDA,EAAEA,SAASA,CAACA,CAACA;AACxFA,CAACA;AAFe,0CAAkC,qCAEjD,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,SAASA,CAACA,CAACA;AACpCA,CAACA;AAJe,2DAAmD,sDAIlE,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACvDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,OAAOA,CAACA,CAACA;AAClCA,CAACA;AALe,wDAAgD,mDAK/D,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,SAASA,CAACA,CAACA;IAC7DA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,SAASA,CAACA,CAACA;AACpCA,CAACA;AANe,mEAA2D,8DAM1E,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,SAASA,CAACA,CAACA;AACpCA,CAACA;AAJe,wDAAgD,mDAI/D,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACpDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,OAAOA,CAACA,CAACA;AAClCA,CAACA;AALe,qDAA6C,gDAK5D,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,MAAMA,CAACA,CAACA;IAC1DA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,SAASA,CAACA,CAACA;AACpCA,CAACA;AANe,gEAAwD,2DAMvE,CAAA"}
|
78
node_modules/reflect-metadata/temp/test/reflect/reflect-getownmetadatakeys.js
generated
vendored
Normal file
78
node_modules/reflect-metadata/temp/test/reflect/reflect-getownmetadatakeys.js
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
// Reflect.getOwnMetadataKeysKeys ( target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectgetownmetadatakeyskeys--target--propertykey-
|
||||
require("../../Reflect");
|
||||
var assert = require("assert");
|
||||
function ReflectGetOwnMetadataKeysKeysInvalidTarget() {
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
assert.throws(function () { return Reflect.getOwnMetadataKeys(undefined, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataKeysKeysInvalidTarget = ReflectGetOwnMetadataKeysKeysInvalidTarget;
|
||||
function ReflectGetOwnMetadataKeysWithoutTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.getOwnMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataKeysWithoutTargetKeyWhenNotDefined = ReflectGetOwnMetadataKeysWithoutTargetKeyWhenNotDefined;
|
||||
function ReflectGetOwnMetadataKeysWithoutTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
var result = Reflect.getOwnMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataKeysWithoutTargetKeyWhenDefined = ReflectGetOwnMetadataKeysWithoutTargetKeyWhenDefined;
|
||||
function ReflectGetOwnMetadataKeysWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
var result = Reflect.getOwnMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataKeysWithoutTargetKeyWhenDefinedOnPrototype = ReflectGetOwnMetadataKeysWithoutTargetKeyWhenDefinedOnPrototype;
|
||||
function ReflectGetOwnMetadataKeysOrderWithoutTargetKey() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key0", "value", obj, undefined);
|
||||
var result = Reflect.getOwnMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataKeysOrderWithoutTargetKey = ReflectGetOwnMetadataKeysOrderWithoutTargetKey;
|
||||
function ReflectGetOwnMetadataKeysOrderAfterRedefineWithoutTargetKey() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key0", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
var result = Reflect.getOwnMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataKeysOrderAfterRedefineWithoutTargetKey = ReflectGetOwnMetadataKeysOrderAfterRedefineWithoutTargetKey;
|
||||
function ReflectGetOwnMetadataKeysWithTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.getOwnMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataKeysWithTargetKeyWhenNotDefined = ReflectGetOwnMetadataKeysWithTargetKeyWhenNotDefined;
|
||||
function ReflectGetOwnMetadataKeysWithTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
var result = Reflect.getOwnMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataKeysWithTargetKeyWhenDefined = ReflectGetOwnMetadataKeysWithTargetKeyWhenDefined;
|
||||
function ReflectGetOwnMetadataKeysWithTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
var result = Reflect.getOwnMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataKeysWithTargetKeyWhenDefinedOnPrototype = ReflectGetOwnMetadataKeysWithTargetKeyWhenDefinedOnPrototype;
|
||||
function ReflectGetOwnMetadataKeysOrderAfterRedefineWithTargetKey() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, "name");
|
||||
Reflect.defineMetadata("key0", "value", obj, "name");
|
||||
Reflect.defineMetadata("key1", "value", obj, "name");
|
||||
var result = Reflect.getOwnMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
exports.ReflectGetOwnMetadataKeysOrderAfterRedefineWithTargetKey = ReflectGetOwnMetadataKeysOrderAfterRedefineWithTargetKey;
|
||||
//# sourceMappingURL=reflect-getownmetadatakeys.js.map
|
1
node_modules/reflect-metadata/temp/test/reflect/reflect-getownmetadatakeys.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/reflect/reflect-getownmetadatakeys.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"reflect-getownmetadatakeys.js","sourceRoot":"","sources":["../../../test/reflect/reflect-getownmetadatakeys.ts"],"names":["ReflectGetOwnMetadataKeysKeysInvalidTarget","ReflectGetOwnMetadataKeysWithoutTargetKeyWhenNotDefined","ReflectGetOwnMetadataKeysWithoutTargetKeyWhenDefined","ReflectGetOwnMetadataKeysWithoutTargetKeyWhenDefinedOnPrototype","ReflectGetOwnMetadataKeysOrderWithoutTargetKey","ReflectGetOwnMetadataKeysOrderAfterRedefineWithoutTargetKey","ReflectGetOwnMetadataKeysWithTargetKeyWhenNotDefined","ReflectGetOwnMetadataKeysWithTargetKeyWhenDefined","ReflectGetOwnMetadataKeysWithTargetKeyWhenDefinedOnPrototype","ReflectGetOwnMetadataKeysOrderAfterRedefineWithTargetKey"],"mappings":"AAAA,4DAA4D;AAC5D,oIAAoI;AAEpI,QAAO,eAAe,CAAC,CAAA;AACvB,IAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC;IAEIA,AADAA,iEAAiEA;IACjEA,MAAMA,CAACA,MAAMA,CAACA,cAAMA,OAAAA,OAAOA,CAACA,kBAAkBA,CAACA,SAASA,EAAEA,SAASA,CAACA,EAAhDA,CAAgDA,EAAEA,SAASA,CAACA,CAACA;AACrFA,CAACA;AAHe,kDAA0C,6CAGzD,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,kBAAkBA,CAACA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,SAASA,CAACA,MAAMA,EAAEA,EAAEA,CAACA,CAACA;AACjCA,CAACA;AAJe,+DAAuD,0DAItE,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACvDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,kBAAkBA,CAACA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,SAASA,CAACA,MAAMA,EAAEA,CAACA,KAAKA,CAACA,CAACA,CAACA;AACtCA,CAACA;AALe,4DAAoD,uDAKnE,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,SAASA,CAACA,CAACA;IAC7DA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,kBAAkBA,CAACA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,SAASA,CAACA,MAAMA,EAAEA,EAAEA,CAACA,CAACA;AACjCA,CAACA;AANe,uEAA+D,kEAM9E,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,MAAMA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,OAAOA,CAACA,cAAcA,CAACA,MAAMA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,kBAAkBA,CAACA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,SAASA,CAACA,MAAMA,EAAEA,CAACA,MAAMA,EAAEA,MAAMA,CAACA,CAACA,CAACA;AAC/CA,CAACA;AANe,sDAA8C,iDAM7D,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,MAAMA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,OAAOA,CAACA,cAAcA,CAACA,MAAMA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,OAAOA,CAACA,cAAcA,CAACA,MAAMA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,kBAAkBA,CAACA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,SAASA,CAACA,MAAMA,EAAEA,CAACA,MAAMA,EAAEA,MAAMA,CAACA,CAACA,CAACA;AAC/CA,CAACA;AAPe,mEAA2D,8DAO1E,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,kBAAkBA,CAACA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,MAAMA,CAACA,SAASA,CAACA,MAAMA,EAAEA,EAAEA,CAACA,CAACA;AACjCA,CAACA;AAJe,4DAAoD,uDAInE,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACpDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,kBAAkBA,CAACA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,MAAMA,CAACA,SAASA,CAACA,MAAMA,EAAEA,CAACA,KAAKA,CAACA,CAACA,CAACA;AACtCA,CAACA;AALe,yDAAiD,oDAKhE,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,MAAMA,CAACA,CAACA;IAC1DA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,kBAAkBA,CAACA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,MAAMA,CAACA,SAASA,CAACA,MAAMA,EAAEA,EAAEA,CAACA,CAACA;AACjCA,CAACA;AANe,oEAA4D,+DAM3E,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,MAAMA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,OAAOA,CAACA,cAAcA,CAACA,MAAMA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,OAAOA,CAACA,cAAcA,CAACA,MAAMA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,kBAAkBA,CAACA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,MAAMA,CAACA,SAASA,CAACA,MAAMA,EAAEA,CAACA,MAAMA,EAAEA,MAAMA,CAACA,CAACA,CAACA;AAC/CA,CAACA;AAPe,gEAAwD,2DAOvE,CAAA"}
|
51
node_modules/reflect-metadata/temp/test/reflect/reflect-hasmetadata.js
generated
vendored
Normal file
51
node_modules/reflect-metadata/temp/test/reflect/reflect-hasmetadata.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// Reflect.hasMetadata ( metadataKey, target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflecthasmetadata--metadatakey-target--propertykey-
|
||||
require("../../Reflect");
|
||||
var assert = require("assert");
|
||||
function ReflectHasMetadataInvalidTarget() {
|
||||
assert.throws(function () { return Reflect.hasMetadata("key", undefined, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectHasMetadataInvalidTarget = ReflectHasMetadataInvalidTarget;
|
||||
function ReflectHasMetadataWithoutTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.hasMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
exports.ReflectHasMetadataWithoutTargetKeyWhenNotDefined = ReflectHasMetadataWithoutTargetKeyWhenNotDefined;
|
||||
function ReflectHasMetadataWithoutTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
var result = Reflect.hasMetadata("key", obj, undefined);
|
||||
assert.equal(result, true);
|
||||
}
|
||||
exports.ReflectHasMetadataWithoutTargetKeyWhenDefined = ReflectHasMetadataWithoutTargetKeyWhenDefined;
|
||||
function ReflectHasMetadataWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
var result = Reflect.hasMetadata("key", obj, undefined);
|
||||
assert.equal(result, true);
|
||||
}
|
||||
exports.ReflectHasMetadataWithoutTargetKeyWhenDefinedOnPrototype = ReflectHasMetadataWithoutTargetKeyWhenDefinedOnPrototype;
|
||||
function ReflectHasMetadataWithTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.hasMetadata("key", obj, "name");
|
||||
assert.equal(result, false);
|
||||
}
|
||||
exports.ReflectHasMetadataWithTargetKeyWhenNotDefined = ReflectHasMetadataWithTargetKeyWhenNotDefined;
|
||||
function ReflectHasMetadataWithTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
var result = Reflect.hasMetadata("key", obj, "name");
|
||||
assert.equal(result, true);
|
||||
}
|
||||
exports.ReflectHasMetadataWithTargetKeyWhenDefined = ReflectHasMetadataWithTargetKeyWhenDefined;
|
||||
function ReflectHasMetadataWithTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
var result = Reflect.hasMetadata("key", obj, "name");
|
||||
assert.equal(result, true);
|
||||
}
|
||||
exports.ReflectHasMetadataWithTargetKeyWhenDefinedOnPrototype = ReflectHasMetadataWithTargetKeyWhenDefinedOnPrototype;
|
||||
//# sourceMappingURL=reflect-hasmetadata.js.map
|
1
node_modules/reflect-metadata/temp/test/reflect/reflect-hasmetadata.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/reflect/reflect-hasmetadata.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"reflect-hasmetadata.js","sourceRoot":"","sources":["../../../test/reflect/reflect-hasmetadata.ts"],"names":["ReflectHasMetadataInvalidTarget","ReflectHasMetadataWithoutTargetKeyWhenNotDefined","ReflectHasMetadataWithoutTargetKeyWhenDefined","ReflectHasMetadataWithoutTargetKeyWhenDefinedOnPrototype","ReflectHasMetadataWithTargetKeyWhenNotDefined","ReflectHasMetadataWithTargetKeyWhenDefined","ReflectHasMetadataWithTargetKeyWhenDefinedOnPrototype"],"mappings":"AAAA,8DAA8D;AAC9D,qIAAqI;AAErI,QAAO,eAAe,CAAC,CAAA;AACvB,IAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC;IACIA,MAAMA,CAACA,MAAMA,CAACA,cAAMA,OAAAA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,SAASA,EAAEA,SAASA,CAACA,EAAhDA,CAAgDA,EAAEA,SAASA,CAACA,CAACA;AACrFA,CAACA;AAFe,uCAA+B,kCAE9C,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,KAAKA,CAACA,CAACA;AAChCA,CAACA;AAJe,wDAAgD,mDAI/D,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACvDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,IAAIA,CAACA,CAACA;AAC/BA,CAACA;AALe,qDAA6C,gDAK5D,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,SAASA,CAACA,CAACA;IAC7DA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,IAAIA,CAACA,CAACA;AAC/BA,CAACA;AANe,gEAAwD,2DAMvE,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,KAAKA,CAACA,CAACA;AAChCA,CAACA;AAJe,qDAA6C,gDAI5D,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACpDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,IAAIA,CAACA,CAACA;AAC/BA,CAACA;AALe,kDAA0C,6CAKzD,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,MAAMA,CAACA,CAACA;IAC1DA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACrDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,IAAIA,CAACA,CAACA;AAC/BA,CAACA;AANe,6DAAqD,wDAMpE,CAAA"}
|
51
node_modules/reflect-metadata/temp/test/reflect/reflect-hasownmetadata.js
generated
vendored
Normal file
51
node_modules/reflect-metadata/temp/test/reflect/reflect-hasownmetadata.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// Reflect.hasOwnMetadata ( metadataKey, target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflecthasownmetadata--metadatakey-target--propertykey-
|
||||
require("../../Reflect");
|
||||
var assert = require("assert");
|
||||
function ReflectHasOwnMetadataInvalidTarget() {
|
||||
assert.throws(function () { return Reflect.hasOwnMetadata("key", undefined, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectHasOwnMetadataInvalidTarget = ReflectHasOwnMetadataInvalidTarget;
|
||||
function ReflectHasOwnMetadataWithoutTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.hasOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
exports.ReflectHasOwnMetadataWithoutTargetKeyWhenNotDefined = ReflectHasOwnMetadataWithoutTargetKeyWhenNotDefined;
|
||||
function ReflectHasOwnMetadataWithoutTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
var result = Reflect.hasOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, true);
|
||||
}
|
||||
exports.ReflectHasOwnMetadataWithoutTargetKeyWhenDefined = ReflectHasOwnMetadataWithoutTargetKeyWhenDefined;
|
||||
function ReflectHasOwnMetadataWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
var result = Reflect.hasOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
exports.ReflectHasOwnMetadataWithoutTargetKeyWhenDefinedOnPrototype = ReflectHasOwnMetadataWithoutTargetKeyWhenDefinedOnPrototype;
|
||||
function ReflectHasOwnMetadataWithTargetKeyWhenNotDefined() {
|
||||
var obj = {};
|
||||
var result = Reflect.hasOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, false);
|
||||
}
|
||||
exports.ReflectHasOwnMetadataWithTargetKeyWhenNotDefined = ReflectHasOwnMetadataWithTargetKeyWhenNotDefined;
|
||||
function ReflectHasOwnMetadataWithTargetKeyWhenDefined() {
|
||||
var obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
var result = Reflect.hasOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, true);
|
||||
}
|
||||
exports.ReflectHasOwnMetadataWithTargetKeyWhenDefined = ReflectHasOwnMetadataWithTargetKeyWhenDefined;
|
||||
function ReflectHasOwnMetadataWithTargetKeyWhenDefinedOnPrototype() {
|
||||
var prototype = {};
|
||||
var obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
var result = Reflect.hasOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, false);
|
||||
}
|
||||
exports.ReflectHasOwnMetadataWithTargetKeyWhenDefinedOnPrototype = ReflectHasOwnMetadataWithTargetKeyWhenDefinedOnPrototype;
|
||||
//# sourceMappingURL=reflect-hasownmetadata.js.map
|
1
node_modules/reflect-metadata/temp/test/reflect/reflect-hasownmetadata.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/reflect/reflect-hasownmetadata.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"reflect-hasownmetadata.js","sourceRoot":"","sources":["../../../test/reflect/reflect-hasownmetadata.ts"],"names":["ReflectHasOwnMetadataInvalidTarget","ReflectHasOwnMetadataWithoutTargetKeyWhenNotDefined","ReflectHasOwnMetadataWithoutTargetKeyWhenDefined","ReflectHasOwnMetadataWithoutTargetKeyWhenDefinedOnPrototype","ReflectHasOwnMetadataWithTargetKeyWhenNotDefined","ReflectHasOwnMetadataWithTargetKeyWhenDefined","ReflectHasOwnMetadataWithTargetKeyWhenDefinedOnPrototype"],"mappings":"AAAA,iEAAiE;AACjE,wIAAwI;AAExI,QAAO,eAAe,CAAC,CAAA;AACvB,IAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC;IACIA,MAAMA,CAACA,MAAMA,CAACA,cAAMA,OAAAA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,SAASA,EAAEA,SAASA,CAACA,EAAnDA,CAAmDA,EAAEA,SAASA,CAACA,CAACA;AACxFA,CAACA;AAFe,0CAAkC,qCAEjD,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,KAAKA,CAACA,CAACA;AAChCA,CAACA;AAJe,2DAAmD,sDAIlE,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IACvDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,IAAIA,CAACA,CAACA;AAC/BA,CAACA;AALe,wDAAgD,mDAK/D,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,SAASA,CAACA,CAACA;IAC7DA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,SAASA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,KAAKA,CAACA,CAACA;AAChCA,CAACA;AANe,mEAA2D,8DAM1E,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,KAAKA,CAACA,CAACA;AAChCA,CAACA;AAJe,wDAAgD,mDAI/D,CAAA;AAED;IACIC,IAAIA,GAAGA,GAAGA,EAAEA,CAACA;IACbA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACpDA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,IAAIA,CAACA,CAACA;AAC/BA,CAACA;AALe,qDAA6C,gDAK5D,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,EAAEA,CAACA;IACnBA,IAAIA,GAAGA,GAAGA,MAAMA,CAACA,MAAMA,CAACA,SAASA,CAACA,CAACA;IACnCA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,OAAOA,EAAEA,SAASA,EAAEA,MAAMA,CAACA,CAACA;IAC1DA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,GAAGA,EAAEA,MAAMA,CAACA,CAACA;IACxDA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,KAAKA,CAACA,CAACA;AAChCA,CAACA;AANe,gEAAwD,2DAMvE,CAAA"}
|
36
node_modules/reflect-metadata/temp/test/reflect/reflect-metadata.js
generated
vendored
Normal file
36
node_modules/reflect-metadata/temp/test/reflect/reflect-metadata.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
// Reflect.metadata ( metadataKey, metadataValue )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectmetadata--metadatakey-metadatavalue-
|
||||
require("../../Reflect");
|
||||
var assert = require("assert");
|
||||
function ReflectMetadataReturnsDecoratorFunction() {
|
||||
var result = Reflect.metadata("key", "value");
|
||||
assert.equal(typeof result, "function");
|
||||
}
|
||||
exports.ReflectMetadataReturnsDecoratorFunction = ReflectMetadataReturnsDecoratorFunction;
|
||||
function ReflectMetadataDecoratorThrowsWithInvalidTargetWithTargetKey() {
|
||||
var decorator = Reflect.metadata("key", "value");
|
||||
assert.throws(function () { return decorator(undefined, "name"); }, TypeError);
|
||||
}
|
||||
exports.ReflectMetadataDecoratorThrowsWithInvalidTargetWithTargetKey = ReflectMetadataDecoratorThrowsWithInvalidTargetWithTargetKey;
|
||||
function ReflectMetadataDecoratorThrowsWithInvalidTargetWithoutTargetKey() {
|
||||
var decorator = Reflect.metadata("key", "value");
|
||||
assert.throws(function () { return decorator({}, undefined); }, TypeError);
|
||||
}
|
||||
exports.ReflectMetadataDecoratorThrowsWithInvalidTargetWithoutTargetKey = ReflectMetadataDecoratorThrowsWithInvalidTargetWithoutTargetKey;
|
||||
function ReflectMetadataDecoratorSetsMetadataOnTargetWithoutTargetKey() {
|
||||
var decorator = Reflect.metadata("key", "value");
|
||||
var target = function () { };
|
||||
decorator(target);
|
||||
var result = Reflect.hasOwnMetadata("key", target, undefined);
|
||||
assert.equal(result, true);
|
||||
}
|
||||
exports.ReflectMetadataDecoratorSetsMetadataOnTargetWithoutTargetKey = ReflectMetadataDecoratorSetsMetadataOnTargetWithoutTargetKey;
|
||||
function ReflectMetadataDecoratorSetsMetadataOnTargetWithTargetKey() {
|
||||
var decorator = Reflect.metadata("key", "value");
|
||||
var target = {};
|
||||
decorator(target, "name");
|
||||
var result = Reflect.hasOwnMetadata("key", target, "name");
|
||||
assert.equal(result, true);
|
||||
}
|
||||
exports.ReflectMetadataDecoratorSetsMetadataOnTargetWithTargetKey = ReflectMetadataDecoratorSetsMetadataOnTargetWithTargetKey;
|
||||
//# sourceMappingURL=reflect-metadata.js.map
|
1
node_modules/reflect-metadata/temp/test/reflect/reflect-metadata.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/reflect/reflect-metadata.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"reflect-metadata.js","sourceRoot":"","sources":["../../../test/reflect/reflect-metadata.ts"],"names":["ReflectMetadataReturnsDecoratorFunction","ReflectMetadataDecoratorThrowsWithInvalidTargetWithTargetKey","ReflectMetadataDecoratorThrowsWithInvalidTargetWithoutTargetKey","ReflectMetadataDecoratorSetsMetadataOnTargetWithoutTargetKey","ReflectMetadataDecoratorSetsMetadataOnTargetWithTargetKey"],"mappings":"AAAA,kDAAkD;AAClD,4HAA4H;AAE5H,QAAO,eAAe,CAAC,CAAA;AACvB,IAAY,MAAM,WAAM,QAAQ,CAAC,CAAA;AAEjC;IACIA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,QAAQA,CAACA,KAAKA,EAAEA,OAAOA,CAACA,CAACA;IAC9CA,MAAMA,CAACA,KAAKA,CAACA,OAAOA,MAAMA,EAAEA,UAAUA,CAACA,CAACA;AAC5CA,CAACA;AAHe,+CAAuC,0CAGtD,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,OAAOA,CAACA,QAAQA,CAACA,KAAKA,EAAEA,OAAOA,CAACA,CAACA;IACjDA,MAAMA,CAACA,MAAMA,CAACA,cAAMA,OAAAA,SAASA,CAACA,SAASA,EAAEA,MAAMA,CAACA,EAA5BA,CAA4BA,EAAEA,SAASA,CAACA,CAACA;AACjEA,CAACA;AAHe,oEAA4D,+DAG3E,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,OAAOA,CAACA,QAAQA,CAACA,KAAKA,EAAEA,OAAOA,CAACA,CAACA;IACjDA,MAAMA,CAACA,MAAMA,CAACA,cAAMA,OAAAA,SAASA,CAACA,EAAEA,EAAEA,SAASA,CAACA,EAAxBA,CAAwBA,EAAEA,SAASA,CAACA,CAACA;AAC7DA,CAACA;AAHe,uEAA+D,kEAG9E,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,OAAOA,CAACA,QAAQA,CAACA,KAAKA,EAAEA,OAAOA,CAACA,CAACA;IACjDA,IAAIA,MAAMA,GAAGA,cAAa,CAAC,CAAAA;IAC3BA,SAASA,CAACA,MAAMA,CAACA,CAACA;IAElBA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,MAAMA,EAAEA,SAASA,CAACA,CAACA;IAC9DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,IAAIA,CAACA,CAACA;AAC/BA,CAACA;AAPe,oEAA4D,+DAO3E,CAAA;AAED;IACIC,IAAIA,SAASA,GAAGA,OAAOA,CAACA,QAAQA,CAACA,KAAKA,EAAEA,OAAOA,CAACA,CAACA;IACjDA,IAAIA,MAAMA,GAAGA,EAAEA,CAAAA;IACfA,SAASA,CAACA,MAAMA,EAAEA,MAAMA,CAACA,CAACA;IAE1BA,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,cAAcA,CAACA,KAAKA,EAAEA,MAAMA,EAAEA,MAAMA,CAACA,CAACA;IAC3DA,MAAMA,CAACA,KAAKA,CAACA,MAAMA,EAAEA,IAAIA,CAACA,CAACA;AAC/BA,CAACA;AAPe,iEAAyD,4DAOxE,CAAA"}
|
5
node_modules/reflect-metadata/temp/test/run.js
generated
vendored
Normal file
5
node_modules/reflect-metadata/temp/test/run.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
var harness_1 = require('./harness');
|
||||
var spec = require("./spec");
|
||||
var results = harness_1.runTests(spec);
|
||||
harness_1.printResults(results);
|
||||
//# sourceMappingURL=run.js.map
|
1
node_modules/reflect-metadata/temp/test/run.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/run.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../test/run.ts"],"names":[],"mappings":"AAAA,wBAAuC,WAAW,CAAC,CAAA;AACnD,IAAY,IAAI,WAAM,QAAQ,CAAC,CAAA;AAE/B,IAAI,OAAO,GAAG,kBAAQ,CAAC,IAAI,CAAC,CAAC;AAC7B,sBAAY,CAAC,OAAO,CAAC,CAAC"}
|
14
node_modules/reflect-metadata/temp/test/spec.js
generated
vendored
Normal file
14
node_modules/reflect-metadata/temp/test/spec.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
function __export(m) {
|
||||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
||||
}
|
||||
__export(require("./reflect/reflect-decorate"));
|
||||
__export(require("./reflect/reflect-metadata"));
|
||||
__export(require("./reflect/reflect-definemetadata"));
|
||||
__export(require("./reflect/reflect-hasownmetadata"));
|
||||
__export(require("./reflect/reflect-hasmetadata"));
|
||||
__export(require("./reflect/reflect-getownmetadata"));
|
||||
__export(require("./reflect/reflect-getmetadata"));
|
||||
__export(require("./reflect/reflect-getownmetadatakeys"));
|
||||
__export(require("./reflect/reflect-getmetadatakeys"));
|
||||
__export(require("./reflect/reflect-deletemetadata"));
|
||||
//# sourceMappingURL=spec.js.map
|
1
node_modules/reflect-metadata/temp/test/spec.js.map
generated
vendored
Normal file
1
node_modules/reflect-metadata/temp/test/spec.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../test/spec.ts"],"names":[],"mappings":";;;AAAA,iBAAc,4BAA4B,CAAC,EAAA;AAC3C,iBAAc,4BAA4B,CAAC,EAAA;AAC3C,iBAAc,kCAAkC,CAAC,EAAA;AACjD,iBAAc,kCAAkC,CAAC,EAAA;AACjD,iBAAc,+BAA+B,CAAC,EAAA;AAC9C,iBAAc,kCAAkC,CAAC,EAAA;AACjD,iBAAc,+BAA+B,CAAC,EAAA;AAC9C,iBAAc,sCAAsC,CAAC,EAAA;AACrD,iBAAc,mCAAmC,CAAC,EAAA;AAClD,iBAAc,kCAAkC,CAAC,EAAA"}
|
40
node_modules/reflect-metadata/test/harness.ts
generated
vendored
Normal file
40
node_modules/reflect-metadata/test/harness.ts
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
export interface TestResults {
|
||||
passed: string[];
|
||||
failed: [string, any][];
|
||||
}
|
||||
|
||||
export function runTests(fixture: any): TestResults {
|
||||
let results: TestResults = { passed: [], failed: [] };
|
||||
for (let testName in fixture) {
|
||||
let test = fixture[testName];
|
||||
if (typeof test === "function") {
|
||||
try {
|
||||
test();
|
||||
results.passed.push(testName);
|
||||
}
|
||||
catch (e) {
|
||||
results.failed.push([testName, e]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
export function printResults(results: TestResults): void {
|
||||
for (let [testName, error] of results.failed) {
|
||||
let message = "stack" in error ? error.stack : String(error);
|
||||
console.error(`${testName} failed.\n${message}`);
|
||||
}
|
||||
|
||||
let passedCount = results.passed.length;
|
||||
let failedCount = results.failed.length;
|
||||
let totalCount = passedCount + failedCount;
|
||||
|
||||
let message = `Run ${failedCount > 0 ? "failed" : "succeeded" }: passed: ${passedCount}, failed: ${failedCount}, total: ${totalCount}.`;
|
||||
if (results.failed.length) {
|
||||
console.error(message);
|
||||
}
|
||||
else {
|
||||
console.log(message);
|
||||
}
|
||||
}
|
208
node_modules/reflect-metadata/test/reflect/reflect-decorate.ts
generated
vendored
Normal file
208
node_modules/reflect-metadata/test/reflect/reflect-decorate.ts
generated
vendored
Normal file
@ -0,0 +1,208 @@
|
||||
// Reflect.decorate ( decorators, target [, propertyKey [, descriptor] ] )
|
||||
|
||||
import "../../Reflect";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForFunctionOverload() {
|
||||
let target = function() { };
|
||||
assert.throws(() => Reflect.decorate(undefined, target, undefined, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectDecorateThrowsIfTargetArgumentNotFunctionForFunctionOverload() {
|
||||
let decorators: (ClassDecorator | MethodDecorator | PropertyDecorator)[] = [];
|
||||
let target = {};
|
||||
assert.throws(() => Reflect.decorate(decorators, target, undefined, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForPropertyOverload() {
|
||||
let target = {};
|
||||
let name = "name";
|
||||
assert.throws(() => Reflect.decorate(undefined, target, name, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectDecorateThrowsIfTargetArgumentNotObjectForPropertyOverload() {
|
||||
let decorators: (ClassDecorator | MethodDecorator | PropertyDecorator)[] = [];
|
||||
let target = 1;
|
||||
let name = "name";
|
||||
assert.throws(() => Reflect.decorate(decorators, target, name, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectDecorateThrowsIfDecoratorsArgumentNotArrayForPropertyDescriptorOverload() {
|
||||
let target = {};
|
||||
let name = "name";
|
||||
let descriptor = {};
|
||||
assert.throws(() => Reflect.decorate(undefined, target, name, descriptor), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectDecorateThrowsIfTargetArgumentNotObjectForPropertyDescriptorOverload() {
|
||||
let decorators: (ClassDecorator | MethodDecorator | PropertyDecorator)[] = [];
|
||||
let target = 1;
|
||||
let name = "name";
|
||||
let descriptor = {};
|
||||
assert.throws(() => Reflect.decorate(decorators, target, name, descriptor), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectDecorateExecutesDecoratorsInReverseOrderForFunctionOverload() {
|
||||
let order: number[] = [];
|
||||
let decorators = [
|
||||
(target: Function): void => { order.push(0); },
|
||||
(target: Function): void => { order.push(1); }
|
||||
];
|
||||
let target = function() { };
|
||||
Reflect.decorate(decorators, target);
|
||||
assert.deepEqual(order, [1, 0]);
|
||||
}
|
||||
|
||||
export function ReflectDecorateExecutesDecoratorsInReverseOrderForPropertyOverload() {
|
||||
let order: number[] = [];
|
||||
let decorators = [
|
||||
(target: Object, name: string | symbol): void => { order.push(0); },
|
||||
(target: Object, name: string | symbol): void => { order.push(1); }
|
||||
];
|
||||
let target = {};
|
||||
let name = "name";
|
||||
Reflect.decorate(decorators, target, name, undefined);
|
||||
assert.deepEqual(order, [1, 0]);
|
||||
}
|
||||
|
||||
export function ReflectDecorateExecutesDecoratorsInReverseOrderForPropertyDescriptorOverload() {
|
||||
let order: number[] = [];
|
||||
let decorators = [
|
||||
(target: Object, name: string | symbol): void => { order.push(0); },
|
||||
(target: Object, name: string | symbol): void => { order.push(1); }
|
||||
];
|
||||
let target = {};
|
||||
let name = "name";
|
||||
let descriptor = {};
|
||||
Reflect.decorate(decorators, target, name, descriptor);
|
||||
assert.deepEqual(order, [1, 0]);
|
||||
}
|
||||
|
||||
export function ReflectDecoratorPipelineForFunctionOverload() {
|
||||
let A = function A(): void { };
|
||||
let B = function B(): void { };
|
||||
let decorators = [
|
||||
(target: Function): any => { return undefined; },
|
||||
(target: Function): any => { return A; },
|
||||
(target: Function): any => { return B; }
|
||||
];
|
||||
let target = function (): void { };
|
||||
let result = Reflect.decorate(decorators, target);
|
||||
assert.strictEqual(result, A);
|
||||
}
|
||||
|
||||
export function ReflectDecoratorPipelineForPropertyOverload() {
|
||||
let A = {};
|
||||
let B = {};
|
||||
let decorators = [
|
||||
(target: Object, name: string | symbol): any => { return undefined; },
|
||||
(target: Object, name: string | symbol): any => { return A; },
|
||||
(target: Object, name: string | symbol): any => { return B; }
|
||||
];
|
||||
let target = {};
|
||||
let result = Reflect.decorate(decorators, target, "name", undefined);
|
||||
assert.strictEqual(result, undefined);
|
||||
}
|
||||
|
||||
export function ReflectDecoratorPipelineForPropertyDescriptorOverload() {
|
||||
let A = {};
|
||||
let B = {};
|
||||
let C = {};
|
||||
let decorators = [
|
||||
(target: Object, name: string | symbol): any => { return undefined; },
|
||||
(target: Object, name: string | symbol): any => { return A; },
|
||||
(target: Object, name: string | symbol): any => { return B; }
|
||||
];
|
||||
let target = {};
|
||||
let result = Reflect.decorate(decorators, target, "name", C);
|
||||
assert.strictEqual(result, A);
|
||||
}
|
||||
|
||||
export function ReflectDecoratorCorrectTargetInPipelineForFunctionOverload() {
|
||||
let sent: Function[] = [];
|
||||
let A = function A(): void { };
|
||||
let B = function B(): void { };
|
||||
let decorators = [
|
||||
(target: Function): any => { sent.push(target); return undefined; },
|
||||
(target: Function): any => { sent.push(target); return undefined; },
|
||||
(target: Function): any => { sent.push(target); return A; },
|
||||
(target: Function): any => { sent.push(target); return B; }
|
||||
];
|
||||
let target = function (): void { };
|
||||
Reflect.decorate(decorators, target);
|
||||
assert.deepEqual(sent, [target, B, A, A]);
|
||||
}
|
||||
|
||||
export function ReflectDecoratorCorrectTargetInPipelineForPropertyOverload() {
|
||||
let sent: Object[] = [];
|
||||
let decorators = [
|
||||
(target: Object, name: string | symbol): any => { sent.push(target); },
|
||||
(target: Object, name: string | symbol): any => { sent.push(target); },
|
||||
(target: Object, name: string | symbol): any => { sent.push(target); },
|
||||
(target: Object, name: string | symbol): any => { sent.push(target); }
|
||||
];
|
||||
let target = { };
|
||||
Reflect.decorate(decorators, target, "name");
|
||||
assert.deepEqual(sent, [target, target, target, target]);
|
||||
}
|
||||
|
||||
export function ReflectDecoratorCorrectNameInPipelineForPropertyOverload() {
|
||||
let sent: (symbol | string)[] = [];
|
||||
let decorators = [
|
||||
(target: Object, name: string | symbol): any => { sent.push(name); },
|
||||
(target: Object, name: string | symbol): any => { sent.push(name); },
|
||||
(target: Object, name: string | symbol): any => { sent.push(name); },
|
||||
(target: Object, name: string | symbol): any => { sent.push(name); }
|
||||
];
|
||||
let target = { };
|
||||
Reflect.decorate(decorators, target, "name");
|
||||
assert.deepEqual(sent, ["name", "name", "name", "name"]);
|
||||
}
|
||||
|
||||
export function ReflectDecoratorCorrectTargetInPipelineForPropertyDescriptorOverload() {
|
||||
let sent: Object[] = [];
|
||||
let A = { };
|
||||
let B = { };
|
||||
let C = { };
|
||||
let decorators = [
|
||||
(target: Object, name: string | symbol): any => { sent.push(target); return undefined; },
|
||||
(target: Object, name: string | symbol): any => { sent.push(target); return undefined; },
|
||||
(target: Object, name: string | symbol): any => { sent.push(target); return A; },
|
||||
(target: Object, name: string | symbol): any => { sent.push(target); return B; }
|
||||
];
|
||||
let target = { };
|
||||
Reflect.decorate(decorators, target, "name", C);
|
||||
assert.deepEqual(sent, [target, target, target, target]);
|
||||
}
|
||||
|
||||
export function ReflectDecoratorCorrectNameInPipelineForPropertyDescriptorOverload() {
|
||||
let sent: (symbol | string)[] = [];
|
||||
let A = { };
|
||||
let B = { };
|
||||
let C = { };
|
||||
let decorators = [
|
||||
(target: Object, name: string | symbol): any => { sent.push(name); return undefined; },
|
||||
(target: Object, name: string | symbol): any => { sent.push(name); return undefined; },
|
||||
(target: Object, name: string | symbol): any => { sent.push(name); return A; },
|
||||
(target: Object, name: string | symbol): any => { sent.push(name); return B; }
|
||||
];
|
||||
let target = { };
|
||||
Reflect.decorate(decorators, target, "name", C);
|
||||
assert.deepEqual(sent, ["name", "name", "name", "name"]);
|
||||
}
|
||||
|
||||
export function ReflectDecoratorCorrectDescriptorInPipelineForPropertyDescriptorOverload() {
|
||||
let sent: PropertyDescriptor[] = [];
|
||||
let A = { };
|
||||
let B = { };
|
||||
let C = { };
|
||||
let decorators = [
|
||||
(target: Object, name: string | symbol, descriptor: PropertyDescriptor): any => { sent.push(descriptor); return undefined; },
|
||||
(target: Object, name: string | symbol, descriptor: PropertyDescriptor): any => { sent.push(descriptor); return undefined; },
|
||||
(target: Object, name: string | symbol, descriptor: PropertyDescriptor): any => { sent.push(descriptor); return A; },
|
||||
(target: Object, name: string | symbol, descriptor: PropertyDescriptor): any => { sent.push(descriptor); return B; }
|
||||
];
|
||||
let target = { };
|
||||
Reflect.decorate(decorators, target, "name", C);
|
||||
assert.deepEqual(sent, [C, B, A, A]);
|
||||
}
|
17
node_modules/reflect-metadata/test/reflect/reflect-definemetadata.ts
generated
vendored
Normal file
17
node_modules/reflect-metadata/test/reflect/reflect-definemetadata.ts
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
// Reflect.defineMetadata ( metadataKey, metadataValue, target, propertyKey )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectdefinemetadata--metadatakey-metadatavalue-target-propertykey-
|
||||
|
||||
import "../../Reflect";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function ReflectDefineMetadataInvalidTarget() {
|
||||
assert.throws(() => Reflect.defineMetadata("key", "value", undefined, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectDefineMetadataValidTargetWithoutTargetKey() {
|
||||
assert.doesNotThrow(() => Reflect.defineMetadata("key", "value", { }, undefined));
|
||||
}
|
||||
|
||||
export function ReflectDefineMetadataValidTargetWithTargetKey() {
|
||||
assert.doesNotThrow(() => Reflect.defineMetadata("key", "value", { }, "name"));
|
||||
}
|
38
node_modules/reflect-metadata/test/reflect/reflect-deletemetadata.ts
generated
vendored
Normal file
38
node_modules/reflect-metadata/test/reflect/reflect-deletemetadata.ts
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Reflect.deleteMetadata ( metadataKey, target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectdeletemetadata--metadatakey-target--propertykey-
|
||||
|
||||
import "../../Reflect";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function ReflectDeleteMetadataInvalidTarget() {
|
||||
assert.throws(() => Reflect.deleteMetadata("key", undefined, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectDeleteMetadataWhenNotDefinedWithoutTargetKey() {
|
||||
let obj = {};
|
||||
let result = Reflect.deleteMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
|
||||
export function ReflectDeleteMetadataWhenDefinedWithoutTargetKey() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
let result = Reflect.deleteMetadata("key", obj, undefined);
|
||||
assert.equal(result, true);
|
||||
}
|
||||
|
||||
export function ReflectDeleteMetadataWhenDefinedOnPrototypeWithoutTargetKey() {
|
||||
let prototype = {};
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
let obj = Object.create(prototype);
|
||||
let result = Reflect.deleteMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
|
||||
export function ReflectHasOwnMetadataAfterDeleteMetadata() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
Reflect.deleteMetadata("key", obj, undefined);
|
||||
let result = Reflect.hasOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
51
node_modules/reflect-metadata/test/reflect/reflect-getmetadata.ts
generated
vendored
Normal file
51
node_modules/reflect-metadata/test/reflect/reflect-getmetadata.ts
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// Reflect.getMetadata ( metadataKey, target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectgetmetadata--metadatakey-target--propertykey-
|
||||
|
||||
import "../../Reflect";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function ReflectGetMetadataInvalidTarget() {
|
||||
assert.throws(() => Reflect.getMetadata("key", undefined, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataWithoutTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.getMetadata("key", obj, undefined);
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataWithoutTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
let result = Reflect.getMetadata("key", obj, undefined);
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
let result = Reflect.getMetadata("key", obj, undefined);
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataWithTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.getMetadata("key", obj, "name");
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataWithTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
let result = Reflect.getMetadata("key", obj, "name");
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataWithTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
let result = Reflect.getMetadata("key", obj, "name");
|
||||
assert.equal(result, "value");
|
||||
}
|
98
node_modules/reflect-metadata/test/reflect/reflect-getmetadatakeys.ts
generated
vendored
Normal file
98
node_modules/reflect-metadata/test/reflect/reflect-getmetadatakeys.ts
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
// Reflect.getMetadataKeys ( target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectgetmetadatakeys--target--propertykey-
|
||||
|
||||
import "../../Reflect";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function ReflectGetMetadataKeysInvalidTarget() {
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
assert.throws(() => Reflect.getMetadataKeys(undefined, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysWithoutTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysWithoutTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
let result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
let result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysOrderWithoutTargetKey() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key0", "value", obj, undefined);
|
||||
let result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysOrderAfterRedefineWithoutTargetKey() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key0", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
let result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysOrderWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
Reflect.defineMetadata("key2", "value", prototype, undefined);
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key0", "value", obj, undefined);
|
||||
let result = Reflect.getMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key1", "key0", "key2"]);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysWithTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.getMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysWithTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
let result = Reflect.getMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysWithTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
let result = Reflect.getMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysOrderAfterRedefineWithTargetKey() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, "name");
|
||||
Reflect.defineMetadata("key0", "value", obj, "name");
|
||||
Reflect.defineMetadata("key1", "value", obj, "name");
|
||||
let result = Reflect.getMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
|
||||
export function ReflectGetMetadataKeysOrderWithTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
Reflect.defineMetadata("key2", "value", prototype, "name");
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key1", "value", obj, "name");
|
||||
Reflect.defineMetadata("key0", "value", obj, "name");
|
||||
let result = Reflect.getMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key1", "key0", "key2"]);
|
||||
}
|
51
node_modules/reflect-metadata/test/reflect/reflect-getownmetadata.ts
generated
vendored
Normal file
51
node_modules/reflect-metadata/test/reflect/reflect-getownmetadata.ts
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// Reflect.getOwnMetadata ( metadataKey, target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectgetownmetadata--metadatakey-target--propertykey-
|
||||
|
||||
import "../../Reflect";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function ReflectGetOwnMetadataInvalidTarget() {
|
||||
assert.throws(() => Reflect.getOwnMetadata("key", undefined, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataWithoutTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.getOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataWithoutTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
let result = Reflect.getOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
let result = Reflect.getOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataWithTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.getOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, undefined);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataWithTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
let result = Reflect.getOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, "value");
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataWithTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
let result = Reflect.getOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, undefined);
|
||||
}
|
78
node_modules/reflect-metadata/test/reflect/reflect-getownmetadatakeys.ts
generated
vendored
Normal file
78
node_modules/reflect-metadata/test/reflect/reflect-getownmetadatakeys.ts
generated
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
// Reflect.getOwnMetadataKeysKeys ( target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectgetownmetadatakeyskeys--target--propertykey-
|
||||
|
||||
import "../../Reflect";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function ReflectGetOwnMetadataKeysKeysInvalidTarget() {
|
||||
// 1. If Type(target) is not Object, throw a TypeError exception.
|
||||
assert.throws(() => Reflect.getOwnMetadataKeys(undefined, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataKeysWithoutTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.getOwnMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataKeysWithoutTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
let result = Reflect.getOwnMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataKeysWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
let result = Reflect.getOwnMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataKeysOrderWithoutTargetKey() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key0", "value", obj, undefined);
|
||||
let result = Reflect.getOwnMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataKeysOrderAfterRedefineWithoutTargetKey() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key0", "value", obj, undefined);
|
||||
Reflect.defineMetadata("key1", "value", obj, undefined);
|
||||
let result = Reflect.getOwnMetadataKeys(obj, undefined);
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataKeysWithTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.getOwnMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataKeysWithTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
let result = Reflect.getOwnMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key"]);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataKeysWithTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
let result = Reflect.getOwnMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, []);
|
||||
}
|
||||
|
||||
export function ReflectGetOwnMetadataKeysOrderAfterRedefineWithTargetKey() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key1", "value", obj, "name");
|
||||
Reflect.defineMetadata("key0", "value", obj, "name");
|
||||
Reflect.defineMetadata("key1", "value", obj, "name");
|
||||
let result = Reflect.getOwnMetadataKeys(obj, "name");
|
||||
assert.deepEqual(result, ["key1", "key0"]);
|
||||
}
|
51
node_modules/reflect-metadata/test/reflect/reflect-hasmetadata.ts
generated
vendored
Normal file
51
node_modules/reflect-metadata/test/reflect/reflect-hasmetadata.ts
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// Reflect.hasMetadata ( metadataKey, target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflecthasmetadata--metadatakey-target--propertykey-
|
||||
|
||||
import "../../Reflect";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function ReflectHasMetadataInvalidTarget() {
|
||||
assert.throws(() => Reflect.hasMetadata("key", undefined, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectHasMetadataWithoutTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.hasMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
|
||||
export function ReflectHasMetadataWithoutTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
let result = Reflect.hasMetadata("key", obj, undefined);
|
||||
assert.equal(result, true);
|
||||
}
|
||||
|
||||
export function ReflectHasMetadataWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
let result = Reflect.hasMetadata("key", obj, undefined);
|
||||
assert.equal(result, true);
|
||||
}
|
||||
|
||||
export function ReflectHasMetadataWithTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.hasMetadata("key", obj, "name");
|
||||
assert.equal(result, false);
|
||||
}
|
||||
|
||||
export function ReflectHasMetadataWithTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
let result = Reflect.hasMetadata("key", obj, "name");
|
||||
assert.equal(result, true);
|
||||
}
|
||||
|
||||
export function ReflectHasMetadataWithTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
let result = Reflect.hasMetadata("key", obj, "name");
|
||||
assert.equal(result, true);
|
||||
}
|
51
node_modules/reflect-metadata/test/reflect/reflect-hasownmetadata.ts
generated
vendored
Normal file
51
node_modules/reflect-metadata/test/reflect/reflect-hasownmetadata.ts
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
// Reflect.hasOwnMetadata ( metadataKey, target [, propertyKey] )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflecthasownmetadata--metadatakey-target--propertykey-
|
||||
|
||||
import "../../Reflect";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function ReflectHasOwnMetadataInvalidTarget() {
|
||||
assert.throws(() => Reflect.hasOwnMetadata("key", undefined, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectHasOwnMetadataWithoutTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.hasOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
|
||||
export function ReflectHasOwnMetadataWithoutTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, undefined);
|
||||
let result = Reflect.hasOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, true);
|
||||
}
|
||||
|
||||
export function ReflectHasOwnMetadataWithoutTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, undefined);
|
||||
let result = Reflect.hasOwnMetadata("key", obj, undefined);
|
||||
assert.equal(result, false);
|
||||
}
|
||||
|
||||
export function ReflectHasOwnMetadataWithTargetKeyWhenNotDefined() {
|
||||
let obj = {};
|
||||
let result = Reflect.hasOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, false);
|
||||
}
|
||||
|
||||
export function ReflectHasOwnMetadataWithTargetKeyWhenDefined() {
|
||||
let obj = {};
|
||||
Reflect.defineMetadata("key", "value", obj, "name");
|
||||
let result = Reflect.hasOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, true);
|
||||
}
|
||||
|
||||
export function ReflectHasOwnMetadataWithTargetKeyWhenDefinedOnPrototype() {
|
||||
let prototype = {};
|
||||
let obj = Object.create(prototype);
|
||||
Reflect.defineMetadata("key", "value", prototype, "name");
|
||||
let result = Reflect.hasOwnMetadata("key", obj, "name");
|
||||
assert.equal(result, false);
|
||||
}
|
38
node_modules/reflect-metadata/test/reflect/reflect-metadata.ts
generated
vendored
Normal file
38
node_modules/reflect-metadata/test/reflect/reflect-metadata.ts
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Reflect.metadata ( metadataKey, metadataValue )
|
||||
// - https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#reflectmetadata--metadatakey-metadatavalue-
|
||||
|
||||
import "../../Reflect";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function ReflectMetadataReturnsDecoratorFunction() {
|
||||
let result = Reflect.metadata("key", "value");
|
||||
assert.equal(typeof result, "function");
|
||||
}
|
||||
|
||||
export function ReflectMetadataDecoratorThrowsWithInvalidTargetWithTargetKey() {
|
||||
let decorator = Reflect.metadata("key", "value");
|
||||
assert.throws(() => decorator(undefined, "name"), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectMetadataDecoratorThrowsWithInvalidTargetWithoutTargetKey() {
|
||||
let decorator = Reflect.metadata("key", "value");
|
||||
assert.throws(() => decorator({}, undefined), TypeError);
|
||||
}
|
||||
|
||||
export function ReflectMetadataDecoratorSetsMetadataOnTargetWithoutTargetKey() {
|
||||
let decorator = Reflect.metadata("key", "value");
|
||||
let target = function () {}
|
||||
decorator(target);
|
||||
|
||||
let result = Reflect.hasOwnMetadata("key", target, undefined);
|
||||
assert.equal(result, true);
|
||||
}
|
||||
|
||||
export function ReflectMetadataDecoratorSetsMetadataOnTargetWithTargetKey() {
|
||||
let decorator = Reflect.metadata("key", "value");
|
||||
let target = {}
|
||||
decorator(target, "name");
|
||||
|
||||
let result = Reflect.hasOwnMetadata("key", target, "name");
|
||||
assert.equal(result, true);
|
||||
}
|
5
node_modules/reflect-metadata/test/run.ts
generated
vendored
Normal file
5
node_modules/reflect-metadata/test/run.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { runTests, printResults } from './harness';
|
||||
import * as spec from "./spec";
|
||||
|
||||
let results = runTests(spec);
|
||||
printResults(results);
|
10
node_modules/reflect-metadata/test/spec.ts
generated
vendored
Normal file
10
node_modules/reflect-metadata/test/spec.ts
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
export * from "./reflect/reflect-decorate";
|
||||
export * from "./reflect/reflect-metadata";
|
||||
export * from "./reflect/reflect-definemetadata";
|
||||
export * from "./reflect/reflect-hasownmetadata";
|
||||
export * from "./reflect/reflect-hasmetadata";
|
||||
export * from "./reflect/reflect-getownmetadata";
|
||||
export * from "./reflect/reflect-getmetadata";
|
||||
export * from "./reflect/reflect-getownmetadatakeys";
|
||||
export * from "./reflect/reflect-getmetadatakeys";
|
||||
export * from "./reflect/reflect-deletemetadata";
|
26
node_modules/reflect-metadata/test/tsconfig.json
generated
vendored
Normal file
26
node_modules/reflect-metadata/test/tsconfig.json
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"noImplicitAny": true,
|
||||
"sourceMap": true,
|
||||
"module": "commonjs",
|
||||
"outDir": "../temp/"
|
||||
},
|
||||
"files": [
|
||||
"../Reflect.ts",
|
||||
"../typings/node.d.ts",
|
||||
"reflect/reflect-decorate.ts",
|
||||
"reflect/reflect-metadata.ts",
|
||||
"reflect/reflect-definemetadata.ts",
|
||||
"reflect/reflect-hasownmetadata.ts",
|
||||
"reflect/reflect-hasmetadata.ts",
|
||||
"reflect/reflect-getownmetadata.ts",
|
||||
"reflect/reflect-getmetadata.ts",
|
||||
"reflect/reflect-getownmetadatakeys.ts",
|
||||
"reflect/reflect-getmetadatakeys.ts",
|
||||
"reflect/reflect-deletemetadata.ts",
|
||||
"harness.ts",
|
||||
"spec.ts",
|
||||
"run.ts"
|
||||
]
|
||||
}
|
10
node_modules/reflect-metadata/tsconfig.json
generated
vendored
Normal file
10
node_modules/reflect-metadata/tsconfig.json
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"noImplicitAny": true,
|
||||
"sourceMap": true
|
||||
},
|
||||
"files": [
|
||||
"Reflect.ts"
|
||||
]
|
||||
}
|
13
node_modules/reflect-metadata/typings/node.d.ts
generated
vendored
Normal file
13
node_modules/reflect-metadata/typings/node.d.ts
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
declare module "assert" {
|
||||
function ok(test: any, message?: string): void;
|
||||
function fail(message?: string): void;
|
||||
function equal(actual: any, expected: any, message?: string): void;
|
||||
function notEqual(actual: any, expected: any, message?: string): void;
|
||||
function deepEqual(actual: any, expected: any, message?: string): void;
|
||||
function notDeepEqual(actual: any, expected: any, message?: string): void;
|
||||
function strictEqual(actual: any, expected: any, message?: string): void;
|
||||
function notStrictEqual(actual: any, expected: any, message?: string): void;
|
||||
function throws(block: () => void, error?: ErrorConstructor | RegExp | ((err: any) => boolean), message?: string): void;
|
||||
function doesNotThrow(block: () => void, message?: string): void;
|
||||
function ifError(value: any): boolean;
|
||||
}
|
Reference in New Issue
Block a user