import { customAlphabet } from "nanoid" ; export const serialiseAndDeserialise = < T > ( obj ) : T => { if ( typeof obj === "object" && obj !== null ) { return JSON . parse ( JSON . stringify ( obj ) ) ; } return obj ; } ; export const clone = < T > ( obj ) : T => { if ( obj ) { if ( typeof obj . clone === "function" ) { return obj . clone ( ) ; } return serialiseAndDeserialise < T > ( obj ) ; } return obj ; } ; export function filter < T > ( obj , predicate ) { const result = { } ; for ( const [ key , value ] of Object . entries ( obj ) ) { if ( value && predicate ( value ) ) { result [ key ] = value ; } } return result ; } export const nanoid = customAlphabet ( "0123456789_abcdefghijklmnopqrstuvwxyz" , 6 ) ;