mirror of
https://github.com/morluto/rea.git
synced 2026-12-05 14:31:22 +00:00
refactor(text): share unpaired surrogate checks (#15770)
This commit is contained in:
1 parent
c19f474453
commit
8f8a8539fc
6 files changed
+16
-52
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { hasUnpairedSurrogate } from "../kernel/hasUnpairedSurrogate.js";
|
||||
/*
|
||||
* The TOON, JSON, YAML and JSON Lines encodings and the Markdown layout are
|
||||
* adapted from Incur's Formatter.
|
||||
@@ -41,10 +42,6 @@ export interface CliDelimitedOutputOptions {
|
||||
|
||||
type DelimitedScalar = string | number | boolean | null | undefined;
|
||||
|
||||
/** UTF-8 cannot encode a lone UTF-16 surrogate without replacing it. */
|
||||
export const hasUnpairedSurrogate = (value: string): boolean =>
|
||||
/[\ud800-\udfff]/u.test(value);
|
||||
|
||||
/** Check selected output, including keys, before using a non-JSON text format. */
|
||||
export const containsUnpairedSurrogate = (value: unknown): boolean => {
|
||||
return containsText(value, hasUnpairedSurrogate);
|
||||
|
||||
Reference in new issue
Block a user