schematics/src/ng-add/utils.js
function isImported(source, classifiedName, importPath) {
    const allNodes = getSourceNodes(source);
    const matchingNodes = allNodes
        .filter(node => node.kind === ts.SyntaxKind.ImportDeclaration)
        .filter((imp) => imp.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral)
        .filter((imp) => {
        return imp.moduleSpecifier.text === importPath;
    })
        .filter((imp) => {
        if (!imp.importClause) {
            return false;
        }
        const nodes = findNodes(imp.importClause, ts.SyntaxKind.ImportSpecifier).filter(n => n.getText() === classifiedName);
        return nodes.length > 0;
    });
    return matchingNodes.length > 0;
}
function isImported(source, classifiedName, importPath) {
    const allNodes = getSourceNodes(source);
    const matchingNodes = allNodes
        .filter(node => node.kind === ts.SyntaxKind.ImportDeclaration)
        .filter((imp) => imp.moduleSpecifier.kind === ts.SyntaxKind.StringLiteral)
        .filter((imp) => {
        return imp.moduleSpecifier.text === importPath;
    })
        .filter((imp) => {
        if (!imp.importClause) {
            return false;
        }
        const nodes = findNodes(imp.importClause, ts.SyntaxKind.ImportSpecifier).filter(n => n.getText() === classifiedName);
        return nodes.length > 0;
    });
    return matchingNodes.length > 0;
}
function isImported ( source , classifiedName , importPath ) { const allNodes = getSourceNodes ( source ) ; const matchingNodes = allNodes . filter ( node => node . kind === ts . SyntaxKind . ImportDeclaration ) . filter ( ( imp ) => imp . moduleSpecifier . kind === ts . SyntaxKind . StringLiteral ) . filter ( ( imp ) => { return imp . moduleSpecifier . text === importPath ; } ) . filter ( ( imp ) => { if ( ! imp . importClause ) { return false ; } const nodes = findNodes ( imp . importClause , ts . SyntaxKind . ImportSpecifier ) . filter ( n => n . getText ( ) === classifiedName ) ; return nodes . length > 0 ; } ) ; return matchingNodes . length > 0 ; }
Determine if an import already exists.
Determine if an import already exists .