rxjs#bindNodeCallback TypeScript Examples

The following examples show how to use rxjs#bindNodeCallback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: pdf.service.ts    From nestjs-pdf with MIT License 6 votes vote down vote up
toFile(
        template: string,
        filename: string,
        options?: PDFOptions,
        scheduler: SchedulerLike = asapScheduler,
    ): Observable<FileInfo> {
        return this.makeHtmlRender(template, options).pipe(
            mergeMap((html: string) => {
                const create = this.create(html, options);
                return bindNodeCallback<
                    [string | undefined],
                    [FileInfo]
                >(
                    create.toFile.bind(create),
                    scheduler,
                )(filename);
            }),
        );
    }
Example #2
Source File: pdf.service.ts    From nestjs-pdf with MIT License 6 votes vote down vote up
toStream(
        template: string,
        options?: PDFOptions,
        scheduler: SchedulerLike = asapScheduler,
    ): Observable<Readable> {
        return this.makeHtmlRender(template, options).pipe(
            mergeMap((html: string) => {
                const create = this.create(html, options);
                return bindNodeCallback<[], [Readable]>(
                    create.toStream.bind(create),
                    scheduler,
                )();
            }),
        );
    }
Example #3
Source File: pdf.service.ts    From nestjs-pdf with MIT License 6 votes vote down vote up
toBuffer(
        template: string,
        options?: PDFOptions,
        scheduler: SchedulerLike = asapScheduler,
    ): Observable<Buffer> {
        return this.makeHtmlRender(template, options).pipe(
            mergeMap((html: string) => {
                const create = this.create(html, options);
                return bindNodeCallback<[], [Buffer]>(
                    create.toBuffer.bind(create),
                    scheduler,
                )();
            }),
        );
    }
Example #4
Source File: pdf.service.ts    From nestjs-pdf with MIT License 6 votes vote down vote up
private generateHtmlFromTemplate(
        template: string,
        { engine, engineOptions }: ViewOptions,
        locals?: Record<string, any>,
    ): Observable<string> {
        return bindNodeCallback<
            [string, ViewOptions['engineOptions'] | undefined],
            [string]
        >(consolidate[engine], asapScheduler)(
            template,
            Object.assign({}, locals, engineOptions),
        );
    }
Example #5
Source File: rxjs-fs.ts    From open-source with MIT License 5 votes vote down vote up
renameFile: (oldPath: string, newPath: string) => Observable<void>
  = bindNodeCallback(rename)