Skip to content

Commit

Permalink
Merge pull request #176 from oat-sa/feature/ADF-1391_upgrade-lodash
Browse files Browse the repository at this point in the history
Upgrade lodash to 4.17.21
  • Loading branch information
yukipastelcat authored Sep 29, 2023
2 parents e43c749 + c466aa4 commit c237af5
Show file tree
Hide file tree
Showing 10 changed files with 7,340 additions and 7,365 deletions.
14,665 changes: 7,321 additions & 7,344 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@oat-sa/browserslist-config-tao": "^1.0.1",
"@oat-sa/eslint-config-tao": "^2.0.0",
"@oat-sa/prettier-config": "^0.1.1",
"@oat-sa/tao-core-libs": "^0.5.3",
"@oat-sa/tao-core-libs": "^1.0.0",
"@oat-sa/tao-qunit-testrunner": "^2.0.0",
"async": "^0.2.10",
"dompurify": "^2.4.0",
Expand All @@ -59,7 +59,7 @@
"jquery": "1.9.1",
"jquery-mockjax": "^2.6.0",
"jquery-simulate": "^1.0.2",
"lodash": "2.4.1",
"lodash": "^4.17.21",
"mime": "^2.4.2",
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
Expand Down
4 changes: 1 addition & 3 deletions src/core/databindcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ export default {
takeControl($container, options) {
const control = {};
let model = {};
const binderOpts = _.pick(options, function (value, key) {
return key === 'encoders' || key === 'filters' || key === 'templates';
});
const binderOpts = _.pick(options, ['encoders', 'filters', 'templates']);

if (options.get) {
control.get = function get(cb) {
Expand Down
8 changes: 4 additions & 4 deletions src/core/databinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ const _unbind = function _unbind($node, $container, eventName) {
if (
bounds &&
_(bounds[eventName])
.where({ namespace: 'internalbinder' })
.filter({ namespace: 'internalbinder' })
.size() > 0
) {
toBind($node, $container).off(`${eventName}.internalbinder`);
Expand All @@ -216,7 +216,7 @@ const _bindOnce = function _bindOnce($node, $container, eventName, cb) {
if (
!bounds ||
_(bounds[eventName])
.where({ namespace: 'internalbinder' })
.filter({ namespace: 'internalbinder' })
.size() < 1
) {
toBind($node, $container).on(`${eventName}.internalbinder`, function (e, ...args) {
Expand Down Expand Up @@ -584,7 +584,7 @@ DataBinder.prototype._setNodeValue = function _setNodeValue($node, value) {
}

//assign value
if (_.contains(['INPUT', 'SELECT', 'TEXTAREA'], $node[0].nodeName)) {
if (_.includes(['INPUT', 'SELECT', 'TEXTAREA'], $node[0].nodeName)) {
if ($node.is(":text, input[type='hidden'], textarea, select")) {
$node.val(value).trigger('change');
} else if ($node.is(':radio, :checkbox')) {
Expand Down Expand Up @@ -621,7 +621,7 @@ DataBinder.prototype._setNodeValue = function _setNodeValue($node, value) {
DataBinder.prototype._getNodeValue = function _getNodeValue($node) {
const self = this;
let value;
if (_.contains(['INPUT', 'SELECT', 'TEXTAREA'], $node[0].nodeName)) {
if (_.includes(['INPUT', 'SELECT', 'TEXTAREA'], $node[0].nodeName)) {
if ($node.is(":text, input[type='hidden'], textarea, select")) {
value = $node.val();
} else if ($node.is(':radio, :checkbox')) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/logger/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function getLevelNum(level) {
if (_.isString(level) && _.has(levels, level)) {
return levels[level];
}
if (_.isNumber(level) && _.contains(levels, level)) {
if (_.isNumber(level) && _.includes(levels, level)) {
return level;
}
return levels[defaultLevel];
Expand Down
2 changes: 1 addition & 1 deletion src/core/mimetype.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const mimetypeHelper = {

const starType = checkType.replace(/\/.*$/, '/*');

return _.contains(validTypes, checkType) || _.contains(validTypes, starType);
return _.includes(validTypes, checkType) || _.includes(validTypes, starType);
},

/**
Expand Down
6 changes: 3 additions & 3 deletions src/core/moduleLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export default function moduleLoaderFactory(requiredModules, validate, specs) {
modules[def.category].push(def.module);
}

if (def.bundle && !_.contains(bundles, def.bundle)) {
if (def.bundle && !_.includes(bundles, def.bundle)) {
bundles.push(def.bundle);
}
return this;
Expand Down Expand Up @@ -193,7 +193,7 @@ export default function moduleLoaderFactory(requiredModules, validate, specs) {
.then(loadedModules => {
_.forEach(dependencies, (dependency, index) => {
const module = loadedModules[index];
const category = _.findKey(modules, val => _.contains(val, dependency));
const category = _.findKey(modules, val => _.includes(val, dependency));

if (typeof validate === 'function' && !validate(module)) {
throw new TypeError(`The module '${dependency}' is not valid`);
Expand Down Expand Up @@ -243,7 +243,7 @@ export default function moduleLoaderFactory(requiredModules, validate, specs) {
throw new TypeError('A list of modules must be an array');
}

if (!_.all(moduleList, validate)) {
if (!_.every(moduleList, validate)) {
throw new TypeError('The list does not contain valid modules');
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ var checkQuotas = function checkQuotas() {
* @returns {Boolean} true if valid
*/
var isBackendApiValid = function isBackendApiValid(backend) {
return _.all(backendApi, function methodExists(method) {
return _.every(backendApi, function methodExists(method) {
return _.isFunction(backend[method]);
});
};
Expand All @@ -195,7 +195,7 @@ var isBackendApiValid = function isBackendApiValid(backend) {
* @returns {Boolean} true if valid
*/
var isStorageApiValid = function isStorageApiValid(storage) {
return _.all(storeApi, function methodExists(method) {
return _.every(storeApi, function methodExists(method) {
return _.isFunction(storage[method]);
});
};
Expand Down
2 changes: 1 addition & 1 deletion src/core/store/memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ memoryStorageBackend.removeAll = function removeAll(validate) {
if (!_.isFunction(validate)) {
validate = null;
}
memoryStore = _.omit(memoryStore, function(store, storeName) {
memoryStore = _.omitBy(memoryStore, function(store, storeName) {
return validate ? validate(storeName) : true;
});
return Promise.resolve(true);
Expand Down
8 changes: 4 additions & 4 deletions src/util/urlParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ UrlParser.extractParams = function (search) {
* @returns {String|Boolean} the requested url part or false
*/
UrlParser.prototype.get = function (what) {
return _.contains(urlParts, what) ? this.data[what] : false;
return _.includes(urlParts, what) ? this.data[what] : false;
};

/**
Expand Down Expand Up @@ -134,7 +134,7 @@ UrlParser.prototype.getUrl = function (exclude) {
let url = '';
exclude = exclude || [];
if (this.data) {
if (this.data.hostname && !_.contains(exclude, 'host')) {
if (this.data.hostname && !_.includes(exclude, 'host')) {
url += `${this.data.protocol ? this.data.protocol : 'http:'}//${this.data.hostname.replace(/\/$/, '')}`;

//the value of the port seems to be different regardign the browser, so we prevent adding port if not usual
Expand All @@ -147,15 +147,15 @@ UrlParser.prototype.getUrl = function (exclude) {
}
url += this.data.pathname; //there is always a path

if (this.params && !_.contains(exclude, 'params')) {
if (this.params && !_.includes(exclude, 'params')) {
url += '?';
_.forEach(this.params, function (value, key) {
url += `${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;
});
url = url.substring(0, url.length - 1);
}

if (this.data.hash && !_.contains(exclude, 'hash')) {
if (this.data.hash && !_.includes(exclude, 'hash')) {
url += this.data.hash;
}
}
Expand Down

0 comments on commit c237af5

Please sign in to comment.