Apply no-buffer-constructor lint rule
This commit is contained in:
1 parent
d85afcd2b5
commit
b43088c03c
6 files changed
+8
-7
No files matched your search
+1
-1
@@ -54,7 +54,7 @@ function parseAuthHeader(authHeader) {
|
||||
}
|
||||
|
||||
function basic(username, password) {
|
||||
return "Basic " + new Buffer(`${username}:${password}`).toString("base64");
|
||||
return "Basic " + Buffer.from(`${username}:${password}`).toString("base64");
|
||||
}
|
||||
|
||||
function digest(username, password, uri, httpMethod, body, authHeader) {
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ function generateDeviceId(deviceIdStruct) {
|
||||
// Escapes everything except alphanumerics and underscore
|
||||
function esc(str) {
|
||||
return str.replace(/[^A-Za-z0-9_]/g, chr => {
|
||||
const buf = new Buffer(chr, "utf8");
|
||||
const buf = Buffer.from(chr, "utf8");
|
||||
let rep = "";
|
||||
for (let b of buf) rep += "%" + b.toString(16).toUpperCase();
|
||||
return rep;
|
||||
|
||||
+1
-1
@@ -1058,7 +1058,7 @@ function listener(httpRequest, httpResponse) {
|
||||
});
|
||||
|
||||
stream.on("end", () => {
|
||||
const body = new Buffer(bytes);
|
||||
const body = Buffer.allocUnsafe(bytes);
|
||||
let offset = 0;
|
||||
for (const chunk of chunks) {
|
||||
chunk.copy(body, offset, 0, chunk.length);
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ function listener(request, response) {
|
||||
|
||||
function getBody() {
|
||||
// Write all chunks into a Buffer
|
||||
const body = new Buffer(bytes);
|
||||
const body = Buffer.allocUnsafe(bytes);
|
||||
let offset = 0;
|
||||
for (const chunk of chunks) {
|
||||
chunk.copy(body, offset, 0, chunk.length);
|
||||
|
||||
+2
-2
@@ -524,7 +524,7 @@ function response(rpc) {
|
||||
SOAPServer: SERVER_NAME
|
||||
};
|
||||
|
||||
if (!rpc) return { code: 204, headers: headers, data: new Buffer(0) };
|
||||
if (!rpc) return { code: 204, headers: headers, data: Buffer.allocUnsafe(0) };
|
||||
|
||||
const env = createSoapEnv(rpc.cwmpVersion);
|
||||
const header = env.node("soap-env:Header");
|
||||
@@ -589,7 +589,7 @@ function response(rpc) {
|
||||
return {
|
||||
code: 200,
|
||||
headers: headers,
|
||||
data: new Buffer(env.doc().toString(LIBXMLJS_SAVE_OPTIONS))
|
||||
data: env.doc().toString(LIBXMLJS_SAVE_OPTIONS)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user