Last change
on this file since b738035 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
963 bytes
|
Line | |
---|
1 | var $ = require('../internals/export');
|
---|
2 | var ReflectMetadataModule = require('../internals/reflect-metadata');
|
---|
3 | var anObject = require('../internals/an-object');
|
---|
4 |
|
---|
5 | var toMetadataKey = ReflectMetadataModule.toKey;
|
---|
6 | var getOrCreateMetadataMap = ReflectMetadataModule.getMap;
|
---|
7 | var store = ReflectMetadataModule.store;
|
---|
8 |
|
---|
9 | // `Reflect.deleteMetadata` method
|
---|
10 | // https://github.com/rbuckton/reflect-metadata
|
---|
11 | $({ target: 'Reflect', stat: true }, {
|
---|
12 | deleteMetadata: function deleteMetadata(metadataKey, target /* , targetKey */) {
|
---|
13 | var targetKey = arguments.length < 3 ? undefined : toMetadataKey(arguments[2]);
|
---|
14 | var metadataMap = getOrCreateMetadataMap(anObject(target), targetKey, false);
|
---|
15 | if (metadataMap === undefined || !metadataMap['delete'](metadataKey)) return false;
|
---|
16 | if (metadataMap.size) return true;
|
---|
17 | var targetMetadata = store.get(target);
|
---|
18 | targetMetadata['delete'](targetKey);
|
---|
19 | return !!targetMetadata.size || store['delete'](target);
|
---|
20 | }
|
---|
21 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.