not-node 6.2.0 → 6.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/fields/index.js +24 -0
package/package.json
CHANGED
package/src/fields/index.js
CHANGED
|
@@ -180,3 +180,27 @@ function getMutationForField(name, list) {
|
|
|
180
180
|
return false;
|
|
181
181
|
}
|
|
182
182
|
module.exports.getMutationForField = getMutationForField;
|
|
183
|
+
|
|
184
|
+
function mutateFieldSide(field, mutation, side) {
|
|
185
|
+
if (Object.hasOwn(mutation, side)) {
|
|
186
|
+
if (Object.hasOwn(field, side)) {
|
|
187
|
+
field[side] = { ...field[side], ...mutation[side] };
|
|
188
|
+
} else {
|
|
189
|
+
field[side] = mutation[side];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
module.exports.mutateFieldSide = mutateFieldSide;
|
|
195
|
+
|
|
196
|
+
function mutateField(sourceField, sourceMutation) {
|
|
197
|
+
const sides = ["ui", "model"];
|
|
198
|
+
let field = clone(sourceField);
|
|
199
|
+
let mutation = clone(sourceMutation);
|
|
200
|
+
if (mutation) {
|
|
201
|
+
sides.forEach((side) => mutateFieldSide(field, mutation, side));
|
|
202
|
+
}
|
|
203
|
+
return field;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
module.exports.mutateField = mutateField;
|