本文整理匯總了TypeScript中dom5/lib/index-next.predicates.AND方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript predicates.AND方法的具體用法?TypeScript predicates.AND怎麽用?TypeScript predicates.AND使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dom5/lib/index-next.predicates
的用法示例。
在下文中一共展示了predicates.AND方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1:
const hasMarker = (doc: ASTNode, id: string) => {
const marker = dom5.query(
doc,
dom5.predicates.AND(
dom5.predicates.hasTagName('div'),
dom5.predicates.hasAttrValue('id', id)));
return marker != null;
};
示例2: require
import {predicates as p} from 'dom5/lib/index-next';
import * as parse5 from 'parse5';
import * as url from 'url';
import File = require('vinyl');
import {AsyncTransformStream, getFileContents} from './streams';
const attrValueMatches = (attrName: string, regex: RegExp) => {
return (node: parse5.ASTNode) => {
const attrValue = dom5.getAttribute(node, attrName);
return attrValue != null && regex.test(attrValue);
};
};
const webcomponentsLoaderRegex = /\bwebcomponents\-(loader|lite)\.js\b/;
const webcomponentsLoaderMatcher = p.AND(
p.hasTagName('script'), attrValueMatches('src', webcomponentsLoaderRegex));
/**
* Wraps `addCustomElementsEs5Adapter()` in a `stream.Transform`.
*/
export class CustomElementsEs5AdapterInjector extends
AsyncTransformStream<File, File> {
constructor() {
super({objectMode: true});
}
protected async *
_transformIter(files: AsyncIterable<File>): AsyncIterable<File> {
for await (const file of files) {
if (file.contents === null || file.extname !== '.html') {
yield file;
示例3: simpleSelectorToPredicate
return dom5.predicates.OR(...parsed.map((simpleSelectors) => {
return dom5.predicates.AND(...simpleSelectors.map(
(selector) => simpleSelectorToPredicate(selector, isPolymerTemplate)));
}));