diff --git a/types/ndn-js/data.d.ts b/types/ndn-js/data.d.ts index d76dd02779..9d6c03cda1 100644 --- a/types/ndn-js/data.d.ts +++ b/types/ndn-js/data.d.ts @@ -3,19 +3,20 @@ import { Name } from "./name"; import { Signature } from "./signature"; export class Data { - constructor(name?: Name); + constructor(name?: Name|string); + constructor(data: Data); - getCongestionMark(): number; - getContent(): Blob; - getFullName(): Name; - getIncomingFaceId(): number; - getMetaInfo(): MetaInfo; getName(): Name; + getFullName(): Name; + getMetaInfo(): MetaInfo; + getContent(): Blob; getSignature(): Signature; + getCongestionMark(): number; + getIncomingFaceId(): number; - setContent(content: Blob): Data; - setMetaInfo(meta: MetaInfo): Data; setName(name: Name): Data; + setMetaInfo(meta: MetaInfo): Data; + setContent(content: Blob|Buffer): Data; setSignature(sig: Signature): Data; wireDecode(input: Blob|Buffer): void; @@ -33,13 +34,13 @@ export enum ContentType { export class MetaInfo { constructor(meta?: MetaInfo); - getFinalBlockId(): Name.Component; - getFreshnessPeriod(): number; - getOtherTypeCode(): number; getType(): ContentType; + getOtherTypeCode(): number; + getFreshnessPeriod(): number; + getFinalBlockId(): Name.Component; - setFinalBlockId(comp: Name.Component): void; - setFreshnessPeriod(freshness: number): void; - setOtherTypeCode(otherTypeCode: number): void; setType(type: ContentType): void; + setOtherTypeCode(otherTypeCode: number): void; + setFreshnessPeriod(freshness: number): void; + setFinalBlockId(comp: Name.Component): void; } diff --git a/types/ndn-js/test/data.ts b/types/ndn-js/test/data.ts index feea541a19..367a7a0ec7 100644 --- a/types/ndn-js/test/data.ts +++ b/types/ndn-js/test/data.ts @@ -3,30 +3,33 @@ import ndn = require("ndn-js"); let meta = new ndn.MetaInfo(); meta = new ndn.MetaInfo(meta); -const comp: ndn.Name.Component = meta.getFinalBlockId(); -let n: number = meta.getFreshnessPeriod(); -n = meta.getOtherTypeCode(); const ct: ndn.ContentType = meta.getType(); +let n: number = meta.getOtherTypeCode(); +n = meta.getFreshnessPeriod(); +const comp: ndn.Name.Component = meta.getFinalBlockId(); -meta.setFinalBlockId(comp); -meta.setFreshnessPeriod(5000); -meta.setOtherTypeCode(1000); meta.setType(ndn.ContentType.OTHER_CODE); +meta.setOtherTypeCode(1000); +meta.setFreshnessPeriod(5000); +meta.setFinalBlockId(comp); let data = new ndn.Data(); data = new ndn.Data(new ndn.Name("/A")); +data = new ndn.Data("/A"); +data = new ndn.Data(data); -n = data.getCongestionMark(); -let blob: ndn.Blob = data.getContent(); let name: ndn.Name = data.getName(); -n = data.getIncomingFaceId(); +name = data.getFullName(); meta = data.getMetaInfo(); -name = data.getName(); +let blob: ndn.Blob = data.getContent(); const sig: ndn.Signature = data.getSignature(); +n = data.getCongestionMark(); +n = data.getIncomingFaceId(); -data = data.setContent(blob) +data = data.setName(name) .setMetaInfo(meta) - .setName(name) + .setContent(blob) + .setContent(Buffer.alloc(4)) .setSignature(sig); data.wireDecode(blob);