本文整理汇总了TypeScript中@ephox/katamari.Obj.has方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Obj.has方法的具体用法?TypeScript Obj.has怎么用?TypeScript Obj.has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/katamari.Obj
的用法示例。
在下文中一共展示了Obj.has方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: cSetFieldValue
const chains = Arr.flatten(Obj.mapToArray(tabSelectors, (value, key): Chain<any, any>[] => {
if (Obj.has(data, key)) {
const newValue = typeof data[key] === 'object' ? data[key].value : data[key];
return [ cSetFieldValue(tabSelectors[key], newValue) ];
} else if (Obj.has(data, 'dimensions') && Obj.has(data.dimensions, key)) {
return [ cSetFieldValue(tabSelectors[key], data.dimensions[key]) ];
} else {
return [];
}
}));
示例2:
Obj.each(expected.pattern, (value, key) => {
if (Obj.has<any, string>(pattern, key)) {
Assertions.assertEq('Pattern ' + (i + 1) + ' property `' + key + '` is not equal', value, pattern[key]);
} else {
assert.fail('Pattern ' + (i + 1) + ' property `' + key + '` is missing');
}
});
示例3: callback
return Obj.bifilter(currentFormats, (callbacks: FormatChangeCallback[], format: string) => {
if (!Obj.has(matchedFormats, format)) {
// Execute callbacks
Arr.each(callbacks, (callback: FormatChangeCallback) => {
callback(false, { node: elm, format, parents });
});
return false;
} else {
return true;
}
}).t;
示例4:
Arr.each(items, (item, i) => {
if (isSeparator(item, i)) {
if (currentSplit.length > 0) {
allSplits.push(currentSplit);
}
currentSplit = [ ];
if (Obj.has(item.dom, 'innerHtml')) {
currentSplit.push(item);
}
} else {
currentSplit.push(item);
}
});
示例5: if
const set = (mode: string) => {
if (mode === activeMode) {
return;
} else if (!Obj.has(availableModes, mode)) {
throw new Error(`Editor mode '${mode}' is invalid`);
}
if (editor.initialized) {
switchToMode(mode);
} else {
editor.on('init', () => switchToMode(mode));
}
};
示例6: addContextMenuGroup
const items = Arr.foldl(menuConfig, (acc, name) => {
// Either read and convert the list of items out of the plugin, or assume it's a standard menu item reference
if (Obj.has(contextMenus, name)) {
const items = contextMenus[name].update(selectedElement);
if (Type.isString(items)) {
return addContextMenuGroup(acc, items.split(' '));
} else if (items.length > 0) {
// TODO: Should we add a ValueSchema check here?
const allItems = Arr.map(items, makeContextItem);
return addContextMenuGroup(acc, allItems);
} else {
return acc;
}
} else {
return acc.concat([name]);
}
}, []);
示例7: if
const realItems = Arr.foldl(items, (acc, item) => {
if (isMenuItemReference(item)) {
if (item === '') {
return acc;
} else if (item === '|') {
// Ignore the separator if it's at the start or a duplicate
return acc.length > 0 && !isSeparator(acc[acc.length - 1]) ? acc.concat([separator]) : acc;
} else if (Obj.has(menuItems, item.toLowerCase())) {
return acc.concat([ menuItems[item.toLowerCase()] ]);
} else {
// TODO: Add back after TINY-3232 is implemented
// console.error('No representation for menuItem: ' + item);
return acc;
}
} else {
return acc.concat([ item ]);
}
}, []);
示例8:
const isNestedFormat = (format: AllowedFormat): format is NestedFormatting => {
return Obj.has(format as Record<string, any>, 'items');
};
示例9:
const updated = Arr.map(shortcut, (segment: string) => {
// search lowercase, but if not found use the original
const search = segment.toLowerCase().trim();
return Obj.has(replace, search) ? replace[search] : segment;
});
示例10:
const translateCategory = (categories: Record<string, string>, name: string) => {
return Obj.has(categories, name) ? categories[name] : name;
};