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);
}
let args = text.split(' ', 2);
if (Number.isNumeric(args[0])) {
// only process if it's numeric
if (args.length === 1) {
// single arg
// just assume we're using the currently selected units
value = moment.duration(Number(args[0]), this.unit().shortKey);
}
else if (args.length === 2) {
// two args
// first determine the units used
let unitName = moment.normalizeUnits(args[1]);
if (String.isNullOrEmpty(unitName) === false) {
let unit = Enumerable
.fromArray(TimeSpanUnits)
.filter(x => x.key === unitName)
.firstOrDefault();
if (unit != null) {
// if the unit type is valid process the value
value = moment.duration(Number(args[0]), unitName);
// only update the currently selected units if they are parsed
this.unit(unit);
}
}
}
}
}
this.setValue(value);
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 =
private getActivator(route: Route) {
// default by just fetching the mapped route directly
let activator = this.routingMap[route.path];
// if there is no directly mapped route, check for a parameterized route
if (activator == null) {
let result = Enumerable
.fromArray(Object.keys(this.routingMap))
.filter(x => x != null && x.length > 0 && x[0] === '^')
.map(x => ({ key: x, regex: new RegExp(x, 'i') }))
.map(x => ({ key: x.key, match: x.regex.exec(route.path) }))
.filter(x => x.match != null)
.map(x => ({ match: x.match, activator: this.routingMap[x.key] }))
.firstOrDefault();
if (result != null) {
// if we found a parameterized route then set the match properties on the route
route.match = result.match;
activator = result.activator;
}
}
logger.error('Could not find external references', err)
}
})
yield* merge(findLocalReferences(), findExternalReferences()).pipe(
// Same-repo references
// Cross-repo references
// Find canonical source location
filter(chunk => chunk.length > 0),
tap({
next: chunk => {
span.log({ event: 'chunk', count: chunk.length })
},
}),
// Rewrite URIs and convert from LSP to Sourcegraph Location
map(chunk =>
chunk
.map(location => {
try {
return convertLocation({
...location,
uri: toSourcegraphTextDocumentUri(new URL(location.uri)).href,
})
} catch (err) {
return undefined
}
})
.filter((location): location is Exclude => !!location)
),
// Aggregate individual chunks into a growing array (which is what Sourcegraph expects)
scan(
(allReferences, chunk) => allReferences.concat(chunk),
}
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) {
test('AsyncIterable#zip equal length no selector', async () => {
const xs = of(1, 2, 3);
const ys = of(4, 5, 6);
const zs = of(7, 8, 9);
const res = combineLatest(xs, ys, zs);
const it = res[Symbol.asyncIterator]();
let next = await it.next();
expect(next.done).toBeFalsy();
expect(sequenceEqual(next.value, [3, 6, 7])).toBeTruthy();
next = await it.next();
expect(next.done).toBeFalsy();
expect(sequenceEqual(next.value, [3, 6, 8])).toBeTruthy();
next = await it.next();
expect(next.done).toBeFalsy();
expect(sequenceEqual(next.value, [3, 6, 9])).toBeTruthy();
test('AsyncIterable#zip equal length with selector', async () => {
const xs = of(1, 2, 3);
const ys = of(4, 5, 6);
const zs = of(7, 8, 9);
const res = combineLatest(([x, y, z]) => x + y + z, xs, ys, zs);
const it = res[Symbol.asyncIterator]();
await hasNext(it, 16);
await hasNext(it, 17);
await hasNext(it, 18);
await noNext(it);
});
test('AsyncIterable#zip equal length with selector', async () => {
const xs = of(1, 2, 3);
const ys = of(4, 5, 6);
const zs = of(7, 8, 9);
const res = combineLatest(([x, y, z]) => x + y + z, xs, ys, zs);
const it = res[Symbol.asyncIterator]();
await hasNext(it, 16);
await hasNext(it, 17);
await hasNext(it, 18);
await noNext(it);
});