Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents worker objects that are able to control merging processors for multiple files, scripts and declarations alike.

Using this object is probably the best way to work with multiple file mergings while avoiding clogging Node's heap due to the heavy nature of this plugin.

Sync:

var tsmerge = require("ts-merge");

var worker = new tsmerge.FileWorker({ outDir: "dist/postbuild" });
worker.addFiles("myfile.d.ts", "myfile2.js", "myfile3.js")
worker.workSync();
worker.write();

Async:

var tsmerge = require("ts-merge");

var worker = new tsmerge.FileWorker({ outDir: "dist/postbuild" });
worker.addFiles("myfile.d.ts", "myfile2.js", "myfile3.js")
worker.work(function(files) {
    for (var i = 0; i < files.length; i++) {
        console.log(files[i].name);
    }

    // Output:
    //   myfile.merged.d.ts
    //   myfile2.merged.js
    //   myfile3.merged.js

    worker.write();
})

Hierarchy

  • FileWorker

Index

Constructors

constructor

Accessors

dtsList

dtsList:

Gets the declaration (d.ts) file array to be merged.

fileCount

fileCount:

Gets the number of files currently in the work queue.

jsList

jsList:

Gets the javascript (.js) file array to be merged.

timer

timer:

Gets the timer object that keeps track of the time spent while working.

unsaved

unsaved:

Gets an array with the files that were not saved during write because their name and/or path were not specified.

Methods

addDts

  • addDts(file: string): void
  • Adds a declaration (d.ts) file to the file worker object.

    Parameters

    • file: string

      Path to file or file object to be added.

    Returns void

addFile

  • addFile(filePath: string): void
  • Adds a single file to the worker object.

    Parameters

    • filePath: string

      String with the path to the file to be added.

    Returns void

addFiles

  • addFiles(...filePaths: string[]): void
  • Adds multiple files to the worker object.

    Parameters

    • Rest ...filePaths: string[]

      One or more strings with the paths to be added.

    Returns void

addGlobPatterns

  • addGlobPatterns(callback: function, ...patterns: string[]): void
  • Adds all files that matches the given glob patterns.

    Parameters

    • callback: function

      A function callback to be used when the files matching the pattern are finished being added; this function may accept a parameter with the list of files added.

        • (files: string[]): void
        • Parameters

          • files: string[]

          Returns void

    • Rest ...patterns: string[]

      One or more string with glob patterns containing files to be added.

    Returns void

addGlobPatternsSync

  • addGlobPatternsSync(...patterns: string[]): string[]
  • Adds all files that matches the given glob patterns, synchronously.

    Parameters

    • Rest ...patterns: string[]

      One or more string with glob patterns containing files to be added.

    Returns string[]

    An array with the files added to the work queue.

addJs

  • addJs(file: string): void
  • Adds a javascript (.js) file to the file worker object.

    Parameters

    • file: string

      Path to file or file object to be added.

    Returns void

work

  • work(callback: function): void
  • Performs the processing of all the files in the file worker queue, and retrieves the resulting files through the asynchronous callback.

    Parameters

    • callback: function

      A function to be called once the work is done.

        • (files: File[]): void
        • Parameters

          Returns void

    Returns void

workSync

  • workSync(): File[]
  • Performs the processing of all the files in the file worker queue, and retrieves the resulting files synchronously.

    Returns File[]

write

  • Writes the given file list to the disk.

    Parameters

    • Optional files: File | File[]

      A string or array of string with the files to be writen.

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc