9.0.10076 • Published 4 years ago

@acoustic-content-sdk/schematics-utils v9.0.10076

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

npm

API Documentation

Home > @acoustic-content-sdk/schematics-utils

schematics-utils package

Helper library to implement schematics.

Classes

ClassDescription
InsertChangeWill add text to the source code.
NoopChangeAn operation that does nothing.
RemoveChangeWill remove text from the source code.
ReplaceChangeWill replace text from the source code.

Enumerations

EnumerationDescription
Builders
DEP_TYPE
NodeDependencyType
ProjectType

Functions

FunctionDescription
addBootstrapToModule(source, modulePath, classifiedName, importPath)Custom function to insert an export into NgModule. It also imports it.
addDeclarationToModule(source, modulePath, classifiedName, importPath)Custom function to insert a declaration (component, pipe, directive) into NgModule declarations. It also imports the component.
addEntryComponentToModule(source, modulePath, classifiedName, importPath)Custom function to insert an entryComponent into NgModule. It also imports it.
addExportToModule(source, modulePath, classifiedName, importPath)Custom function to insert an export into NgModule. It also imports it.
addImportsToModule(aFile, aModules, aHost)Changes the identified module by adding a couple of imports
addImportToModule(source, modulePath, classifiedName, importPath)Custom function to insert an NgModule into NgModule imports. It also imports the module.
addPackageJsonDependency(tree, dependency)
addProjectToWorkspace(workspace, name, project)
addProviderToModule(source, modulePath, classifiedName, importPath)Custom function to insert a provider into NgModule. It also imports it.
addRouteDeclarationToModule(source, fileToAdd, routeLiteral)Adds a new route declaration to a router module (i.e. has a RouterModule declaration)
addSymbolToNgModuleMetadata(source, ngModulePath, metadataField, symbolName, importPath)
addToWchToolsDependencies(aDeps, aPkg)
assertHasTrailingSlash(aValue)
assertIsEmail(aValue, aName)
assertIsUrl(aValue, aName)
assertIsValidUserName(aValue, aName)
assertNotNull(aValue, aName)
assertParameter(aValue, aParameterName)
buildDefaultPath(project)Build a default project path for generating.
buildRelativePath(from, to)Build a relative path from one file path to another file path.
byIdentifier(aName)
byName(aText)
byText(aText)
byType(aType)
byTypeAndName(aType, aName)
canonicalizeJSON(aData)
changeSourceFile(aFile, aOp, aHost)
copyDir(aSrc, aDst, aHost, aLogger)Copies from source to target and overrides the target. But does not delete extra files
createLoggerService(context)Constructs the logger service on top of the context
createTransientTree(aRoot)Creates a transient copy of a tree
ensureTrailingSlash(aUrl)
findBootstrapModuleCall(host, mainPath)
findBootstrapModulePath(host, mainPath)
findDataDir(host, options)
findModule(host, generateDir, moduleExt, routingModuleExt)Function to find the "closest" module to a generated file's path.
findModuleFromOptions(host, options)Find the module referred by a set of options passed to the schematics.
findNode(node, kind, text)
findNodes(node, kind, max, recursive)Find all nodes from the AST in the subtree of node of SyntaxKind kind.
findPackageJson(aDir)
findProject(workspaceOrHost, options)Locates the workspace project, either from the configured project name, else falls back to the default project
findProjectName(workspaceOrHost, options)Locates the workspace project, either from the configured project name, else falls back to the default project
findSdkVersion(host)
findWchToolsOptions(host, options)
getAppFromConfig(config, appIndexOrName)
getAppModulePath(host, mainPath)
getConfig(host)
getContentOfKeyLiteral(_source, node)
getDecoratorMetadata(source, identifier, module)
getEnvironmentExportName(source)This function returns the name of the environment export whether this export is aliased or not. If the environment file is not imported, then it will return null.
getFirstNgModuleName(source)Given a source file with class(es), find the name of the first class.
getFolderForType(aType)
getMetadataField(node, metadataField)
getPackageJsonDependency(tree, name)
getPackageManager(aHost)Decodes the supported workspace from the host
getProject(workspaceOrHost, projectName)
getProjectTargets(project)
getProjectTargets(workspaceOrHost, projectName)
getRouterModuleDeclaration(source)Returns the RouterModule declaration from NgModule metadata, if any.
getSourceFile(host, path)
getSourceFileFromFileEntry(aEntry)
getSourceNodes(sourceFile)Get all the nodes from a source.
getWorkspace(host)
getWorkspacePath(host)
hasTrailingSlash(aUrl)
insertAfterLastOccurrence(nodes, toInsert, file, fallbackPos, syntaxKind)Insert toInsert after the last occurence of ts.SyntaxKind[nodesi.kind] or after the last of occurence of syntaxKind if the last occurence is a sub child of SyntaxKind[nodes[i].kind] and save the changes in file.
insertChanges(aChanges, aRecorder)
insertImport(source, fileToEdit, symbolName, fileName, isDefault)Add Import import { symbolName } from fileName if the import doesn't exit already. Assumes fileToEdit can be resolved and accessed.
insertLines(aSource, aInsert)
isImported(source, classifiedName, importPath)Determine if an import already exists.
isValidEmail(aValue)
isValidUrl(aValue)
isValidUserName(aValue)
isWorkspaceProject(project)
isWorkspaceSchema(workspace)
locatePackageJson(aDir)Locates the name of the package.json starting with the current directory
parseLines(aSource)
parseName(path, name)
readBufferOnTree(aHost, aRoot)Constructs the ReadBuffer callback on top of a host
readDirectoryOnTree(aHost, aRoot)Creates a function callback that reads files from a host
readRelativeDirectoryOnTree(aHost, aRoot)Creates a function callback that reads files from a host
readTextFileOnTree(aHost, aRoot)Constructs the ReadTextFile callback on top of a host
readWorkspace(aRoot)Reads a workspace definition based on a root path
removePackageJsonDependency(tree, name)
rxDownload(aUri, aDstFile)
rxFormPost(aUri, aData)
rxGet(aUri)
rxGetJson(aUri)
rxLocateDir(aSrcDir, aPredicate)Locates the directory across the parent chain for which the predicate matches
rxTransformHtmlFile(aName, aOp, aTree)Reads an HMTL from the tree and then transforms it using the given function. If the result is null or undefined, the file will be deleted, else replaced or created.
rxTransformHtmlFragment(aName, aOp, aTree)Reads an HMTL from the tree and then transforms it using the given function. If the result is null or undefined, the file will be deleted, else replaced or created.
rxTransformJsonFile(aName, aOp, aTree)Reads a JSON file from the tree and then transforms it using the given function. If the result is null or undefined, the file will be deleted, else replaced or created.
rxTransformLinesFile(aName, aOp, aTree)Reads a line based file from the tree and then transforms it using the given function. If the result is null or undefined, the file will be deleted, else replaced or created.
rxTransformTextFile(aName, aOp, aTree)Reads a text file from the tree and then transforms it using the given function. If the result is null or undefined, the file will be deleted, else replaced or created.
rxUnzipFromUrl(aTree, aSrcUrl, aDstDir, aSkip)
safeWrite(aPath, aFile, aHost)Overwrites file content, but only if it differs
serializeJson(aData)
serializeLines(aSource)
syncDir(aSrc, aDst, aHost, aLogger)
targetBuildNotFoundError()
updateField(aName, aGenerator, aObj)
updateMinVersion(aName, aMinVersion, aPkg, aType)Updates the package JSON to use at least the given version
updateWorkspace(workspace)
validateApiUrl(aUrl, bValidateWithCredentials)Tests if the API URL is valid and if we have sufficient credentials to access the API
validateCredentials(aApiUrl, aCredentials)
validateHtmlSelector(selector)
validateName(name)
validateProjectName(projectName)
writeFilesOnTree(aHost, aRoot)Returns an operator that writes all file descriptors to disk

Interfaces

InterfaceDescription
AppConfig
AppShellBuilderOptions
BrowserBuilderBaseOptions
BrowserBuilderOptions
BuilderTarget
Change
CliConfig
E2EOptions
ExtractI18nOptions
FileReplacements
HostCopyright Google Inc. All Rights Reserved.Use of this source code is governed by an MIT-style license that can be found in the LICENSE file at https://angular.io/license
LibraryBuilderOptions
LintBuilderOptions
Location
ModuleOptions
NodeDependency
ServeBuilderOptions
ServerBuilderOptions
TestBuilderOptions
WorkspaceProject
WorkspaceSchema
WorkspaceTargets
ZipEntry

Variables

VariableDescription
ajaxRequest
configPath
createXHR
htmlSelectorRe
MODULE_EXT
NOOP_LOGGER
ROUTING_MODULE_EXT
rxDeleteFile
rxReadTextFile
rxReadZipExport the function to extract a zip file
rxTmpFile
rxUnlink
TENANT_BASED_URL_REGEXP
VERSIONVersion and build number of the package
WCHTOOLS_DEPENDENCIES
writeBufferOnTreeConstructs a WriteTextFile on top of a host
writeTextFileOnTreeConstructs a WriteTextFile on top of a host

Type Aliases

Type AliasDescription
AppShellBuilderTarget
BrowserBuilderTarget
E2EBuilderTarget
ExtractI18nBuilderTarget
LibraryBuilderTarget
LintBuilderTarget
OutputHashing
ServeBuilderTarget
ServerBuilderTarget
TestBuilderTarget
TransformCallback
TransformWithoutPath
TransformWithPath

