mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-02 20:19:30 +08:00
29 lines
No EOL
756 B
Text
29 lines
No EOL
756 B
Text
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = removeProperties;
|
|
|
|
var _constants = require("../constants");
|
|
|
|
const CLEAR_KEYS = ["tokens", "start", "end", "loc", "raw", "rawValue"];
|
|
const CLEAR_KEYS_PLUS_COMMENTS = [..._constants.COMMENT_KEYS, "comments", ...CLEAR_KEYS];
|
|
|
|
function removeProperties(node, opts = {}) {
|
|
const map = opts.preserveComments ? CLEAR_KEYS : CLEAR_KEYS_PLUS_COMMENTS;
|
|
|
|
for (const key of map) {
|
|
if (node[key] != null) node[key] = undefined;
|
|
}
|
|
|
|
for (const key of Object.keys(node)) {
|
|
if (key[0] === "_" && node[key] != null) node[key] = undefined;
|
|
}
|
|
|
|
const symbols = Object.getOwnPropertySymbols(node);
|
|
|
|
for (const sym of symbols) {
|
|
node[sym] = null;
|
|
}
|
|
} |