提交 6607a81c 编写于 作者: B Benjamin Pasero

debt - do not use deprecated Buffer() ctor

上级 0bae8679
......@@ -202,7 +202,7 @@ gulp.task('editor-distro', ['clean-editor-distro', 'compile-editor-esm', 'minify
this.emit('data', new File({
path: data.path.replace(/monaco\.d\.ts/, 'editor.api.d.ts'),
base: data.base,
contents: new Buffer(toExternalDTS(data.contents.toString()))
contents: Buffer.from(toExternalDTS(data.contents.toString()))
}));
}))
.pipe(gulp.dest('out-monaco-editor-core/esm/vs/editor')),
......
......@@ -177,7 +177,7 @@ export interface IFile {
export function zip(zipPath: string, files: IFile[]): TPromise<string> {
return new TPromise<string>((c, e) => {
const zip = new yazl.ZipFile();
files.forEach(f => f.contents ? zip.addBuffer(typeof f.contents === 'string' ? new Buffer(f.contents, 'utf8') : f.contents, f.path) : zip.addFile(f.localPath, f.path));
files.forEach(f => f.contents ? zip.addBuffer(typeof f.contents === 'string' ? Buffer.from(f.contents, 'utf8') : f.contents, f.path) : zip.addFile(f.localPath, f.path));
zip.end();
const zipStream = createWriteStream(zipPath);
......
......@@ -111,7 +111,7 @@ enum BodyType {
Object
}
const empty = new Buffer(0);
const empty = Buffer.allocUnsafe(0);
function serializeBody(body: any): { buffer: Buffer, type: BodyType } {
if (typeof body === 'undefined') {
......@@ -126,7 +126,7 @@ function serializeBody(body: any): { buffer: Buffer, type: BodyType } {
}
function serialize(header: any, body: any = undefined): Buffer {
const headerSizeBuffer = new Buffer(4);
const headerSizeBuffer = Buffer.allocUnsafe(4);
const { buffer: bodyBuffer, type: bodyType } = serializeBody(body);
const headerBuffer = Buffer.from(JSON.stringify([header, bodyType]));
headerSizeBuffer.writeUInt32BE(headerBuffer.byteLength, 0);
......
......@@ -60,7 +60,7 @@ suite('IPC, Socket Protocol', () => {
assert.equal(data.readInt8(0), 123);
resolve(null);
});
const buffer = new Buffer(1);
const buffer = Buffer.allocUnsafe(1);
buffer.writeInt8(123, 0);
a.send(buffer);
});
......
......@@ -12,7 +12,7 @@ export enum MessageType {
}
export function createMessageOfType(type: MessageType): Buffer {
const result = new Buffer(1);
const result = Buffer.allocUnsafe(1);
switch (type) {
case MessageType.Initialized: result.writeUInt8(1, 0); break;
......
......@@ -311,7 +311,7 @@ class RPCMultiplexer {
private _sendAccumulated(): void {
const size = this._messagesToSend.reduce((r, b) => r + 4 + b.byteLength, 0);
const buffer = new Buffer(size);
const buffer = Buffer.allocUnsafe(size);
let i = 0;
for (const msg of this._messagesToSend) {
......
......@@ -273,7 +273,7 @@ describe('Test', () => {
const app = this.app as Application;
const raw = await app.capturePage();
const buffer = new Buffer(raw, 'base64');
const buffer = Buffer.from(raw, 'base64');
const name = this.currentTest.fullTitle().replace(/[^a-z0-9\-]/ig, '_');
const screenshotPath = path.join(screenshotsPath, `${name}.png`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册