当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Writable.end方法代码示例

本文整理汇总了TypeScript中stream.Writable.end方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Writable.end方法的具体用法?TypeScript Writable.end怎么用?TypeScript Writable.end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stream.Writable的用法示例。


在下文中一共展示了Writable.end方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: writeOutgoingMessages

 function writeOutgoingMessages(outgoingMessages: Wrapper[], output: Writable) {
   for (const outgoingMessage of outgoingMessages) {
     const chunk = Wrapper.encodeDelimited(outgoingMessage).finish()
     output.write(chunk)
   }
   output.end()
 }
开发者ID:cucumber,项目名称:cucumber,代码行数:7,代码来源:message_serialization_test.ts

示例2: write

export const wrapWriter = <Msg>(w: Writable, encode?: (msg: Msg) => any) => {
  return {
    write(data) {
      if (w.writable) {
        w.write(encode ? encode(data) : data)

        // Work around this bug:
        // https://github.com/kawanet/msgpack-lite/issues/80
        if ((w as any).encoder) (w as any).encoder.flush()
      }
    },
    close() {
      w.end()
    }
  } as TinyWriter<Msg>
}
开发者ID:josephg,项目名称:statecraft,代码行数:16,代码来源:tinystream.ts

示例3: doExecuteTasks

  const w = (taskOffset: number) => {
    if (taskOffset >= tasks.length) {
      if (differentialDownloader.fileMetadataBuffer != null) {
        out.write(differentialDownloader.fileMetadataBuffer)
      }
      out.end()
      return
    }

    const nextOffset = taskOffset + 1000
    doExecuteTasks(differentialDownloader, {
      tasks,
      start: taskOffset,
      end: Math.min(tasks.length, nextOffset),
      oldFileFd,
    }, out, () => w(nextOffset), reject)
  }
开发者ID:electron-userland,项目名称:electron-builder,代码行数:17,代码来源:multipleRangeDownloader.ts

示例4: _executeTasks

  const w = (taskOffset: number) => {
    if (taskOffset >= tasks.length) {
      if (differentialDownloader.fileMetadataBuffer != null) {
        out.write(differentialDownloader.fileMetadataBuffer)
      }
      out.end()
      return
    }

    const nextOffset = taskOffset + (differentialDownloader.options.useMultipleRangeRequest === false ? 1 : 1000)
    _executeTasks(differentialDownloader, {
      tasks,
      start: taskOffset,
      end: Math.min(tasks.length, nextOffset),
      oldFileFd,
    }, out, () => w(nextOffset), reject)
  }
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:17,代码来源:multipleRangeDownloader.ts

示例5: writeCSV

    // Export dataset variables to CSV (not including metadata)
    static async writeCSV(datasetId: number, stream: Writable) {
        const csvHeader = ["Entity", "Year"]
        const variables = await db.query(`SELECT name, id FROM variables v WHERE v.datasetId=? ORDER BY v.columnOrder ASC, v.id ASC`, [datasetId])
        for (const variable of variables) {
            csvHeader.push(variable.name)
        }

        const columnIndexByVariableId: {[key: number]: number} = {}
        for (const variable of variables) {
            columnIndexByVariableId[variable.id] = csvHeader.indexOf(variable.name)
        }

        stream.write(csvRow(csvHeader))

        const data = await db.query(`
            SELECT e.name AS entity, dv.year, dv.value, dv.variableId FROM data_values dv
            JOIN variables v ON v.id=dv.variableId
            JOIN datasets d ON v.datasetId=d.id
            JOIN entities e ON dv.entityId=e.id
            WHERE d.id=?
            ORDER BY e.name ASC, dv.year ASC, v.columnOrder ASC, dv.variableId ASC`, [datasetId])

        let row: string[] = []
        for (const datum of data) {
            if (datum.entity !== row[0] || datum.year !== row[1]) {
                // New row
                if (row.length) {
                    stream.write(csvRow(row))
                }
                row = [datum.entity, datum.year]
                for (const variable of variables) {
                    row.push("")
                }
            }

            row[columnIndexByVariableId[datum.variableId]] = datum.value
        }

        // Final row
        stream.write(csvRow(row))

        stream.end()
    }
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:44,代码来源:Dataset.ts

示例6: setImmediate

 setImmediate(() => dst.end(src)) // string or Buffer
开发者ID:dianpeng,项目名称:fly,代码行数:1,代码来源:server.ts

示例7: end

	/**
	 * Closes the underlying stream
	 */
	end(): void {
		this.outStream.end()
	}
开发者ID:calebsander,项目名称:structure-bytes,代码行数:6,代码来源:appendable-stream.ts

示例8:

 socket.on('close', () => {
   writer.end() // Does this help??
   reader.isClosed = true
   reader.onClose && reader.onClose()
 })
开发者ID:josephg,项目名称:statecraft,代码行数:5,代码来源:wsserver.ts

示例9: Error

 process.nextTick(() => {
   const err = new Error(SourceError[401]);
   err.stack = option.path;
   writer.emit("error", err, option);
   writer.end();
 });
开发者ID:node-dmr,项目名称:dmr-source,代码行数:6,代码来源:source-file.ts


注:本文中的stream.Writable.end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。