Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Add alternate implementation of forEach#8

Merged
PythonCoderAS merged 1 commit intomasterfromforeach_new_impl
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionarrayStringMap.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -250,7 +250,6 @@ describe("Map with two objects", () => {
it("Map forEach is called twice", () => {
let count = 0;
arrayStringMap.forEach((value, key, map) => {
count++;
assert(map === arrayStringMap, "Map is arrayStringMap");
if (count === 0){
assert(key === sampleArray1, "Key is sampleArray1");
Expand All@@ -260,6 +259,7 @@ describe("Map with two objects", () => {
assert(key === sampleArray3, "Key is sampleArray3");
assert(value === sampleValue2, "Value is sampleValue2");
}
count++;
});
assert(count === 2, "ForEach is called twice");
})
Expand Down
8 changes: 3 additions & 5 deletionsarrayStringMap.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -51,11 +51,9 @@ export default class ArrayStringMap<K extends any[], V> implements Map<K, V> {
}

forEach(callbackfn: (value: V, key: K, map: ArrayStringMap<K, V>) => void, thisArg?: any): void {
this._converterInfo.forEach((value, key) => {
// TypeScript complains that this will be undefined, but the items in
// `this._converterInfo` and `this._map` will always be defined in each other.
return callbackfn(this._map.get(key)!, value, thisArg);
});
for (const [key, value] of this.entries()) {
callbackfn.call(thisArg, value, key, this);
}
}

get(key: K): V | undefined {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp