本文整理匯總了TypeScript中es6-shim.Set類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Set類的具體用法?TypeScript Set怎麽用?TypeScript Set使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Set類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Reader
pcsc.on("reader", (reader) => {
log(`New Reader(${ reader.name })`);
readers.add(reader);
reader.on("status", (status) => {
const changes = reader.state ^ status.state;
if (changes) {
if (changes & status.state & reader.SCARD_STATE_EMPTY) {
log(`Reader(${ reader.name }) card removed`);
reader.disconnect(reader.SCARD_LEAVE_CARD, (err) => {
if (err) {
log(`Reader(${ reader.name }) error on disconnect ${ err }`);
} else {
log(`Reader(${ reader.name }) card disconnected`);
}
});
} else if (changes & status.state & reader.SCARD_STATE_PRESENT) {
log(`Reader(${ reader.name }) card inserted`);
setTimeout(() => {
reader.connect({ share_mode: reader.SCARD_SHARE_SHARED }, (err, protocol) => {
if (err) {
log(`Reader(${ reader.name }) error on connect ${ err }`);
} else {
cb(new Card(reader, protocol));
}
});
}, 20);
}
}
});
reader.on('end', () => {
log(`Remove Reader(${ reader.name })`);
readers.delete(reader);
});
reader.on('error', (err) => log(`Error Reader(${ reader.name }): ${ err.message }`));
});
示例2: dispose
export function dispose() {
readers.forEach(reader => {
reader.close();
});
readers.clear();
}