mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-06 10:10:08 +00:00
ndn-js: Blob and SignedBlob
This commit is contained in:
23
types/ndn-js/blob.d.ts
vendored
Normal file
23
types/ndn-js/blob.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
export class Blob {
|
||||
constructor(value?: Blob);
|
||||
constructor(value: Buffer, copy?: boolean);
|
||||
constructor(value: number[]);
|
||||
constructor(value: string);
|
||||
|
||||
size(): number;
|
||||
buf(): Buffer;
|
||||
isNull(): boolean;
|
||||
toHex(): string;
|
||||
toString(): string;
|
||||
equals(other: Blob): boolean;
|
||||
}
|
||||
|
||||
export class SignedBlob extends Blob {
|
||||
constructor();
|
||||
constructor(value: Blob|Buffer|number[], signedPortionBeginOffset: number, signedPortionEndOffset: number);
|
||||
|
||||
signedSize(): number;
|
||||
signedBuf(): Buffer;
|
||||
getSignedPortionBeginOffset(): number;
|
||||
getSignedPortionEndOffset(): number;
|
||||
}
|
||||
1
types/ndn-js/index.d.ts
vendored
1
types/ndn-js/index.d.ts
vendored
@@ -1,3 +1,4 @@
|
||||
export as namespace ndn;
|
||||
export * from "./blob";
|
||||
export * from "./face";
|
||||
export * from "./transport";
|
||||
|
||||
@@ -1,7 +1,31 @@
|
||||
/// <reference types="node"/>
|
||||
import ndn = require("ndn-js");
|
||||
|
||||
let face = new ndn.Face();
|
||||
face = new ndn.Face({host: 'hobo.cs.arizona.edu', port: 6363});
|
||||
face = new ndn.Face(new ndn.TcpTransport(), new ndn.TcpTransport.ConnectionInfo("hobo.cs.arizona.edu", 9696));
|
||||
face = new ndn.Face(new ndn.UnixTransport(), new ndn.UnixTransport.ConnectionInfo("/run/nfd.sock"));
|
||||
face = new ndn.Face(new ndn.WebSocketTransport(), new ndn.WebSocketTransport.ConnectionInfo("hobo.cs.arizona.edu", 9696));
|
||||
function testBlob() {
|
||||
let blob = new ndn.Blob();
|
||||
blob = new ndn.Blob(blob);
|
||||
blob = new ndn.Blob(Buffer.alloc(4));
|
||||
blob = new ndn.Blob("str");
|
||||
|
||||
let n: number = blob.size();
|
||||
let buf: Buffer = blob.buf();
|
||||
let b: boolean = blob.equals(blob);
|
||||
let s: string = blob.toHex();
|
||||
s = blob.toString();
|
||||
b = blob.isNull();
|
||||
|
||||
let sb = new ndn.SignedBlob();
|
||||
sb = new ndn.SignedBlob(sb, 20, 40);
|
||||
n = sb.signedSize();
|
||||
buf = sb.signedBuf();
|
||||
n = sb.getSignedPortionBeginOffset();
|
||||
n = sb.getSignedPortionEndOffset();
|
||||
}
|
||||
|
||||
function testFaceTransport() {
|
||||
let face = new ndn.Face();
|
||||
face = new ndn.Face({host: 'hobo.cs.arizona.edu', port: 6363});
|
||||
face = new ndn.Face(new ndn.TcpTransport(), new ndn.TcpTransport.ConnectionInfo("hobo.cs.arizona.edu", 9696));
|
||||
face = new ndn.Face(new ndn.UnixTransport(), new ndn.UnixTransport.ConnectionInfo("/run/nfd.sock"));
|
||||
face = new ndn.Face(new ndn.WebSocketTransport(), new ndn.WebSocketTransport.ConnectionInfo("hobo.cs.arizona.edu", 9696));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user