本文整理匯總了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;
};