Skip to content

Commit faf4895

Browse files
replace map function with forEach where map
function is not needed
1 parent 830d553 commit faf4895

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

example/complete-example/src/components/tabs/tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export default function (props) {
117117
ref.current.log('[beforeSelect]');
118118
return true;
119119
});
120-
_instance.getData().openTabIDs.map((id) => {
120+
_instance.getData().openTabIDs.forEach((id) => {
121121
_instance.setTab(id, {closable: false});
122122
});
123123
_instance

src/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ beforeEach(() => {
4141
const _options = Object.assign({}, op, options);
4242
if (_options.tabs) {
4343
const _tabs = [];
44-
_options.tabs.map((tab) => {
44+
_options.tabs.forEach((tab) => {
4545
_tabs.push({...tab});
4646
});
4747
_options.tabs = _tabs;

src/utils/api/api.factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const _apiProps = {
6363
},
6464
_subscribeCallbacksOptions: function () {
6565
const op = this.optionsManager.options;
66-
Object.keys(this._publishers).map((eventName) => {
66+
Object.keys(this._publishers).forEach((eventName) => {
6767
if (eventName[0] !== '_')
6868
this.on(eventName, function () {
6969
op[eventName].apply(this, arguments);

src/utils/api/api.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ describe('user api : ', () => {
2525
];
2626
expect(Object.keys(obj.userProxy).length === userApi.length).toBe(true);
2727
let _isEqual = true;
28-
userApi.map((value) => {
28+
userApi.forEach((value) => {
2929
if (!Object.prototype.hasOwnProperty.call(obj.userProxy, value)) {
3030
_isEqual = false;
3131
}

src/utils/api/optionManager/optionManager.factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Object.assign(OptionManager.prototype, {
6262
// set this.initialTabs and this.initialState
6363
const {selectedTabID, tabs} = this.options,
6464
openTabIDs = [];
65-
tabs.map((tab) => {
65+
tabs.forEach((tab) => {
6666
const newTab = this.validateTabData(tab);
6767
this.initialTabs.push(newTab);
6868
openTabIDs.push(newTab.id);

src/utils/api/pub_sub.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ helper.setNoneEnumProps(Pub_Sub.prototype, {
4949
context = context || null;
5050
const result = [];
5151
const _subscribers = [...this._publishers[publisherName]];
52-
_subscribers.map((subscriber) => {
52+
_subscribers.forEach((subscriber) => {
5353
result.push(subscriber.apply(context, generateParamsCallback()));
5454
});
5555
return result;

src/utils/api/tabs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function Tabs({initialTabs} = {initialTabs: []}) {
22
this._data = [];
33
if (initialTabs && initialTabs.constructor === Array && initialTabs.length) {
4-
initialTabs.map((tab) => {
4+
initialTabs.forEach((tab) => {
55
this._addTab(tab);
66
});
77
}

src/utils/helper.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const helper = {
1212
},
1313
assingAll: function (targetObj, ...sourcObjs) {
1414
// copy all enumerable and not enumerable properties into the target
15-
sourcObjs.map((sourcObj) => {
15+
sourcObjs.forEach((sourcObj) => {
1616
const enum_only = Object.keys(sourcObj);
17-
Object.getOwnPropertyNames(sourcObj).map((prop) => {
17+
Object.getOwnPropertyNames(sourcObj).forEach((prop) => {
1818
if (enum_only.indexOf(prop) >= 0) targetObj[prop] = sourcObj[prop];
1919
else
2020
Object.defineProperty(targetObj, prop, {
@@ -27,7 +27,7 @@ const helper = {
2727
},
2828
setNoneEnumProps: function (obj, props) {
2929
const noneEnum = {};
30-
Object.keys(props).map((prop) => {
30+
Object.keys(props).forEach((prop) => {
3131
noneEnum[prop] = {
3232
writable: true,
3333
value: props[prop],
@@ -38,7 +38,7 @@ const helper = {
3838
getArraysDiff: function (arr1, arr2) {
3939
const arr1Copy = [...arr1],
4040
arr2Copy = [...arr2];
41-
arr1.map((item) => {
41+
arr1.forEach((item) => {
4242
if (arr2.indexOf(item) >= 0) {
4343
arr1Copy.splice(arr1Copy.indexOf(item), 1);
4444
arr2Copy.splice(arr2Copy.indexOf(item), 1);

0 commit comments

Comments
 (0)