本文整理匯總了TypeScript中vs/base/common/map.BoundedMap類的典型用法代碼示例。如果您正苦於以下問題:TypeScript BoundedMap類的具體用法?TypeScript BoundedMap怎麽用?TypeScript BoundedMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了BoundedMap類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('BoundedMap - serialization', function () {
const map = new BoundedMap<any>(5);
map.set('1', 1);
map.set('2', '2');
map.set('3', true);
const obj = Object.create(null);
map.set('4', obj);
const date = Date.now();
map.set('5', date);
const mapClone = new BoundedMap<any>(5, 1, map.serialize());
assert.deepEqual(map.serialize(), mapClone.serialize());
assert.equal(mapClone.size, 5);
assert.equal(mapClone.get('1'), 1);
assert.equal(mapClone.get('2'), '2');
assert.equal(mapClone.get('3'), true);
assert.equal(mapClone.get('4'), obj);
assert.equal(mapClone.get('5'), date);
assert.ok(!mapClone.get('6'));
mapClone.set('6', '6');
assert.equal(mapClone.size, 5);
assert.ok(!mapClone.get('1'));
});
示例2: peek
function peek(key) {
const res = map.get(key);
if (res) {
map.delete(key);
map.set(key, res);
}
return res;
}