本文整理匯總了TypeScript中util.TextDecoder類的典型用法代碼示例。如果您正苦於以下問題:TypeScript TextDecoder類的具體用法?TypeScript TextDecoder怎麽用?TypeScript TextDecoder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TextDecoder類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: cb
const arg1: (arg: string) => Promise<number> = util.promisify((arg: string, cb: (err: Error | null, result: number) => void): void => { });
const arg1NoResult: (arg: string) => Promise<any> = util.promisify((arg: string, cb: (err: Error | null) => void): void => { });
const cbOptionalError: () => Promise<void | {}> = util.promisify((cb: (err?: Error | null) => void): void => { cb(); }); // tslint:disable-line void-return
assert(typeof util.promisify.custom === 'symbol');
// util.deprecate
const foo = () => {};
// $ExpectType () => void
util.deprecate(foo, 'foo() is deprecated, use bar() instead');
// $ExpectType <T extends Function>(fn: T, message: string) => T
util.deprecate(util.deprecate, 'deprecate() is deprecated, use bar() instead');
// util.isDeepStrictEqual
util.isDeepStrictEqual({foo: 'bar'}, {foo: 'bar'});
// util.TextDecoder()
const td = new util.TextDecoder();
new util.TextDecoder("utf-8");
new util.TextDecoder("utf-8", { fatal: true });
new util.TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
const ignoreBom: boolean = td.ignoreBOM;
const fatal: boolean = td.fatal;
const encoding: string = td.encoding;
td.decode(new Int8Array(1));
td.decode(new Int16Array(1));
td.decode(new Int32Array(1));
td.decode(new Uint8Array(1));
td.decode(new Uint16Array(1));
td.decode(new Uint32Array(1));
td.decode(new Uint8ClampedArray(1));
td.decode(new Float32Array(1));
td.decode(new Float64Array(1));
示例2: decode
public async decode(input: ArrayBuffer | DataView | TypedArray) {
return this.td.decode(input)
}