source: trip-planner-front/node_modules/webpack/lib/util/MapHelpers.js@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 472 bytes
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8/**
9 * @template K
10 * @template V
11 * @param {Map<K, V>} map a map
12 * @param {K} key the key
13 * @param {function(): V} computer compute value
14 * @returns {V} value
15 */
16exports.provide = (map, key, computer) => {
17 const value = map.get(key);
18 if (value !== undefined) return value;
19 const newValue = computer();
20 map.set(key, newValue);
21 return newValue;
22};
Note: See TracBrowser for help on using the repository browser.