massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / reflect-metadata.js
1 // TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
2 require('../modules/es.map');
3 require('../modules/es.weak-map');
4 var getBuiltIn = require('../internals/get-built-in');
5 var uncurryThis = require('../internals/function-uncurry-this');
6 var shared = require('../internals/shared');
7
8 var Map = getBuiltIn('Map');
9 var WeakMap = getBuiltIn('WeakMap');
10 var push = uncurryThis([].push);
11
12 var metadata = shared('metadata');
13 var store = metadata.store || (metadata.store = new WeakMap());
14
15 var getOrCreateMetadataMap = function (target, targetKey, create) {
16   var targetMetadata = store.get(target);
17   if (!targetMetadata) {
18     if (!create) return;
19     store.set(target, targetMetadata = new Map());
20   }
21   var keyMetadata = targetMetadata.get(targetKey);
22   if (!keyMetadata) {
23     if (!create) return;
24     targetMetadata.set(targetKey, keyMetadata = new Map());
25   } return keyMetadata;
26 };
27
28 var ordinaryHasOwnMetadata = function (MetadataKey, O, P) {
29   var metadataMap = getOrCreateMetadataMap(O, P, false);
30   return metadataMap === undefined ? false : metadataMap.has(MetadataKey);
31 };
32
33 var ordinaryGetOwnMetadata = function (MetadataKey, O, P) {
34   var metadataMap = getOrCreateMetadataMap(O, P, false);
35   return metadataMap === undefined ? undefined : metadataMap.get(MetadataKey);
36 };
37
38 var ordinaryDefineOwnMetadata = function (MetadataKey, MetadataValue, O, P) {
39   getOrCreateMetadataMap(O, P, true).set(MetadataKey, MetadataValue);
40 };
41
42 var ordinaryOwnMetadataKeys = function (target, targetKey) {
43   var metadataMap = getOrCreateMetadataMap(target, targetKey, false);
44   var keys = [];
45   if (metadataMap) metadataMap.forEach(function (_, key) { push(keys, key); });
46   return keys;
47 };
48
49 var toMetadataKey = function (it) {
50   return it === undefined || typeof it == 'symbol' ? it : String(it);
51 };
52
53 module.exports = {
54   store: store,
55   getMap: getOrCreateMetadataMap,
56   has: ordinaryHasOwnMetadata,
57   get: ordinaryGetOwnMetadata,
58   set: ordinaryDefineOwnMetadata,
59   keys: ordinaryOwnMetadataKeys,
60   toKey: toMetadataKey
61 };