Sfoglia il codice sorgente

add default values for parameters and jsdoc

mightyplow 7 anni fa
parent
commit
4d5c0bd9e1
1 ha cambiato i file con 8 aggiunte e 1 eliminazioni
  1. 8 1
      src/object/defaults.js

+ 8 - 1
src/object/defaults.js

@@ -1,4 +1,11 @@
-const defaults = (obj, values) => ({
+/**
+ * Populates an object with default values.
+ *
+ * @param {Object} obj - the object to populate the values on
+ * @param {Object} values - the default values to populate on the target object
+ * @return {Object} a new object with the default values and the object values
+ */
+const defaults = (obj = {}, values = {}) => ({
     ...values,
     ...obj
 });