UNPKG

m3u8parse

Version:

Structural parsing of Apple HTTP Live Streaming .m3u8 format

41 lines (40 loc) 2.41 kB
import type * as AttrT from './attr-types.ts'; import type { TAnyAttr, AttrType, ImmutableAttrList } from './attrlist.ts'; import type { ImmutableMediaSegment, MediaSegment } from './media-segment.ts'; import { AttrList } from './attrlist.ts'; import type { Proto } from './types.ts'; export type UriMapFunction<T extends string = string> = (uri: string | undefined, type: T, data: unknown) => string | undefined | void; export type ImmutableUriMapFunction<T extends string = string> = (uri: string | undefined, type: T, data: unknown) => undefined | void; type ImmutableMap<K, V> = Omit<Map<K, V>, 'clear' | 'set' | 'delete'>; export type Immutify<T> = T extends Function ? T : T extends AttrList<infer U> ? ImmutableAttrList<U> : T extends Map<string, AttrList<infer U>[]> ? ImmutableMap<string, AttrList<U>[]> : T extends MediaSegment ? ImmutableMediaSegment : T extends object ? { readonly [P in keyof T]: Immutify<T[P]>; } : T; export declare const cloneAttrArray: <T extends TAnyAttr>(src?: readonly ImmutableAttrList<T>[]) => AttrList<T>[]; export declare const cloneAttrMap: <T extends TAnyAttr>(src?: Iterable<[string, readonly ImmutableAttrList<T>[]]> | { [key: string]: readonly ImmutableAttrList<T>[]; }) => Map<string, AttrList<T>[]>; export declare const isStringish: (val: unknown) => val is string; type AnyAttrWithUri = TAnyAttr & { uri: AttrType.String; }; export declare const rewriteAttr: (mapFn: UriMapFunction<any>, attrs: AttrList<AnyAttrWithUri> | null | undefined, type: string) => void; export declare const rewriteAttrs: (mapFn: UriMapFunction<any>, list: AttrList<AnyAttrWithUri>[] | null | undefined, type: string) => void; export declare const rewriteMappedAttrs: (mapFn: UriMapFunction<any>, map: Map<string, AttrList<AnyAttrWithUri>[]>, type: string) => void; export interface IRewritableUris { rewriteUris(mapFn: UriMapFunction): this; } export interface ImmutableIRewritableUris extends IRewritableUris { rewriteUris(mapFn: ImmutableUriMapFunction): this; } export declare class BasePlaylist { readonly master: boolean; version: number; independent_segments?: boolean | undefined; start?: AttrList<AttrT.Start> | undefined; defines: AttrList<AttrT.Define>[]; vendor?: Iterable<[string, string | null]> | undefined; constructor(obj: Immutify<Proto<BasePlaylist>>); isLive(): boolean; toString(): string; } export {};