You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
587 B
JavaScript
27 lines
587 B
JavaScript
"use strict";
|
|
|
|
const matchValue = require("match-value");
|
|
|
|
const node = require("../../ast-node");
|
|
|
|
module.exports = function makeIndexObject(fieldsResult, properties) {
|
|
if (fieldsResult.type === "local") {
|
|
return node({
|
|
type: "localIndex"
|
|
});
|
|
} else {
|
|
let isComposite = matchValue(fieldsResult.type, {
|
|
single: false,
|
|
composite: true
|
|
});
|
|
|
|
return node({
|
|
type: "index",
|
|
isComposite: isComposite,
|
|
field: (isComposite === false) ? fieldsResult.value : undefined,
|
|
fields: (isComposite === true) ? fieldsResult.value : undefined,
|
|
... properties
|
|
});
|
|
}
|
|
};
|