mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-17 23:14:03 +01:00
11 lines
284 B
TypeScript
11 lines
284 B
TypeScript
import { generateId } from '../../lib/generateId';
|
|
import type { Pair, PairWithId } from './PairEditor';
|
|
|
|
export function ensurePairId(p: Pair): PairWithId {
|
|
if (typeof p.id === 'string') {
|
|
return p as PairWithId;
|
|
} else {
|
|
return { ...p, id: p.id ?? generateId() };
|
|
}
|
|
}
|