mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Updating write* methods to return offsets, fill to return the Buffer, and making isBuffer a type guard.
This commit is contained in:
+20
-1
@@ -34,7 +34,7 @@ assert.doesNotThrow(() => {
|
||||
fs.writeFile("thebible.txt",
|
||||
"Do unto others as you would have them do unto you.",
|
||||
assert.ifError);
|
||||
|
||||
|
||||
fs.write(1234, "test");
|
||||
|
||||
fs.writeFile("Harry Potter",
|
||||
@@ -87,6 +87,25 @@ function bufferTests() {
|
||||
console.log(Buffer.byteLength('xyz123', 'ascii'));
|
||||
var result1 = Buffer.concat([utf8Buffer, base64Buffer]);
|
||||
var result2 = Buffer.concat([utf8Buffer, base64Buffer], 9999999);
|
||||
|
||||
// Test that TS 1.6 works with the 'as Buffer' annotation
|
||||
// on isBuffer.
|
||||
var a: Buffer | number;
|
||||
a = new Buffer(10);
|
||||
if (Buffer.isBuffer(a)) {
|
||||
a.writeUInt8(3, 4);
|
||||
}
|
||||
|
||||
// write* methods return offsets.
|
||||
var b = new Buffer(16);
|
||||
var result: number = b.writeUInt32LE(0, 0);
|
||||
result = b.writeUInt16LE(0, 4);
|
||||
result = b.writeUInt8(0, 6);
|
||||
result = b.writeInt8(0, 7);
|
||||
result = b.writeDoubleLE(0, 8);
|
||||
|
||||
// fill returns the input buffer.
|
||||
b.fill('a').fill('b');
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user