MCPcopy Create free account
hub / github.com/adobe/react-spectrum / parseSegments

Function parseSegments

packages/react-aria/src/tokenfield/useTokenField.ts:729–739  ·  view source on GitHub ↗
(json: string)

Source from the content-addressed store, hash-verified

727// JSON or does not match the expected shape, so malformed or untrusted data is ignored rather
728// than throwing or being inserted into the field.
729function parseSegments(json: string): TokenFieldSegment[] | null {
730 try {
731 let data = JSON.parse(json);
732 if (Array.isArray(data) && data.length > 0 && data.every(isValidSegment)) {
733 return data;
734 }
735 } catch {
736 // Ignore invalid clipboard data.
737 }
738 return null;
739}
740
741function isValidSegment(segment: unknown): segment is TokenFieldSegment {
742 return (

Callers 1

useTokenFieldFunction · 0.85

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected