本文整理匯總了TypeScript中vs/base/common/map.ResourceMap.clear方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ResourceMap.clear方法的具體用法?TypeScript ResourceMap.clear怎麽用?TypeScript ResourceMap.clear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/base/common/map.ResourceMap
的用法示例。
在下文中一共展示了ResourceMap.clear方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('ResourceMap - basics', function () {
const map = new ResourceMap<any>();
const resource1 = URI.parse('some://1');
const resource2 = URI.parse('some://2');
const resource3 = URI.parse('some://3');
const resource4 = URI.parse('some://4');
const resource5 = URI.parse('some://5');
const resource6 = URI.parse('some://6');
assert.equal(map.size, 0);
map.set(resource1, 1);
map.set(resource2, '2');
map.set(resource3, true);
const values = map.values();
assert.equal(values[0], 1);
assert.equal(values[1], '2');
assert.equal(values[2], true);
let counter = 0;
map.forEach(value => {
assert.equal(value, values[counter++]);
});
const obj = Object.create(null);
map.set(resource4, obj);
const date = Date.now();
map.set(resource5, date);
assert.equal(map.size, 5);
assert.equal(map.get(resource1), 1);
assert.equal(map.get(resource2), '2');
assert.equal(map.get(resource3), true);
assert.equal(map.get(resource4), obj);
assert.equal(map.get(resource5), date);
assert.ok(!map.get(resource6));
map.delete(resource6);
assert.equal(map.size, 5);
assert.ok(map.delete(resource1));
assert.ok(map.delete(resource2));
assert.ok(map.delete(resource3));
assert.ok(map.delete(resource4));
assert.ok(map.delete(resource5));
assert.equal(map.size, 0);
assert.ok(!map.get(resource5));
assert.ok(!map.get(resource4));
assert.ok(!map.get(resource3));
assert.ok(!map.get(resource2));
assert.ok(!map.get(resource1));
map.set(resource1, 1);
map.set(resource2, '2');
map.set(resource3, true);
assert.ok(map.has(resource1));
assert.equal(map.get(resource1), 1);
assert.equal(map.get(resource2), '2');
assert.equal(map.get(resource3), true);
map.clear();
assert.equal(map.size, 0);
assert.ok(!map.get(resource1));
assert.ok(!map.get(resource2));
assert.ok(!map.get(resource3));
assert.ok(!map.has(resource1));
map.set(resource1, false);
map.set(resource2, 0);
assert.ok(map.has(resource1));
assert.ok(map.has(resource2));
});