mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
dict: Make set method return value consistent with Map.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
ab61222dd5
commit
0e657756f1
@@ -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', () => {
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -35,7 +35,7 @@ run_test('basic', () => {
|
||||
|
||||
const val = ['fred'];
|
||||
const res = d.set(103, val);
|
||||
assert.equal(val, res);
|
||||
assert.strictEqual(res, d);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user