mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
@types/node (v8): add transcode function to buffer module.
This commit is contained in:
Vendored
+7
@@ -22,6 +22,7 @@
|
||||
// Hoàng Văn Khải <https://github.com/KSXGitHub>
|
||||
// Lishude <https://github.com/islishude>
|
||||
// Andrew Makarov <https://github.com/r3nya>
|
||||
// Jordi Oliveras Rovira <https://github.com/j-oliveras>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
@@ -909,6 +910,12 @@ declare module "buffer" {
|
||||
export var INSPECT_MAX_BYTES: number;
|
||||
var BuffType: typeof Buffer;
|
||||
var SlowBuffType: typeof SlowBuffer;
|
||||
|
||||
export function transcode(
|
||||
source: Buffer | Uint8Array,
|
||||
fromEnc: "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary",
|
||||
toEnc: "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary"): Buffer;
|
||||
|
||||
export { BuffType as Buffer, SlowBuffType as SlowBuffer };
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ import * as perf_hooks from "perf_hooks";
|
||||
import Module = require("module");
|
||||
|
||||
// Specifically test buffer module regression.
|
||||
import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer } from "buffer";
|
||||
import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer, transcode } from "buffer";
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
/// Global Tests : https://nodejs.org/api/global.html ///
|
||||
@@ -568,6 +568,11 @@ function bufferTests() {
|
||||
let buffer = new Buffer('123');
|
||||
let octets = new Uint8Array(buffer.buffer);
|
||||
}
|
||||
|
||||
// Buffer module, transcode function
|
||||
{
|
||||
transcode(Buffer.from('€'), 'utf8', 'ascii'); // $ExpectType Buffer
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user