本文整理匯總了TypeScript中vega-util.splitAccessPath函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript splitAccessPath函數的具體用法?TypeScript splitAccessPath怎麽用?TypeScript splitAccessPath使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了splitAccessPath函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: accessPathWithDatum
export function accessPathWithDatum(path: string, datum='datum') {
const pieces = splitAccessPath(path);
const prefixes = [];
for (let i = 1; i <= pieces.length; i++) {
const prefix = `[${pieces.slice(0,i).map(stringValue).join('][')}]`;
prefixes.push(`${datum}${prefix}`);
}
return prefixes.join(' && ');
}
示例2: prefixGenerator
export function prefixGenerator(a: Set<string>): Set<string> {
const prefixes = new Set<string>();
for (const x of a) {
const splitField = splitAccessPath(x);
// Wrap every element other than the first in `[]`
const wrappedWithAccessors = splitField.map((y, i) => (i === 0 ? y : `[${y}]`));
const computedPrefixes = wrappedWithAccessors.map((_, i) => wrappedWithAccessors.slice(0, i + 1).join(''));
computedPrefixes.forEach(y => prefixes.add(y));
}
return prefixes;
}
示例3: accessPathDepth
export function accessPathDepth(path: string) {
if (!path) {
return 0;
}
return splitAccessPath(path).length;
}
示例4: removePathFromField
export function removePathFromField(path: string) {
return `${splitAccessPath(path).join('.')}`;
}
示例5: replacePathInField
export function replacePathInField(path: string) {
return `${splitAccessPath(path)
.map(p => p.replace('.', '\\.'))
.join('\\.')}`;
}
示例6: flatAccessWithDatum
export function flatAccessWithDatum(path: string, datum: 'datum' | 'parent' | 'datum.datum' = 'datum') {
return `${datum}[${stringValue(splitAccessPath(path).join('.'))}]`;
}