Skip to content

Commit

Permalink
IE11 fix using lodash .find (#106) (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszglow authored Oct 29, 2020
1 parent 856311e commit beecbf0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gulp/tasks/lodash.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function(gulp) {
const shell = require('gulp-shell');

const configs = {
include: ['cloneDeep', 'cloneDeepWith', 'get', 'has', 'isEmpty', 'isEqual', 'isNull', 'isPlainObject', 'isObject', 'merge', 'mergeWith', 'omit', 'reject'],
include: ['cloneDeep', 'cloneDeepWith', 'get', 'has', 'isEmpty', 'isEqual', 'isNull', 'isPlainObject', 'isObject', 'merge', 'mergeWith', 'omit', 'reject', 'find'],
output: 'custom-lodash.js'
};

Expand Down
3 changes: 2 additions & 1 deletion src/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const _ = require('../custom-lodash');
const isPlainObject = _.isPlainObject;
const isEmpty = _.isEmpty;
const omit = _.omit;
const find = _.find;

const dataMatchesContraints = require('./utils/dataMatchesContraints');
const ITEM_CONSTRAINTS = require('./itemConstraints');
Expand All @@ -34,7 +35,7 @@ module.exports = function(itemConfig, index) {
const _valid = !!_type;

function getType() {
return Object.keys(ITEM_CONSTRAINTS).find(key => dataMatchesContraints(_config, ITEM_CONSTRAINTS[key])) ||
return find(Object.keys(ITEM_CONSTRAINTS), key => dataMatchesContraints(_config, ITEM_CONSTRAINTS[key])) ||
(typeof _config === 'function' && CONSTANTS.itemType.FCTN) ||
(isPlainObject(_config) && CONSTANTS.itemType.DATA);
}
Expand Down
5 changes: 4 additions & 1 deletion src/utils/dataMatchesContraints.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const _ = require('../../custom-lodash');
const find = _.find;

module.exports = function(data, constraints) {
// Go through all constraints and find one which does not match the data
const foundObjection = Object.keys(constraints).find(key => {
const foundObjection = find(Object.keys(constraints), key => {
const type = constraints[key].type;
const supportedValues = key && constraints[key].values;
const mandatory = !constraints[key].optional;
Expand Down

0 comments on commit beecbf0

Please sign in to comment.