source: trip-planner-front/node_modules/core-js/internals/reflect-metadata.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.8 KB
Line 
1// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
2var Map = require('../modules/es.map');
3var WeakMap = require('../modules/es.weak-map');
4var shared = require('../internals/shared');
5
6var metadata = shared('metadata');
7var store = metadata.store || (metadata.store = new WeakMap());
8
9var getOrCreateMetadataMap = function (target, targetKey, create) {
10 var targetMetadata = store.get(target);
11 if (!targetMetadata) {
12 if (!create) return;
13 store.set(target, targetMetadata = new Map());
14 }
15 var keyMetadata = targetMetadata.get(targetKey);
16 if (!keyMetadata) {
17 if (!create) return;
18 targetMetadata.set(targetKey, keyMetadata = new Map());
19 } return keyMetadata;
20};
21
22var ordinaryHasOwnMetadata = function (MetadataKey, O, P) {
23 var metadataMap = getOrCreateMetadataMap(O, P, false);
24 return metadataMap === undefined ? false : metadataMap.has(MetadataKey);
25};
26
27var ordinaryGetOwnMetadata = function (MetadataKey, O, P) {
28 var metadataMap = getOrCreateMetadataMap(O, P, false);
29 return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey);
30};
31
32var ordinaryDefineOwnMetadata = function (MetadataKey, MetadataValue, O, P) {
33 getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue);
34};
35
36var ordinaryOwnMetadataKeys = function (target, targetKey) {
37 var metadataMap = getOrCreateMetadataMap(target, targetKey, false);
38 var keys = [];
39 if (metadataMap) metadataMap.forEach(function (_, key) { keys.push(key); });
40 return keys;
41};
42
43var toMetadataKey = function (it) {
44 return it === undefined || typeof it == 'symbol' ? it : String(it);
45};
46
47module.exports = {
48 store: store,
49 getMap: getOrCreateMetadataMap,
50 has: ordinaryHasOwnMetadata,
51 get: ordinaryGetOwnMetadata,
52 set: ordinaryDefineOwnMetadata,
53 keys: ordinaryOwnMetadataKeys,
54 toKey: toMetadataKey
55};
Note: See TracBrowser for help on using the repository browser.