sanitizeTexts
Converts text data from object or array format into a standardized array of text record objects.
Usage
import { sanitizeTexts } from '@justaname.id/sdk'
// Object format
const texts = sanitizeTexts({
description: 'My personal description',
url: 'https://example.com',
email: '[email protected]'
})
console.log(texts)
// [
// { key: 'description', value: 'My personal description' },
// { key: 'url', value: 'https://example.com' },
// { key: 'email', value: '[email protected]' }
// ]
// Array format (returns as-is)
const texts2 = sanitizeTexts([
{ key: 'description', value: 'My personal description' },
{ key: 'url', value: 'https://example.com' }
])
Returns
undefined
| TextRecord
[] - An array of text record objects with key
and value
properties, or undefined if no texts provided
Parameters
texts:
undefined
|Record<string, string>
|TextRecord
[] - Text data in object or array format
Defined in
packages/@justaname.id/sdk/src/lib/utils/transformJsonToRecord/index.ts:3
Last updated
Was this helpful?