Home > LIB_Symbol > search
LIB_Symbol.search() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Search symbol
Signature
typescript
function search(
key: string,
libraryUuid?: string,
classification?: ILIB_ClassificationIndex | Array<string>,
symbolType?: ELIB_SymbolType,
itemsOfPage?: number,
page?: number,
): Promise<Array<ILIB_SymbolSearchItem>>;1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Parameters
Parameter | Type | Description |
|---|---|---|
key | string | Search keyword |
libraryUuid | string | (Optional) Library UUID, default is system library, you can use LIB_LibrariesList APIs in |
classification | ILIB_ClassificationIndex | Array<string> | (Optional) Classification, defaults to all |
symbolType | (Optional) Symbol type, defaults to all | |
itemsOfPage | number | (Optional) Number of search results per page |
page | number | (Optional) Page count |
Returns
Promise<Array<ILIB_SymbolSearchItem>>
List of searched symbol properties
Example
javascript
// 1. 尝试按关键字搜索(当前版本非空关键字会抛错,如实展示)
try {
const keywordResults = await eda.lib_Symbol.search('0402');
console.log('关键字搜索返回', keywordResults.length, '条');
}
catch (e) {
// 剥掉错误类型前缀;注意:正则写法尾部会产生星号+斜杠序列,会闭掉 tsdoc 注释,故用 split
console.log('关键字搜索当前版本抛错:', String(e.message).split('Error: ').pop());
}
// 2. 改用空关键字列出系统库符号,每页 5 条
const results = await eda.lib_Symbol.search('', undefined, [], undefined, 5, 1);
// 3. 输出搜索结果(需要过滤时可按 item.name 自行筛选)
console.log('count:', results.length);
results.forEach((item, i) => {
console.log(`[${i}] name:`, item.name, 'uuid:', item.uuid, 'libraryUuid:', item.libraryUuid);
});1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18