source: trip-planner-front/node_modules/@babel/types/lib/converters/toKeyAlias.js@ 6a80231

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

initial commit

  • Property mode set to 100644
File size: 1013 bytes
RevLine 
[6a3a178]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = toKeyAlias;
7
8var _generated = require("../validators/generated");
9
10var _cloneNode = require("../clone/cloneNode");
11
12var _removePropertiesDeep = require("../modifications/removePropertiesDeep");
13
14function toKeyAlias(node, key = node.key) {
15 let alias;
16
17 if (node.kind === "method") {
18 return toKeyAlias.increment() + "";
19 } else if ((0, _generated.isIdentifier)(key)) {
20 alias = key.name;
21 } else if ((0, _generated.isStringLiteral)(key)) {
22 alias = JSON.stringify(key.value);
23 } else {
24 alias = JSON.stringify((0, _removePropertiesDeep.default)((0, _cloneNode.default)(key)));
25 }
26
27 if (node.computed) {
28 alias = `[${alias}]`;
29 }
30
31 if (node.static) {
32 alias = `static:${alias}`;
33 }
34
35 return alias;
36}
37
38toKeyAlias.uid = 0;
39
40toKeyAlias.increment = function () {
41 if (toKeyAlias.uid >= Number.MAX_SAFE_INTEGER) {
42 return toKeyAlias.uid = 0;
43 } else {
44 return toKeyAlias.uid++;
45 }
46};
Note: See TracBrowser for help on using the repository browser.