dict: Make set method return value consistent with Map.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg
2020-02-02 22:18:13 -08:00
committed by Tim Abbott
parent ab61222dd5
commit 0e657756f1
6 changed files with 9 additions and 9 deletions

View File

@@ -36,7 +36,7 @@ run_test('basic', () => {
const val = ['foo'];
const res = d.set('abc', val);
assert.equal(val, res);
assert.strictEqual(res, d);
});
run_test('undefined_keys', () => {

View File

@@ -36,7 +36,7 @@ run_test('basic', () => {
const val = ['foo'];
const res = d.set('abc', val);
assert.equal(val, res);
assert.strictEqual(res, d);
});
run_test('case insensitivity', () => {

View File

@@ -35,7 +35,7 @@ run_test('basic', () => {
const val = ['fred'];
const res = d.set(103, val);
assert.equal(val, res);
assert.strictEqual(res, d);
});

View File

@@ -5,9 +5,9 @@ export class Dict<V> {
return this._items.get(this._munge(key));
}
set(key: string, value: V): V {
set(key: string, value: V): Dict<V> {
this._items.set(this._munge(key), value);
return value;
return this;
}
has(key: string): boolean {

View File

@@ -25,9 +25,9 @@ export class FoldDict<V> {
return mapping.v;
}
set(key: string, value: V): V {
set(key: string, value: V): FoldDict<V> {
this._items.set(this._munge(key), {k: key, v: value});
return value;
return this;
}
has(key: string): boolean {

View File

@@ -26,10 +26,10 @@ export class IntDict<V> {
return this._map.get(key);
}
set(key: number, value: V): V {
set(key: number, value: V): IntDict<V> {
key = this._convert(key);
this._map.set(key, value);
return value;
return this;
}
has(key: number): boolean {