mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
@types/node (v10): add transcode function to buffer module.
This commit is contained in:
parent
a9b3a2b5a8
commit
3a08ee731e
5
types/node/v10/buffer.d.ts
vendored
5
types/node/v10/buffer.d.ts
vendored
@ -2,6 +2,11 @@ declare module "buffer" {
|
||||
export const INSPECT_MAX_BYTES: number;
|
||||
const BuffType: typeof Buffer;
|
||||
|
||||
export function transcode(
|
||||
source: Buffer | Uint8Array,
|
||||
fromEnc: "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary",
|
||||
toEnc: "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary"): Buffer;
|
||||
|
||||
export const SlowBuffer: {
|
||||
/** @deprecated since v6.0.0, use Buffer.allocUnsafeSlow() */
|
||||
new(size: number): Buffer;
|
||||
|
||||
1
types/node/v10/index.d.ts
vendored
1
types/node/v10/index.d.ts
vendored
@ -33,6 +33,7 @@
|
||||
// Jeremie Rodriguez <https://github.com/jeremiergz>
|
||||
// Samuel Ainsworth <https://github.com/samuela>
|
||||
// Kyle Uehlein <https://github.com/kuehlein>
|
||||
// Jordi Oliveras Rovira <https://github.com/j-oliveras>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// NOTE: These definitions support NodeJS and TypeScript 3.1.
|
||||
|
||||
@ -35,7 +35,7 @@ import * as trace_events from "trace_events";
|
||||
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 ///
|
||||
@ -632,6 +632,11 @@ function bufferTests() {
|
||||
const buffer = new Buffer('123');
|
||||
const octets = new Uint8Array(buffer.buffer);
|
||||
}
|
||||
|
||||
// Buffer module, transcode function
|
||||
{
|
||||
transcode(Buffer.from('€'), 'utf8', 'ascii'); // $ExpectType Buffer
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
Loading…
Reference in New Issue
Block a user