@abraham/reflection 中文文档教程
Reflection
reflect-metadata 的轻量级 ES 模块实现TypeScript 的实验性装饰器支持。
Why?
这个库的主要原因是提供一个可以作为模块包含在内的更小的实现。
- ES module
reflection
can be loaded with<script type="module" src="..."></script>
- Size (uncompressed)
reflect-metadata
is ~50Kcore-js/es7/reflect
is ~80K@abraham/reflection
is ~3K
了解如何通过切换到这个来从生产 Angular 应用中减少 20K。
Install
npm install @abraham/reflection
Usage
import '@abraham/reflection';
Reflect.defineMetadata(metadataKey, metadataValue, target);
您还可以导入 Reflection
:
import { Reflection as Reflect } from '@abraham/reflection';
Reflect.defineMetadata(metadataKey, metadataValue, target);
API
Reflection 目前并未涵盖 reflect-metadata 的完整 API 表面。 可以使用以下方法:
Reflect.decorate(...);
Reflect.defineMetadata(...);
Reflect.getMetadata(...);
Reflect.hasMetadata(...);
Reflect.getOwnMetadata(...);
Reflect.hasOwnMetadata(...);
Reflect.metadata(...);
Reflection
Lightweight ES Module implementation of reflect-metadata to work with TypeScript's experimental decorator support.
Why?
The main reason for this library is to provide a much smaller implementation that can be included as a module.
- ES module
reflection
can be loaded with<script type="module" src="..."></script>
- Size (uncompressed)
reflect-metadata
is ~50Kcore-js/es7/reflect
is ~80K@abraham/reflection
is ~3K
Read about how to drop 20K from your production Angular app by switching to this.
Install
npm install @abraham/reflection
Usage
import '@abraham/reflection';
Reflect.defineMetadata(metadataKey, metadataValue, target);
You can also import Reflection
:
import { Reflection as Reflect } from '@abraham/reflection';
Reflect.defineMetadata(metadataKey, metadataValue, target);
API
Reflection does not currently cover the complete API surface of reflect-metadata. The following methods are available:
Reflect.decorate(...);
Reflect.defineMetadata(...);
Reflect.getMetadata(...);
Reflect.hasMetadata(...);
Reflect.getOwnMetadata(...);
Reflect.hasOwnMetadata(...);
Reflect.metadata(...);
更多
你可能也喜欢
- 2vdom 中文文档教程
- @0x-klaytn/utils 中文文档教程
- @0x/contracts-exchange 中文文档教程
- @1e3/ui 中文文档教程
- @1hive/connect-app-dandelion-voting 中文文档教程
- @36node/xlsx-toolkits 中文文档教程
- @3acaga/react-bing-maps 中文文档教程
- @3dwayfinder/wayfinder-vue-components 中文文档教程
- @4geit/rct-collapsible-component 中文文档教程
- @51nodes/decentralized-schema-registry 中文文档教程