UNPKG

hls.js

Version:

JavaScript HLS client using MediaSourceExtension

23 lines (21 loc) 569 B
const omitCircularRefsReplacer = ( replacer: ((this: any, key: string, value: any) => any) | undefined, ) => { const known = new WeakSet(); return (_, value) => { if (replacer) { value = replacer(_, value); } if (typeof value === 'object' && value !== null) { if (known.has(value)) { return; } known.add(value); } return value; }; }; export const stringify = <T>( object: T, replacer?: (this: any, key: string, value: any) => any, ): string => JSON.stringify(object, omitCircularRefsReplacer(replacer));