Home > @acoustic-content-sdk/schematics-utils > InsertChange

InsertChange class

Will add text to the source code.

Signature:

export declare class InsertChange implements Change 

Constructors

ConstructorModifiersDescription
(constructor)(path, pos, toAdd)Constructs a new instance of the InsertChange class

Properties

PropertyModifiersTypeDescription
descriptionstring
ordernumber
pathstring
posnumber
toAddstring

Methods

MethodModifiersDescription
apply(host)This method does not insert spaces if there is none in the original string.

Home > @acoustic-content-sdk/schematics-utils > NoopChange

NoopChange class

An operation that does nothing.

Signature:

export declare class NoopChange implements Change 

Properties

PropertyModifiersTypeDescription
descriptionstring
ordernumber
pathany

Methods

MethodModifiersDescription
apply()

Home > @acoustic-content-sdk/schematics-utils > RemoveChange

RemoveChange class

Will remove text from the source code.

Signature:

export declare class RemoveChange implements Change 

Constructors

ConstructorModifiersDescription
(constructor)(path, pos, toRemove)Constructs a new instance of the RemoveChange class

Properties

PropertyModifiersTypeDescription
descriptionstring
ordernumber
pathstring

Methods

MethodModifiersDescription
apply(host)

Home > @acoustic-content-sdk/schematics-utils > ReplaceChange

ReplaceChange class

Will replace text from the source code.

Signature:

export declare class ReplaceChange implements Change 

Constructors

ConstructorModifiersDescription
(constructor)(path, pos, oldText, newText)Constructs a new instance of the ReplaceChange class

Properties

PropertyModifiersTypeDescription
descriptionstring
ordernumber
pathstring

Methods

MethodModifiersDescription
apply(host)

Home > @acoustic-content-sdk/schematics-utils > Builders

Builders enum

Signature:

export declare enum Builders 

Enumeration Members

MemberValueDescription
AppShell"@angular-devkit/build-angular:app-shell"
Browser"@angular-devkit/build-angular:browser"
DevServer"@angular-devkit/build-angular:dev-server"
ExtractI18n"@angular-devkit/build-angular:extract-i18n"
Karma"@angular-devkit/build-angular:karma"
NgPackagr"@angular-devkit/build-ng-packagr:build"
Protractor"@angular-devkit/build-angular:protractor"
Server"@angular-devkit/build-angular:server"
TsLint"@angular-devkit/build-angular:tslint"

Home > @acoustic-content-sdk/schematics-utils > DEP_TYPE

DEP_TYPE enum

Signature:

export declare enum DEP_TYPE 

Enumeration Members

MemberValueDescription
DEVELOPMENT2
PEER0
RUNTIME1

Home > @acoustic-content-sdk/schematics-utils > NodeDependencyType

NodeDependencyType enum

Signature:

export declare enum NodeDependencyType 

Enumeration Members

MemberValueDescription
Default"dependencies"
Dev"devDependencies"
Optional"optionalDependencies"
Peer"peerDependencies"

Home > @acoustic-content-sdk/schematics-utils > ProjectType

ProjectType enum

Signature:

export declare enum ProjectType 

Enumeration Members

MemberValueDescription
Application"application"
Library"library"

Home > @acoustic-content-sdk/schematics-utils > addBootstrapToModule

