Skip to content

Commit

Permalink
增加toNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
kala888 committed Mar 5, 2024
1 parent 943e711 commit 39b77cd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tixwork-ui/src/utils/object-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,23 @@ function parseToString(obj: any) {
return obj;
}

function toNumber(value: any) {
if (_.isNil(value) || (_.isString(value) && value.trim().length === 0)) {
return null;
}
const result = _.toNumber(value);
if (_.isNaN(result)) {
return null;
}
return result;
}

const ObjectUtils = {
isEmpty,
isNotEmpty,
noop,
toBoolean,
toNumber,
parseToObject,
parseToArray,
parseToString,
Expand Down

0 comments on commit 39b77cd

Please sign in to comment.