.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / core-js / internals / internal-metadata.js
1 var hiddenKeys = require('../internals/hidden-keys');
2 var isObject = require('../internals/is-object');
3 var has = require('../internals/has');
4 var defineProperty = require('../internals/object-define-property').f;
5 var uid = require('../internals/uid');
6 var FREEZING = require('../internals/freezing');
7
8 var METADATA = uid('meta');
9 var id = 0;
10
11 var isExtensible = Object.isExtensible || function () {
12   return true;
13 };
14
15 var setMetadata = function (it) {
16   defineProperty(it, METADATA, { value: {
17     objectID: 'O' + ++id, // object ID
18     weakData: {}          // weak collections IDs
19   } });
20 };
21
22 var fastKey = function (it, create) {
23   // return a primitive with prefix
24   if (!isObject(it)) return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
25   if (!has(it, METADATA)) {
26     // can't set metadata to uncaught frozen object
27     if (!isExtensible(it)) return 'F';
28     // not necessary to add metadata
29     if (!create) return 'E';
30     // add missing metadata
31     setMetadata(it);
32   // return object ID
33   } return it[METADATA].objectID;
34 };
35
36 var getWeakData = function (it, create) {
37   if (!has(it, METADATA)) {
38     // can't set metadata to uncaught frozen object
39     if (!isExtensible(it)) return true;
40     // not necessary to add metadata
41     if (!create) return false;
42     // add missing metadata
43     setMetadata(it);
44   // return the store of weak collections IDs
45   } return it[METADATA].weakData;
46 };
47
48 // add metadata on freeze-family methods calling
49 var onFreeze = function (it) {
50   if (FREEZING && meta.REQUIRED && isExtensible(it) && !has(it, METADATA)) setMetadata(it);
51   return it;
52 };
53
54 var meta = module.exports = {
55   REQUIRED: false,
56   fastKey: fastKey,
57   getWeakData: getWeakData,
58   onFreeze: onFreeze
59 };
60
61 hiddenKeys[METADATA] = true;