Skip to content

Commit

Permalink
fix stringsINArray
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Aug 29, 2024
1 parent 432dcda commit 6fd5fc6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions libs/stringsInArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.stringsInArray = stringsInArray;
exports.someInArray = someInArray;
exports.extractFieldValues = extractFieldValues;
const isValue_1 = require("../utils/isValue");
/**
* @notused
*/
Expand All @@ -26,9 +27,14 @@ function stringsInArray(check, array) {
}
}
function someInArray(check, array) {
if (!(0, isValue_1.isValue)(check))
return false;
if (typeof check === 'string') {
check = [check];
}
else if (!Array.isArray(check)) {
return false;
}
return array.some((e) => check.includes(e));
}
function extractFieldValues(obj, fields, exclude = true, result = []) {
Expand Down
6 changes: 6 additions & 0 deletions libs/stringsInArray.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isValue } from "../utils/isValue";

/**
* @notused
*/
Expand All @@ -22,8 +24,12 @@ export function stringsInArray(check: string[] | string, array: string[]): boole
}

export function someInArray(check: string[] | string, array: string[]) {
if(!isValue(check)) return false;

if (typeof check === 'string') {
check = [check];
} else if(!Array.isArray(check)) {
return false;
}

return array.some((e)=> check.includes(e));
Expand Down
2 changes: 1 addition & 1 deletion models/Order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ let Model = {

await Order.update({ id: order.id }, promotionOrderToSave).fetch();
} catch (error) {
sails.log.error(`Core > order > promotion calculate fail: `, error)
sails.log.error(`Core > order > promotion calculate fail: `, error);
} finally {
// finally
order.isPromoting = false;
Expand Down

0 comments on commit 6fd5fc6

Please sign in to comment.