source: frontend/node_modules/@pmmmwh/react-refresh-webpack-plugin/options/index.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.0 KB
Line 
1/**
2 * Sets a constant default value for the property when it is undefined.
3 * @template T
4 * @template {keyof T} Property
5 * @param {T} object An object.
6 * @param {Property} property A property of the provided object.
7 * @param {T[Property]} [defaultValue] The default value to set for the property.
8 * @returns {T[Property]} The defaulted property value.
9 */
10const d = (object, property, defaultValue) => {
11 if (typeof object[property] === 'undefined' && typeof defaultValue !== 'undefined') {
12 object[property] = defaultValue;
13 }
14 return object[property];
15};
16
17/**
18 * Resolves the value for a nested object option.
19 * @template T
20 * @template {keyof T} Property
21 * @template Result
22 * @param {T} object An object.
23 * @param {Property} property A property of the provided object.
24 * @param {function(T | undefined): Result} fn The handler to resolve the property's value.
25 * @returns {Result} The resolved option value.
26 */
27const n = (object, property, fn) => {
28 object[property] = fn(object[property]);
29 return object[property];
30};
31
32module.exports = { d, n };
Note: See TracBrowser for help on using the repository browser.