⬅️ Back to Table of Contents
📄 string.ts
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
2 |
📦 Imports |
1 |
📊 Variables & Constants |
1 |
📚 Table of Contents
🛠️ File Location:
📂 packages/ast-spec/tests/util/serializers/string.ts
📦 Imports
Name |
Source |
NewPlugin |
@vitest/pretty-format |
Variables & Constants
Name |
Type |
Kind |
Value |
Exported |
serializer |
NewPlugin |
const |
`{ |
|
serialize( |
|
|
|
|
str: string, |
|
|
|
|
// config, |
|
|
|
|
// indentation, |
|
|
|
|
// depth, |
|
|
|
|
// refs, |
|
|
|
|
// printer, |
|
|
|
|
) { |
|
|
|
|
return '${str.replaceAll(/'|\\/g, '\\$&')}' ; |
|
|
|
|
}, |
|
|
|
|
test(val: unknown) { |
|
|
|
|
return typeof val === 'string'; |
|
|
|
|
}, |
|
|
|
|
}` |
✓ |
|
|
|
Functions
serialize(str: string): string
Code
serialize(
str: string,
// config,
// indentation,
// depth,
// refs,
// printer,
) {
return `'${str.replaceAll(/'|\\/g, '\\$&')}'`;
}
- Parameters:
str: string
- Return Type:
string
- Calls:
str.replaceAll
test(val: unknown): boolean
Code
test(val: unknown) {
return typeof val === 'string';
}
- Parameters:
val: unknown
- Return Type:
boolean