mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Flatten lib namespace
Move all functions and classes currently available through lib/name and libName to be under a single flat namespace in lib. This make reorganising the lib namespace much simpler as the location of symbols can move without breaking the consumers of lib. The multi-entrypoint design was already problematic for the web plugin system which couldn't effectively use it due to how webpack's shared module system is awkward to set up with multiple entrypoints per package.
This commit is contained in:
1 parent
bb58670597
commit
bfe119eaa3
143 files changed
+1798
-1918
No files matched your search
+6
-7
@@ -1,12 +1,11 @@
|
||||
"use strict";
|
||||
const assert = require("assert").strict;
|
||||
const events = require("events");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
const stream = require("stream");
|
||||
const util = require("util");
|
||||
|
||||
const libStream = require("@clusterio/lib/stream");
|
||||
const lib = require("@clusterio/lib");
|
||||
|
||||
const finished = util.promisify(stream.finished);
|
||||
|
||||
@@ -14,7 +13,7 @@ const finished = util.promisify(stream.finished);
|
||||
describe("lib/stream", function() {
|
||||
describe("class LineSplitter", function() {
|
||||
function createSplitter(lines) {
|
||||
let lineStream = new libStream.LineSplitter({ readableObjectMode: true });
|
||||
let lineStream = new lib.LineSplitter({ readableObjectMode: true });
|
||||
lineStream.on("data", line => lines.push(line.toString("utf-8")));
|
||||
return lineStream;
|
||||
}
|
||||
@@ -61,7 +60,7 @@ describe("lib/stream", function() {
|
||||
|
||||
describe("class ReverseLineSplitter", function() {
|
||||
function createReverseSplitter(lines) {
|
||||
let lineStream = new libStream.ReverseLineSplitter({ readableObjectMode: true });
|
||||
let lineStream = new lib.ReverseLineSplitter({ readableObjectMode: true });
|
||||
lineStream.on("data", line => lines.push(line.toString("utf-8")));
|
||||
return lineStream;
|
||||
}
|
||||
@@ -111,7 +110,7 @@ describe("lib/stream", function() {
|
||||
let content = "";
|
||||
for (let i = 0; i < 10; i++) { content += String(i).repeat(10); }
|
||||
await fs.outputFile(path.join("temp", "test", "reverse.txt"), content);
|
||||
let reverseStream = await libStream.createReverseReadStream(
|
||||
let reverseStream = await lib.createReverseReadStream(
|
||||
path.join("temp", "test", "reverse.txt"),
|
||||
{ encoding: "utf8", highWaterMark: 10 }
|
||||
);
|
||||
@@ -131,9 +130,9 @@ describe("lib/stream", function() {
|
||||
ws.end();
|
||||
await finished(ws);
|
||||
|
||||
let lineStream = new libStream.ReverseLineSplitter({ readableObjectMode: true });
|
||||
let lineStream = new lib.ReverseLineSplitter({ readableObjectMode: true });
|
||||
let index = 99999;
|
||||
let rs = await libStream.createReverseReadStream(path.join("temp", "test", "reverse.txt"));
|
||||
let rs = await lib.createReverseReadStream(path.join("temp", "test", "reverse.txt"));
|
||||
lineStream.on("data", line => {
|
||||
let n = Number(line.toString());
|
||||
if (index !== n) {
|
||||
|
||||
Reference in new issue
Block a user