oorabona / node-liblzma

Handle Xz as easily as Zlib
GNU Lesser General Public License v3.0
9 stars 2 forks source link

Typescript types are missing #15

Open piedrahitapablo opened 1 year ago

piedrahitapablo commented 1 year ago

The library does not have typescript types, so this makes working with typescript a little harder. I created a simple module that works for my use case but it might be missing some types (it's based on zlib's type declarations):

declare module 'node-liblzma' {
  import type * as stream from 'node:stream';

  interface LzmaOptions {
    check?: number;
    preset?: number;
    filters?: number[];
    mode?: number;
    threads?: number;
  }

  interface Lzma {}

  interface Xz extends stream.Transform, Lzma {}

  interface Unxz extends stream.Transform, Lzma {}

  function createXz(options?: LzmaOptions): Xz;

  function createUnxz(options?: LzmaOptions): Unxz;

  namespace check {
    const NONE: number;
    const CRC32: number;
    const CRC64: number;
    const SHA256: number;
  }
  namespace preset {
    const DEFAULT: number;
    const EXTREME: number;
  }

  namespace flag {
    const TELL_NO_CHECK: number;
    const TELL_UNSUPPORTED_CHECK: number;
    const TELL_ANY_CHECK: number;
    const CONCATENATED: number;
  }

  namespace filter {
    const LZMA2: number;
    const X86: number;
    const POWERPC: number;
    const IA64: number;
    const ARM: number;
    const ARMTHUMB: number;
    const SPARC: number;
  }

  namespace mode {
    const FAST: number;
    const NORMAL: number;
  }
}

Let me know if this works and I can create a PR with the types.

Thanks!

oorabona commented 1 year ago

Hello again,

Thanks for your interest in provided typescript module definition. Should also be tested, if you can create a PR with the scaffolding required, I will (again) gladly review it !

Many thanks,