Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
765 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.default = removeProperties;
|
---|
7 |
|
---|
8 | var _constants = require("../constants");
|
---|
9 |
|
---|
10 | const CLEAR_KEYS = ["tokens", "start", "end", "loc", "raw", "rawValue"];
|
---|
11 |
|
---|
12 | const CLEAR_KEYS_PLUS_COMMENTS = _constants.COMMENT_KEYS.concat(["comments"]).concat(CLEAR_KEYS);
|
---|
13 |
|
---|
14 | function removeProperties(node, opts = {}) {
|
---|
15 | const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS;
|
---|
16 |
|
---|
17 | for (const key of map) {
|
---|
18 | if (node[key] != null) node[key] = undefined;
|
---|
19 | }
|
---|
20 |
|
---|
21 | for (const key of Object.keys(node)) {
|
---|
22 | if (key[0] === "_" && node[key] != null) node[key] = undefined;
|
---|
23 | }
|
---|
24 |
|
---|
25 | const symbols = Object.getOwnPropertySymbols(node);
|
---|
26 |
|
---|
27 | for (const sym of symbols) {
|
---|
28 | node[sym] = null;
|
---|
29 | }
|
---|
30 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.