在这个读取文件的Node片段中,什么是实验性的?

时间:2019-06-18 08:36:07

标签: javascript node.js

我从这里运行代码:

https://nodejs.org/dist/latest-v10.x/docs/api/readline.html#readline_example_read_file_stream_line_by_line

const fs = require('fs');
const readline = require('readline');

async function processLineByLine() {
  const fileStream = fs.createReadStream('input.txt');

  const rl = readline.createInterface({
    input: fileStream,
    crlfDelay: Infinity
  });
  // Note: we use the crlfDelay option to recognize all instances of CR LF
  // ('\r\n') in input.txt as a single line break.

  for await (const line of rl) {
    // Each line in input.txt will be successively available here as `line`.
    console.log(`Line from file: ${line}`);
  }
}

processLineByLine();

并收到此警告:

(node:13735) ExperimentalWarning: readline Interface [Symbol.asyncIterator] is an experimental feature. This feature could change at any time
(node:13735) ExperimentalWarning: Readable[Symbol.asyncIterator] is an experimental feature. This feature could change at any time

什么是实验性的?没有行号。

1 个答案:

答案 0 :(得分:0)

它说:

  

readline接口[Symbol.asyncIterator]

所以寻找一个接口:

const rl = readline.createInterface

您要遍历的地方:

const line of rl