addBootstrapToModule() function

Custom function to insert an export into NgModule. It also imports it.

Signature:

export declare function addBootstrapToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];

Parameters

ParameterTypeDescription
sourceSourceFile
modulePathstring
classifiedNamestring
importPathstring

Returns:

Change[]

Home > @acoustic-content-sdk/schematics-utils > addDeclarationToModule

addDeclarationToModule() function

Custom function to insert a declaration (component, pipe, directive) into NgModule declarations. It also imports the component.

Signature:

export declare function addDeclarationToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];

Parameters

ParameterTypeDescription
sourceSourceFile
modulePathstring
classifiedNamestring
importPathstring

Returns:

Change[]

Home > @acoustic-content-sdk/schematics-utils > addEntryComponentToModule

addEntryComponentToModule() function

Warning: This API is now obsolete.

  • Since version 9.0.0 with Ivy, entryComponents is no longer necessary.

Custom function to insert an entryComponent into NgModule. It also imports it.

Signature:

export declare function addEntryComponentToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];

Parameters

ParameterTypeDescription
sourceSourceFile
modulePathstring
classifiedNamestring
importPathstring

Returns:

Change[]

Home > @acoustic-content-sdk/schematics-utils > addExportToModule

addExportToModule() function

Custom function to insert an export into NgModule. It also imports it.

Signature:

export declare function addExportToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];

Parameters

ParameterTypeDescription
sourceSourceFile
modulePathstring
classifiedNamestring
importPathstring

Returns:

Change[]

Home > @acoustic-content-sdk/schematics-utils > addImportsToModule

addImportsToModule() function

Changes the identified module by adding a couple of imports

Signature:

export declare function addImportsToModule(aFile: string, aModules: {
    [identifier: string]: string;
}, aHost: Tree): void;

Parameters

ParameterTypeDescription
aFilestringthe filename
aModules{ identifier: string: string;}the modules to be added
aHostTreethe tree

Returns:

void

Home > @acoustic-content-sdk/schematics-utils > addImportToModule

addImportToModule() function

Custom function to insert an NgModule into NgModule imports. It also imports the module.

Signature:

export declare function addImportToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];

Parameters

ParameterTypeDescription
sourceSourceFile
modulePathstring
classifiedNamestring
importPathstring

Returns:

Change[]

Home > @acoustic-content-sdk/schematics-utils > addPackageJsonDependency

addPackageJsonDependency() function

Signature:

export declare function addPackageJsonDependency(tree: Tree, dependency: NodeDependency): void;

Parameters

ParameterTypeDescription
treeTree
dependencyNodeDependency

Returns:

void

Home > @acoustic-content-sdk/schematics-utils > addProjectToWorkspace

addProjectToWorkspace() function

Signature:

export declare function addProjectToWorkspace<TProjectType extends ProjectType = ProjectType.Application>(workspace: WorkspaceSchema, name: string, project: WorkspaceProject<TProjectType>): Rule;

Parameters

ParameterTypeDescription
workspaceWorkspaceSchema
namestring
projectWorkspaceProject<TProjectType>

Returns:

Rule

Home > @acoustic-content-sdk/schematics-utils > addProviderToModule

addProviderToModule() function

Custom function to insert a provider into NgModule. It also imports it.

Signature:

export declare function addProviderToModule(source: SourceFile, modulePath: string, classifiedName: string, importPath: string): Change[];

Parameters

ParameterTypeDescription
sourceSourceFile
modulePathstring
classifiedNamestring
importPathstring

Returns:

Change[]

Home > @acoustic-content-sdk/schematics-utils > addRouteDeclarationToModule

addRouteDeclarationToModule() function

Adds a new route declaration to a router module (i.e. has a RouterModule declaration)

Signature:

export declare function addRouteDeclarationToModule(source: SourceFile, fileToAdd: string, routeLiteral: string): Change;

Parameters

ParameterTypeDescription
sourceSourceFile
fileToAddstring
routeLiteralstring

Returns:

Change

Home > @acoustic-content-sdk/schematics-utils > addSymbolToNgModuleMetadata

addSymbolToNgModuleMetadata() function

Signature:

export declare function addSymbolToNgModuleMetadata(source: SourceFile, ngModulePath: string, metadataField: string, symbolName: string, importPath?: string | null): Change[];

