isArray to native Array.isArray

isUnd(*) to native undefined === *
isFunc to native typeof * === 'function'
isObject to native typeof * === 'object'
microtime() to native Date().getTime();
noop to native ()=>{}
noopFalse to native ()=>false
noopTrue to native ()=>true
boolToAjax to native *?'1':'0'
Underscore.js to native
This commit is contained in:
djmaze 2020-07-29 21:49:41 +02:00
parent fa39c7ecba
commit ea48f5060b
72 changed files with 551 additions and 775 deletions

View file

@ -1,4 +1,3 @@
import { isFunc, isArray, isUnd } from 'Common/Utils';
import { data as GlobalsData } from 'Common/Globals';
import * as Settings from 'Storage/Settings';
@ -11,8 +10,8 @@ const SIMPLE_HOOKS = {},
* @param {Function} callback
*/
export function addHook(name, callback) {
if (isFunc(callback)) {
if (!isArray(SIMPLE_HOOKS[name])) {
if (typeof callback === 'function') {
if (!Array.isArray(SIMPLE_HOOKS[name])) {
SIMPLE_HOOKS[name] = [];
}
@ -25,7 +24,7 @@ export function addHook(name, callback) {
* @param {Array=} args = []
*/
export function runHook(name, args = []) {
if (isArray(SIMPLE_HOOKS[name])) {
if (Array.isArray(SIMPLE_HOOKS[name])) {
SIMPLE_HOOKS[name].forEach(callback => {
callback(...args);
});
@ -89,6 +88,6 @@ export function runSettingsViewModelHooks(admin) {
*/
export function settingsGet(pluginSection, name) {
let plugins = Settings.settingsGet('Plugins');
plugins = plugins && !isUnd(plugins[pluginSection]) ? plugins[pluginSection] : null;
return plugins ? (isUnd(plugins[name]) ? null : plugins[name]) : null;
plugins = plugins && undefined !== plugins[pluginSection] ? plugins[pluginSection] : null;
return plugins ? (undefined === plugins[name] ? null : plugins[name]) : null;
}