move flattenable keys to types
This commit is contained in:
parent
5f2df40f6d
commit
c4da0253c5
@ -1,6 +1,7 @@
|
||||
import TraversalPath from "./path";
|
||||
import flatten from "lodash/array/flatten";
|
||||
import compact from "lodash/array/compact";
|
||||
import t from "../types";
|
||||
|
||||
export default class TraversalContext {
|
||||
constructor(scope, opts, state, parentPath) {
|
||||
@ -42,7 +43,7 @@ export default class TraversalContext {
|
||||
if (this.shouldFlatten) {
|
||||
node[key] = flatten(node[key]);
|
||||
|
||||
if (key === "body" || key === "expressions") {
|
||||
if (t.FLATTENABLE_KEYS.indexOf(key) >= 0) {
|
||||
// we can safely compact this
|
||||
node[key] = compact(node[key]);
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ function registerType(type, skipAliasCheck) {
|
||||
|
||||
t.STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
|
||||
t.NATIVE_TYPE_NAMES = ["Array", "Object", "Number", "Boolean", "Date", "Array", "String"];
|
||||
t.FLATTENABLE_KEYS = ["body", "expressions"];
|
||||
t.FOR_INIT_KEYS = ["left", "init"];
|
||||
|
||||
t.VISITOR_KEYS = require("./visitor-keys");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user