Parameters

ParameterTypeDescription
sourceSourceFile
ngModulePathstring
metadataFieldstring
symbolNamestring
importPathstring | null

Returns:

Change[]

Home > @acoustic-content-sdk/schematics-utils > addToWchToolsDependencies

addToWchToolsDependencies() function

Signature:

export declare function addToWchToolsDependencies(aDeps: string[], aPkg: any): void;

Parameters

ParameterTypeDescription
aDepsstring[]
aPkgany

Returns:

void

Home > @acoustic-content-sdk/schematics-utils > assertHasTrailingSlash

assertHasTrailingSlash() function

Signature:

export declare function assertHasTrailingSlash(aValue: any): string;

Parameters

ParameterTypeDescription
aValueany

Returns:

string

Home > @acoustic-content-sdk/schematics-utils > assertIsEmail

assertIsEmail() function

Signature:

export declare function assertIsEmail(aValue: any, aName?: string): string;

Parameters

ParameterTypeDescription
aValueany
aNamestring

Returns:

string

Home > @acoustic-content-sdk/schematics-utils > assertIsUrl

assertIsUrl() function

Signature:

export declare function assertIsUrl(aValue: any, aName?: string): string;

Parameters

ParameterTypeDescription
aValueany
aNamestring

Returns:

string

Home > @acoustic-content-sdk/schematics-utils > assertIsValidUserName

assertIsValidUserName() function

Signature:

export declare function assertIsValidUserName(aValue: any, aName?: string): string;

Parameters

ParameterTypeDescription
aValueany
aNamestring

Returns:

string

Home > @acoustic-content-sdk/schematics-utils > assertNotNull

assertNotNull() function

Signature:

export declare function assertNotNull(aValue: any, aName?: string): void;

Parameters

ParameterTypeDescription
aValueany
aNamestring

Returns:

void

Home > @acoustic-content-sdk/schematics-utils > assertParameter

assertParameter() function

Signature:

export declare function assertParameter(aValue: any, aParameterName: string): void;

Parameters

ParameterTypeDescription
aValueany
aParameterNamestring

Returns:

void

Home > @acoustic-content-sdk/schematics-utils > buildDefaultPath

buildDefaultPath() function

Build a default project path for generating.

Signature:

export declare function buildDefaultPath(project: WorkspaceProject): string;

Parameters

ParameterTypeDescription
projectWorkspaceProjectThe project to build the path for.

Returns:

string

Home > @acoustic-content-sdk/schematics-utils > buildRelativePath

buildRelativePath() function

Build a relative path from one file path to another file path.

Signature:

export declare function buildRelativePath(from: string, to: string): string;

Parameters

ParameterTypeDescription
fromstring
tostring

Returns:

string

Home > @acoustic-content-sdk/schematics-utils > byIdentifier

byIdentifier() function

Signature:

export declare function byIdentifier(aName: string): Predicate<Node>;

Parameters

ParameterTypeDescription
aNamestring

Returns:

Predicate<Node>

Home > @acoustic-content-sdk/schematics-utils > byName

byName() function

Signature:

export declare function byName(aText: string): Predicate<NamedDeclaration>;

Parameters

ParameterTypeDescription
aTextstring

Returns:

Predicate<NamedDeclaration>

Home > @acoustic-content-sdk/schematics-utils > byText

byText() function

Signature:

export declare function byText(aText: string): Predicate<Node>;

Parameters

ParameterTypeDescription
aTextstring

Returns:

Predicate<Node>

Home > @acoustic-content-sdk/schematics-utils > byType

byType() function

Signature:

export declare function byType(aType: SyntaxKind): Predicate<Node>;

Parameters

ParameterTypeDescription
aTypeSyntaxKind

Returns:

Predicate<Node>

Home > @acoustic-content-sdk/schematics-utils > byTypeAndName

byTypeAndName() function

Signature:

export declare function byTypeAndName(aType: SyntaxKind, aName: string): Predicate<Node>;

Parameters

ParameterTypeDescription
aTypeSyntaxKind
aNamestring

Returns:

Predicate<Node>

Home > @acoustic-content-sdk/schematics-utils > canonicalizeJSON

canonicalizeJSON() function

Signature:

declare function _canonicalize(aData: any): any;

Parameters

ParameterTypeDescription
aDataany

