REFACTOR: Use Array.isArray instead of _.isArray

This commit is contained in:
Robin Ward 2020-08-31 15:39:10 -04:00
parent b129abfc11
commit 2f11457263
7 changed files with 11 additions and 9 deletions

View File

@ -5,6 +5,8 @@
"discourse-ember/global-ember": 2 "discourse-ember/global-ember": 2
}, },
"globals": { "globals": {
"bootbox": "off" "bootbox": "off",
"Mousetrap": "off",
"_": "off"
} }
} }

View File

@ -492,7 +492,7 @@ Report.reopenClass({
const startDate = options.startDate || "start_date"; const startDate = options.startDate || "start_date";
const endDate = options.endDate || "end_date"; const endDate = options.endDate || "end_date";
if (_.isArray(report[dataField])) { if (Array.isArray(report[dataField])) {
const startDateFormatted = moment const startDateFormatted = moment
.utc(report[startDate]) .utc(report[startDate])
.locale("en") .locale("en")

View File

@ -27,7 +27,7 @@ export default Component.extend({
$(this.element.querySelector("input")).autocomplete({ $(this.element.querySelector("input")).autocomplete({
debounced: true, debounced: true,
allowAny: false, allowAny: false,
items: _.isArray(groupNames) items: Array.isArray(groupNames)
? groupNames ? groupNames
: isEmpty(groupNames) : isEmpty(groupNames)
? [] ? []

View File

@ -275,7 +275,7 @@ export default Component.extend({
const group = this.get("searchedTerms.group"); const group = this.get("searchedTerms.group");
if (match.length !== 0) { if (match.length !== 0) {
const existingInput = _.isArray(group) ? group[0] : group; const existingInput = Array.isArray(group) ? group[0] : group;
const userInput = match[0].replace(REGEXP_GROUP_PREFIX, ""); const userInput = match[0].replace(REGEXP_GROUP_PREFIX, "");
if (existingInput !== userInput) { if (existingInput !== userInput) {
@ -294,7 +294,7 @@ export default Component.extend({
const badge = this.get("searchedTerms.badge"); const badge = this.get("searchedTerms.badge");
if (match.length !== 0) { if (match.length !== 0) {
const existingInput = _.isArray(badge) ? badge[0] : badge; const existingInput = Array.isArray(badge) ? badge[0] : badge;
const userInput = match[0].replace(REGEXP_BADGE_PREFIX, ""); const userInput = match[0].replace(REGEXP_BADGE_PREFIX, "");
if (existingInput !== userInput) { if (existingInput !== userInput) {
@ -317,7 +317,7 @@ export default Component.extend({
if (match.length !== 0) { if (match.length !== 0) {
const join_char = contain_all_tags ? "+" : ","; const join_char = contain_all_tags ? "+" : ",";
const existingInput = _.isArray(tags) ? tags.join(join_char) : tags; const existingInput = Array.isArray(tags) ? tags.join(join_char) : tags;
const userInput = match[0].replace(REGEXP_TAGS_REPLACE, ""); const userInput = match[0].replace(REGEXP_TAGS_REPLACE, "");
if (existingInput !== userInput) { if (existingInput !== userInput) {

View File

@ -113,7 +113,7 @@ export default function(options) {
if (options.single) { if (options.single) {
inputSelectedItems = []; inputSelectedItems = [];
} }
transformed = _.isArray(transformedItem) transformed = Array.isArray(transformedItem)
? transformedItem ? transformedItem
: [transformedItem || item]; : [transformedItem || item];

View File

@ -6,7 +6,7 @@ import { htmlSafe as htmlSafeTemplateHelper } from "@ember/template";
function addonFmt(str, formats) { function addonFmt(str, formats) {
let cachedFormats = formats; let cachedFormats = formats;
if (!_.isArray(cachedFormats) || arguments.length > 2) { if (!Array.isArray(cachedFormats) || arguments.length > 2) {
cachedFormats = new Array(arguments.length - 1); cachedFormats = new Array(arguments.length - 1);
for (let i = 1, l = arguments.length; i < l; i++) { for (let i = 1, l = arguments.length; i < l; i++) {

View File

@ -13,7 +13,7 @@ QUnit.module("lib:keyboard-shortcuts", {
_bindings[binding] = callback; _bindings[binding] = callback;
}.bind(this); }.bind(this);
if (_.isArray(bindings)) { if (Array.isArray(bindings)) {
bindings.forEach(registerBinding, this); bindings.forEach(registerBinding, this);
} else { } else {
registerBinding(bindings); registerBinding(bindings);