Skip to content

Commit

Permalink
Return '@null' if args is null ASAP (#767)
Browse files Browse the repository at this point in the history
* chore: return 'null' if arg[i] is null ASAP

* chore: update comment

* chore: use continue
  • Loading branch information
matamatanot authored Dec 8, 2020
1 parent c003b30 commit fddc048
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/libs/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ export default function hash(args: any[]): string {
if (!args.length) return ''
let key = 'arg'
for (let i = 0; i < args.length; ++i) {
if (args[i] === null) {
key += '@null'
continue
}
let _hash
if (
args[i] === null ||
(typeof args[i] !== 'object' && typeof args[i] !== 'function')
) {
if (typeof args[i] !== 'object' && typeof args[i] !== 'function') {
// need to consider the case that args[i] is a string:
// args[i] _hash
// "undefined" -> '"undefined"'
// undefined -> 'undefined'
// 123 -> '123'
// null -> 'null'
// "null" -> '"null"'
if (typeof args[i] === 'string') {
_hash = '"' + args[i] + '"'
Expand Down

0 comments on commit fddc048

Please sign in to comment.