Returns:

any

Home > @acoustic-content-sdk/schematics-utils > changeSourceFile

changeSourceFile() function

Signature:

export declare function changeSourceFile(aFile: string, aOp: (aFile: string, aContent: SourceFile) => Change[], aHost: Tree): void;

Parameters

ParameterTypeDescription
aFilestring
aOp(aFile: string, aContent: SourceFile) => Change[]
aHostTree

Returns:

void

Home > @acoustic-content-sdk/schematics-utils > copyDir

copyDir() function

Copies from source to target and overrides the target. But does not delete extra files

Signature:

export declare function copyDir(aSrc: string, aDst: string, aHost: Tree, aLogger?: Logger): Tree;

Parameters

ParameterTypeDescription
aSrcstringsource directory
aDststringtarget directory
aHostTreetree
aLoggerLogger

Returns:

Tree

the tree

Home > @acoustic-content-sdk/schematics-utils > createLoggerService

createLoggerService() function

Constructs the logger service on top of the context

Signature:

export declare function createLoggerService(context: SchematicContext): LoggerService;

Parameters

ParameterTypeDescription
contextSchematicContextcontext

Returns:

LoggerService

the logger service

Home > @acoustic-content-sdk/schematics-utils > createTransientTree

createTransientTree() function

Creates a transient copy of a tree

Signature:

export declare function createTransientTree(aRoot: string): Tree;

Parameters

ParameterTypeDescription
aRootstringroot folder for the tree

Returns:

Tree

the tree

Home > @acoustic-content-sdk/schematics-utils > ensureTrailingSlash

ensureTrailingSlash() function

Signature:

declare function _ensureTrailingSlash(aUrl: string): string;

Parameters

ParameterTypeDescription
aUrlstring

Returns:

string

Home > @acoustic-content-sdk/schematics-utils > findBootstrapModuleCall

findBootstrapModuleCall() function

Signature:

export declare function findBootstrapModuleCall(host: Tree, mainPath: string): CallExpression | null;

Parameters

ParameterTypeDescription
hostTree
mainPathstring

Returns:

CallExpression | null

Home > @acoustic-content-sdk/schematics-utils > findBootstrapModulePath

findBootstrapModulePath() function

Signature:

export declare function findBootstrapModulePath(host: Tree, mainPath: string): string;

Parameters

ParameterTypeDescription
hostTree
mainPathstring

Returns:

string

Home > @acoustic-content-sdk/schematics-utils > findDataDir

findDataDir() function

Signature:

export declare function findDataDir(host: Tree, options?: {
    data?: string;
}): Path;

Parameters

ParameterTypeDescription
hostTree
options{ data?: string;}

Returns:

Path

Home > @acoustic-content-sdk/schematics-utils > findModule

findModule() function

Function to find the "closest" module to a generated file's path.

Signature:

export declare function findModule(host: Tree, generateDir: string, moduleExt?: string, routingModuleExt?: string): Path;

Parameters

ParameterTypeDescription
hostTree
generateDirstring
moduleExtstring
routingModuleExtstring

Returns:

Path

Home > @acoustic-content-sdk/schematics-utils > findModuleFromOptions

findModuleFromOptions() function

Find the module referred by a set of options passed to the schematics.

Signature:

export declare function findModuleFromOptions(host: Tree, options: ModuleOptions): Path | undefined;

Parameters

ParameterTypeDescription
hostTree
optionsModuleOptions

Returns:

Path | undefined

Home > @acoustic-content-sdk/schematics-utils > findNode

findNode() function

Signature:

export declare function findNode(node: Node, kind: SyntaxKind, text: string): Node | null;

Parameters

ParameterTypeDescription
nodeNode
kindSyntaxKind
textstring

Returns:

Node | null

Home > @acoustic-content-sdk/schematics-utils > findNodes

findNodes() function

Find all nodes from the AST in the subtree of node of SyntaxKind kind.

Signature:

export declare function findNodes(node: Node, kind: SyntaxKind, max?: number, recursive?: boolean): Node[];

Parameters

ParameterTypeDescription
nodeNode
kindSyntaxKind
maxnumberThe maximum number of items to return.
recursivebooleanContinue looking for nodes of kind recursive until end the last child even when node of kind has been found.

Returns:

Node[]

all nodes of kind, or [] if none is foun