Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tell serialize fn if it's being used on arguments #284

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
noBody: boolean
throwError: boolean
retryOnInvalidCache: boolean
serialize: (val: unknown) => string
serialize: (val: unknown, isArgs: boolean) => string
deserialize: (val: string) => unknown
}

function serialize(val: unknown) {
function serialize(val: unknown, _isArgs: boolean) {

Check failure on line 25 in src/index.ts

View workflow job for this annotation

GitHub Actions / Test with Node v20

'_isArgs' is defined but never used
const circRefColl: unknown[] = []
return JSON.stringify(val, function (name, value) {
if (typeof value === 'function') {
Expand Down Expand Up @@ -60,7 +60,7 @@
fnStr = options.astBody ? JSON.stringify(fnStr) : fnStr
}

const argsStr = options.serialize(args)
const argsStr = options.serialize(args, true)
const hash = crypto
.createHash('md5')
.update(fnStr + argsStr + salt)
Expand Down Expand Up @@ -127,7 +127,7 @@
let resultString
if ((r && typeof r === 'object') || typeof r === 'string') {
resultObj = { data: r }
resultString = optExt.serialize(resultObj)
resultString = optExt.serialize(resultObj, false)
} else {
resultString = '{"data":' + r + '}'
}
Expand Down
Loading