Home Manual Reference Source Test
import {WriteStream} from 'atscm/src/lib/gulp/dest.js'
public class | source

WriteStream

Extends:

stream~Writable → WriteStream

A stream that writes Nodes to the file system.

Test:

Constructor Summary

Public Constructor
public

constructor(options: Object)

Creates a new WriteStream.

Member Summary

Public Members
public get

If the stream is destroyed.

Private Members
private

The base to output to.

private
private

The IDs that are affected by node id conflicts, lowercased.

private

The number of id conflicts discovered.

private

_idMap: *

A map of ids used for renaming.

private

If the stream is destroyed.

private

A promise that resolves once the rename file is loaded.

private

If writes should actually be performed.

private

The number of processed nodes.

private

The object stored in the rename file (usually at './atscm/rename.json')

private
private

The number of written nodes.

Method Summary

Public Methods
public

writeAsync(node: *): *

public

Writes the updated rename config to disk.

Private Methods
private

_destroy(err: Error, callback: function(err: ?Error): void)

Destroys the stream.

private

async _outputFile(path: *, content: *): *

private

Transverses the node tree to see if any parent node has an id conflict.

private

_write(node: Node, enc: string, callback: function(err: ?Error): void)

Writes a single node to the file system.

private

Writes a single node to disk.

private

_writev(nodes: Node[], callback: function(error: ?Error): void)

Writes multiple nodes in parallel.

Public Constructors

public constructor(options: Object) source

Creates a new WriteStream.

Params:

NameTypeAttributeDescription
options Object

The options to use.

options.path string

The path to write to (required).

options.base string

The base path to write to (defaults to path).

options.cleanRenameConfig boolean
  • optional
  • default: false

If unused entries should be removed when rename config is written.

Public Members

public get isDestroyed: boolean source

If the stream is destroyed.

Private Members

private _base: string source

The base to output to.

private _cleanRenameConfig: * source

private _conflictingIds: Set<string> source

The IDs that are affected by node id conflicts, lowercased.

private _discoveredIdConflicts: number source

The number of id conflicts discovered.

private _idMap: * source

A map of ids used for renaming.

private _isDestroyed: boolean source

If the stream is destroyed.

private _loadRenameConfig: * source

A promise that resolves once the rename file is loaded.

private _performWrites: boolean source

If writes should actually be performed. Set to false once id conflicts were discovered.

private _processed: number source

The number of processed nodes.

private _renameConfig: {} source

The object stored in the rename file (usually at './atscm/rename.json')

private _renamesUsed: {} source

private _written: number source

The number of written nodes.

Public Methods

public writeAsync(node: *): * source

Params:

NameTypeAttributeDescription
node *

Return:

*

public writeRenamefile(): * source

Writes the updated rename config to disk.

Return:

*

Private Methods

private _destroy(err: Error, callback: function(err: ?Error): void) source

Destroys the stream.

Params:

NameTypeAttributeDescription
err Error
  • nullable: true

The error that caused the destroy.

callback function(err: ?Error): void

Called once finished.

private async _outputFile(path: *, content: *): * source

Params:

NameTypeAttributeDescription
path *
content *

Return:

*

private _parentHasIdConflict(node: ServerNode): boolean source

Transverses the node tree to see if any parent node has an id conflict.

Params:

NameTypeAttributeDescription
node ServerNode

The processed node.

Return:

boolean

true if a parent node has an id conflict.

private _write(node: Node, enc: string, callback: function(err: ?Error): void) source

Writes a single node to the file system.

Params:

NameTypeAttributeDescription
node Node

The node to write.

enc string

The encoding used.

callback function(err: ?Error): void

Called once finished.

private async _writeNode(node: ServerNode): Promise<boolean> source

Writes a single node to disk.

Params:

NameTypeAttributeDescription
node ServerNode

The processed node.

Return:

Promise<boolean>

Resolves once the node has been written, true indicates the node has actually been written.

private _writev(nodes: Node[], callback: function(error: ?Error): void) source

Writes multiple nodes in parallel.

Params:

NameTypeAttributeDescription
nodes Node[]

The nodes to write.

callback function(error: ?Error): void

Called once all nodes have been written.