本文整理匯總了TypeScript中node-binary-marshal.Marshal函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript Marshal函數的具體用法?TypeScript Marshal怎麽用?TypeScript Marshal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Marshal函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: cb
this.readdir((derr: any, files: string[]) => {
if (derr) {
console.log('readdir: ' + derr);
cb(-EFAULT);
return;
}
files = files.filter((s: string) => s !== '.deletedFiles.log');
files.sort();
files = files.slice(this.off);
let dents = files.map((n) => new fs.Dirent(-1, fs.DT.UNKNOWN, n));
let view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
let voff = 0;
for (let i = 0; i < dents.length; i++) {
let dent = dents[i];
if (voff + dent.reclen > buf.byteLength)
break;
let [len, err] = Marshal(view, voff, dent, fs.DirentDef);
if (err) {
console.log('dirent marshal failed: ' + err);
cb(-EFAULT);
return;
}
voff += len;
this.off++;
}
cb(voff);
});
示例2: sys_getsockname
function sys_getsockname(cb: Function, trap: number, arg0: any, arg1: any, arg2: any): void {
console.log('TODO: getsockname');
let view = new DataView(arg1.buffer, arg1.byteOffset);
Marshal(arg1, 0, {family: 2, port: 8080, addr: '127.0.0.1'}, socket.SockAddrInDef);
arg2.$set(socket.SockAddrInDef.length);
setTimeout(cb, 0, [0, 0, 0]);
}
示例3: function
let args = [arg0, function(err: any, fd: number, remoteAddr: string, remotePort: number): void {
if (remoteAddr === 'localhost')
remoteAddr = '127.0.0.1';
let view = new DataView($acceptArray.buffer, $acceptArray.byteOffset);
Marshal(view, 0, {family: 2, port: remotePort, addr: remoteAddr}, socket.SockAddrInDef);
$acceptLen.$set(socket.SockAddrInDef.length);
cb([err ? -1 : fd, 0, err ? -1 : 0]);
}];