Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getCommentsBetween(
document: parse5.ASTNode,
from: parse5.ASTNode|undefined,
until: parse5.ASTNode|undefined): string[] {
const nodesStart =
from === undefined ? nodesInside(document) : nodesAfter(from);
const nodesBetween =
IterableX.from(nodesStart).takeWhile((node) => node !== until);
const commentNodesBetween =
nodesBetween.filter((node) => dom5.isCommentNode(node));
const commentStringsBetween =
commentNodesBetween.map((node) => dom5.getTextContent(node));
const formattedCommentStringsBetween =
commentStringsBetween.map((commentText) => {
// If it looks like there might be jsdoc in the comment, start the
// comment with an extra * so that the js comment looks like a jsdoc
// comment.
if (/@\w+/.test(commentText)) {
return '*' + commentText;
}
return commentText;
});
return Array.from(formattedCommentStringsBetween);
}
protected getColumnDefinitions(): Array | undefined {
const count = React.Children.count(this.props.children);
if (count === 0) {
// try and auto-gen columns
const item = this.getListItems().getItems().first();
if (item == null) {
this.logger.warn('Unable to Autogenerate Columns');
return undefined;
}
return Iterable
.from(Object.keys(item))
.orderBy(x => x)
.map(x => (
))
.toArray();
}
if (count === 1) {
const elem = React.Children.only(this.props.children);
if (React.isType(elem, GridViewColumns)) {
return React.Children.toArray(elem.props.children);
}
}
},
});
}
}
const usedIdentifiers = collectIdentifierNames(program, ignoredIdentifiers);
const jsExplicitImports = new Set();
// Rewrite HTML Imports to JS imports
const jsImportDeclarations = [];
for (const htmlImport of this.getHtmlImports()) {
const importedJsDocumentUrl = this.convertDocumentUrl(
this.urlHandler.getDocumentUrl(htmlImport.document));
const references = importedReferences.get(importedJsDocumentUrl);
const namedExports =
new Set(IterableX.from(references || []).map((ref) => ref.target));
const jsFormattedImportUrl =
this.formatImportUrl(importedJsDocumentUrl, htmlImport.originalUrl);
jsImportDeclarations.push(...getImportDeclarations(
jsFormattedImportUrl, namedExports, references, usedIdentifiers));
jsExplicitImports.add(importedJsDocumentUrl);
}
// Add JS imports for any additional, implicit HTML imports
for (const jsImplicitImportUrl of importedReferences.keys()) {
if (jsExplicitImports.has(jsImplicitImportUrl)) {
continue;
}
const references = importedReferences.get(jsImplicitImportUrl);
const namedExports =
}
const options = {
inDir: sourceDir,
outDir: sourceDir,
packageName: '@polymer/polymer',
packageVersion: '3.0.0',
};
const analyzer = configureAnalyzer(options);
const analysis = await analyzer.analyzePackage();
const converter = configureConverter(analysis, options);
const results = await converter.convert();
const resultPaths = IterableX.from(results.entries())
.filter(([_, v]) => v !== undefined)
.map(([k]) => k);
const expectedPaths = IterableX.from(walkDir(expectedDir))
.map((f) => f as ConvertedDocumentFilePath)
.filter((f) => f !== './package.json');
const allPathsUnsorted = new Set(resultPaths.concat(expectedPaths));
const allPaths = [...allPathsUnsorted].sort((a, b) => a.localeCompare(b));
for (const outPath of allPaths) {
const jsContents = results.get(outPath);
if (jsContents === undefined) {
exitCode = 1;
console.log(chalk.bold.red(`✕ ${outPath} (missing file)`));
continue;
}
const expectedJsPath = path.resolve(expectedDir, outPath);
let expectedJsContents;
try {
expectedJsContents = fs.readFileSync(expectedJsPath, 'utf8');
} catch (e) {
.toProperty([], (a, b) => Iterable.from(a).sequenceEqual(Iterable.from(b)));
protected getResponse(request: DataSourceRequest | undefined): ObservableOrValue | undefined> {
if (request == null) {
return undefined;
}
const items = Iterable
.from(this.source.value);
return this.getResponseFromItems(items, request);
}
protected renderTableHeaderRow() {
if (this.columns == null) {
return undefined;
}
const renderHeaders = Iterable
.from(this.columns)
.some(x => GridViewColumn.canRenderHeader(x));
if (renderHeaders) {
const props = this.trimProps({
itemTemplate: this.props.headerTemplate,
});
return (
{
this.columns
.map(x => {
if (React.isValidElement(x)) {
return (
function getNamespaceNames(analysis: Analysis) {
return IterableX
.from(analysis.getFeatures(
{kind: 'namespace', externalPackages: true, imported: true}))
.map((n) => {
const name = n.name;
if (name.startsWith('window.')) {
return name.slice('window.'.length);
}
return name;
});
}
getItems() {
return Iterable
.from(this.getItemsSource())
.flatMap(x => this.flattenItems(x));
}
export function flattenItems(
item: T,
itemsSource: (item: T) => (IterableLike | undefined),
): Iterable {
const items = itemsSource(item);
return items == null ?
Iterable.of(item) :
Iterable
.from(items)
.flatMap(x => flattenItems(x, itemsSource))
.startWith(item);
}