本文整理汇总了TypeScript中compassql/build/src/wildcard.isWildcard函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isWildcard函数的具体用法?TypeScript isWildcard怎么用?TypeScript isWildcard使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isWildcard函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
return encodings.reduce((encodingMixins, encQ) => {
if (isWildcard(encQ.channel)) {
encodingMixins.anyEncodings.push(encQ);
} else {
const {channel: _, ...fieldDef} = encQ;
encodingMixins.encoding[encQ.channel] = fieldDef;
}
return encodingMixins;
}, {encoding: {}, anyEncodings: []});
示例2: hasWildcards
export function hasWildcards(spec: SpecQuery): HasWildcard {
let hasWildcardField = false, hasWildcardFn = false, hasWildcardChannel = false;
for (const encQ of spec.encodings) {
if (isValueQuery(encQ)) {
continue;
} else if (isAutoCountQuery(encQ)) {
if (isWildcard(encQ.autoCount)) {
hasWildcardFn = true;
}
} else { // encQ is FieldQuery
if (isWildcard(encQ.field)) {
hasWildcardField = true;
}
if (isWildcard(encQ.aggregate) ||
isWildcard(encQ.bin) ||
isWildcard(encQ.timeUnit)) {
hasWildcardFn = true;
}
if (isWildcard(encQ.channel)) {
hasWildcardChannel = true;
}
}
}
return {
hasAnyWildcard: hasWildcardChannel || hasWildcardField || hasWildcardFn,
hasWildcardField,
hasWildcardFn,
hasWildcardChannel
};
}
示例3: isWildcardChannelId
export function isWildcardChannelId(shelfId: ShelfId): shelfId is ShelfWildcardChannelId {
return isWildcard(shelfId.channel);
}
示例4: shelfSpecReducer
export function shelfSpecReducer(shelfSpec: Readonly<ShelfUnitSpec> = DEFAULT_SHELF_UNIT_SPEC,
action: Action,
schema: Schema): ShelfUnitSpec {
switch (action.type) {
case SHELF_CLEAR:
return DEFAULT_SHELF_UNIT_SPEC;
case SHELF_MARK_CHANGE_TYPE: {
const mark = action.payload;
return {
...shelfSpec,
mark
};
}
case SHELF_FIELD_ADD: {
const {shelfId, fieldDef} = action.payload;
return addEncoding(shelfSpec, shelfId, fieldDef);
}
case SHELF_FIELD_AUTO_ADD: {
const {fieldDef} = action.payload;
if (shelfSpec.anyEncodings.length > 0 || isWildcard(fieldDef.field)) {
// If there was an encoding shelf or if the field is a wildcard, just add to wildcard shelf
return {
...shelfSpec,
anyEncodings: [
...shelfSpec.anyEncodings,
{
channel: SHORT_WILDCARD,
...fieldDef
}
]
};
} else {
// Otherwise, query for the best encoding if there is no wildcard channel
const query = autoAddFieldQuery(shelfSpec, fieldDef);
const rec = recommend(query, schema);
const topSpecQuery = getTopSpecQueryItem(rec.result).specQuery;
return {
...fromSpecQuery(topSpecQuery, shelfSpec.config),
// retain auto-mark if mark is previously auto
...(isWildcard(shelfSpec.mark) ? {mark: shelfSpec.mark} : {})
};
}
}
case SHELF_FIELD_REMOVE:
return removeEncoding(shelfSpec, action.payload).shelf;
case SHELF_FIELD_MOVE: {
const {to, from} = action.payload;
const {fieldDef: fieldDefFrom, shelf: removedShelf1} = removeEncoding(shelfSpec, from);
const {fieldDef: fieldDefTo, shelf: removedShelf2} = removeEncoding(removedShelf1, to);
const addedShelf1 = addEncoding(removedShelf2, to, fieldDefFrom);
const addedShelf2 = addEncoding(addedShelf1, from, fieldDefTo);
return addedShelf2;
}
case SHELF_FUNCTION_CHANGE: {
const {shelfId, fn} = action.payload;
return modifyEncoding(shelfSpec, shelfId, (fieldDef: Readonly<ShelfFieldDef | ShelfAnyEncodingDef>) => {
// Remove all existing functions then assign new function
const {aggregate: _a, bin: _b, timeUnit: _t, hasFn: _h, ...newFieldDef} = fieldDef;
return {
...newFieldDef,
...(getFunctionMixins(fn))
};
});
}
case SHELF_SPEC_LOAD:
const {spec} = action.payload;
const specQ = isWildcard(shelfSpec.mark) ? {
...fromSpec(spec),
mark: SHORT_WILDCARD
} : fromSpec(spec);
// Restore wildcard mark if the shelf previously has wildcard mark.
return fromSpecQuery(specQ, shelfSpec.config);
}
return shelfSpec;
}