Underscore.js _.each() to native Array.forEach() (optional with Object.entries/values)

This commit is contained in:
djmaze 2020-07-22 14:49:18 +02:00
parent 178e5f6ef7
commit a5d41edb24
25 changed files with 72 additions and 79 deletions

View file

@ -1,4 +1,3 @@
import _ from '_';
import { isObject, isUnd } from 'Common/Utils';
import * as Plugins from 'Common/Plugins';
@ -14,7 +13,7 @@ export function sub(name, func, context) {
context = func || null;
func = null;
_.each(name, (subFunc, subName) => {
Object.entries(name).forEach(([subFunc, subName]) => {
sub(subName, subFunc, context);
});
} else {
@ -34,7 +33,7 @@ export function pub(name, args) {
Plugins.runHook('rl-pub', [name, args]);
if (!isUnd(SUBS[name])) {
_.each(SUBS[name], (items) => {
SUBS[name].forEach(items => {
if (items[0]) {
items[0].apply(items[1] || null, args || []);
}