forked from mystiq/hydrogen-web
Add type annotations to common
This commit is contained in:
parent
e53f3d23d5
commit
bf53449f66
1 changed files with 3 additions and 2 deletions
|
@ -14,9 +14,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
import {BaseObservableList} from "./BaseObservableList";
|
||||
|
||||
/* inline update of item in collection backed by array, without replacing the preexising item */
|
||||
export function findAndUpdateInArray(predicate, array, observable, updater) {
|
||||
export function findAndUpdateInArray<T>(predicate: (value: T) => boolean, array: T[], observable: BaseObservableList<T>, updater: (value: T) => any | false) {
|
||||
const index = array.findIndex(predicate);
|
||||
if (index !== -1) {
|
||||
const value = array[index];
|
||||
|
@ -29,4 +30,4 @@ export function findAndUpdateInArray(predicate, array, observable, updater) {
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue