Skip to content

Commit 12172c2

Browse files
author
Larry Botha
committed
Merge branch 'master' into feat/add-textarea-component
# Via GitHub (1) and Larry Botha (1) * master: chore(packages): remove unneeded property-expr refactor(utils): remove unused utils feat(utils): replace lodash.isequal with smaller dequal dep # Conflicts: # package-lock.json
2 parents d520f1d + 91450fe commit 12172c2

File tree

3 files changed

+232
-78
lines changed

3 files changed

+232
-78
lines changed

lib/util.js

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import isEqual from 'lodash.isequal';
2-
import {forEach} from 'property-expr';
1+
import {dequal as isEqual} from 'dequal/lite';
32

43
function subscribeOnce(observable) {
54
return new Promise((resolve) => {
@@ -85,12 +84,6 @@ function assignDeep(object, value) {
8584
return copy;
8685
}
8786

88-
function has(object, key) {
89-
return (
90-
object != undefined && Object.prototype.hasOwnProperty.call(object, key)
91-
);
92-
}
93-
9487
function set(object, path, value) {
9588
if (new Object(object) !== object) return object;
9689

@@ -118,53 +111,6 @@ function set(object, path, value) {
118111
return object;
119112
}
120113

121-
// Implementation of yup.reach
122-
// TODO rewrite to simpler version and remove dependency on forEach
123-
function reach(object, path, value, context) {
124-
return getIn(object, path, value, context).schema;
125-
}
126-
127-
function trim(part) {
128-
return part.slice(0, -1).slice(1);
129-
}
130-
131-
function getIn(schema, path, value, context) {
132-
let parent, lastPart, lastPartDebug;
133-
134-
context = context || value;
135-
136-
if (!path)
137-
return {
138-
parent,
139-
parentPath: path,
140-
schema,
141-
};
142-
143-
forEach(path, (_part, isBracket, isArray) => {
144-
let part = isBracket ? trim(_part) : _part;
145-
146-
if (isArray || has(schema, '_subType')) {
147-
let index = isArray ? Number.parseInt(part, 10) : 0;
148-
schema = schema.resolve({context, parent, value})._subType;
149-
if (value) {
150-
value = value[index];
151-
}
152-
}
153-
154-
if (!isArray) {
155-
schema = schema.resolve({context, parent, value});
156-
schema = schema.fields[part];
157-
parent = value;
158-
value = value && value[part];
159-
lastPart = part;
160-
// eslint-disable-next-line no-unused-vars
161-
lastPartDebug = isBracket ? '[' + _part + ']' : '.' + _part;
162-
}
163-
});
164-
165-
return {schema, parent, parentPath: lastPart};
166-
}
167-
168114
export const util = {
169115
assignDeep,
170116
cloneDeep,
@@ -173,7 +119,6 @@ export const util = {
173119
getValues,
174120
isEmpty,
175121
isNullish,
176-
reach,
177122
set,
178123
subscribeOnce,
179124
update,

0 commit comments

Comments
 (0)