(input: string)
| 33 | } |
| 34 | |
| 35 | function sanitizeInput(input: string) { |
| 36 | input = String(input); |
| 37 | |
| 38 | if (input.length > 0) { |
| 39 | // Add trailing `\n` if not exists |
| 40 | if (!isEOL(input.charCodeAt(input.length - 1))) input += "\n"; |
| 41 | |
| 42 | // Strip BOM |
| 43 | if (input.charCodeAt(0) === 0xfeff) input = input.slice(1); |
| 44 | } |
| 45 | |
| 46 | return input; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Parse and return a YAML string as a parsed YAML document object. |