mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
* Renamed file to match contribution guidelines
* Added simple tests-file * Made callback parameters in seek() and skip() optional
This commit is contained in:
parent
971afd9fc3
commit
ae77785d1c
16
jbinary/jbinary-tests.ts
Normal file
16
jbinary/jbinary-tests.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/// <reference path="jbinary.d.ts" />
|
||||
|
||||
var originalData = [0x05, 0x03, 0x7F, 0x1E];
|
||||
var b1 = new jBinary(originalData);
|
||||
console.log(b1.readAll());
|
||||
console.log(b1.read('int8'));
|
||||
|
||||
b1.seek(4);
|
||||
console.log(b1.read('int8'));
|
||||
|
||||
console.log(b1.tell());
|
||||
|
||||
b1.write('int8', 0x9A, 2);
|
||||
b1.writeAll(originalData);
|
||||
|
||||
console.log(b1.slice(0, 2));
|
||||
32
jbinary/jbinary.d.ts
vendored
Normal file
32
jbinary/jbinary.d.ts
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
// Type definitions for jBinary
|
||||
// Project: https://github.com/jDataView/jBinary
|
||||
// Definitions by: Tim Bureck <https://github.com/tbureck>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// Additional notes:
|
||||
// Method stubs and types are taken from the official jBinary documentation, which can be found here:
|
||||
// https://github.com/jDataView/jBinary/wiki/jBinary-Constructor
|
||||
// https://github.com/jDataView/jBinary/wiki/jBinary-Methods
|
||||
|
||||
/// <reference path="../jdataview/jdataview.d.ts" />
|
||||
|
||||
declare class jBinary
|
||||
{
|
||||
|
||||
constructor(data:Array<number>);
|
||||
constructor(data:jDataView, typeSet:Object);
|
||||
constructor(bufferSize:number, typeSet:Object);
|
||||
|
||||
read(type:string, offset?:number):any;
|
||||
readAll():any;
|
||||
|
||||
write(type:string, data:any, offset?:number):number;
|
||||
writeAll(data:any):number;
|
||||
|
||||
tell():number;
|
||||
seek(position:number, callback?: (prop:jBinary, data:any) => any):number;
|
||||
skip(count:number, callback?: (prop:jBinary, data:any) => any):number;
|
||||
|
||||
slice(start:number, end:number, forceCopy?:boolean):jBinary;
|
||||
as(typeSet:Object, modifyOriginal?:boolean):jBinary;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user