Skip to content
Open
Show file tree
Hide file tree
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
13 changes: 10 additions & 3 deletions src/Destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
*/

export function objectDestroy(object: any) {
for (const [key, value] of Object.entries(object)) {
if (object === null || typeof object !== 'object') {
return
}
for (const key of Object.keys(object)) {
if (!Object.prototype.hasOwnProperty.call(object, key)) {
continue
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant hasOwnProperty check after Object.keys

Low Severity

The hasOwnProperty guard is redundant here because Object.keys() already returns only an object's own enumerable properties by specification. The condition !Object.prototype.hasOwnProperty.call(object, key) can never be true for keys returned by Object.keys(object), making this a dead branch that adds unnecessary complexity without any protective benefit.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fd8eb55. Configure here.

const value = object[key]
if (value instanceof Function) {
(object as Record<string, any>)[key] = postMortem(value)
object[key] = postMortem(value)
} else {
delete (object as Record<string, any>)[key]
delete object[key]
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/NumberLiteralHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export class NumberLiteralHelper {
constructor(
private readonly config: Config
) {
const thousandSeparator = this.config.thousandSeparator === '.' ? `\\${this.config.thousandSeparator}` : this.config.thousandSeparator
const decimalSeparator = this.config.decimalSeparator === '.' ? `\\${this.config.decimalSeparator}` : this.config.decimalSeparator
const escapeRegex = (str: string): string => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const thousandSeparator = escapeRegex(this.config.thousandSeparator)
const decimalSeparator = escapeRegex(this.config.decimalSeparator)

this.numberPattern = new RegExp(`^([+-]?((${decimalSeparator}\\d+)|(\\d+(${thousandSeparator}\\d{3,})*(${decimalSeparator}\\d*)?)))([eE][+-]?\\d+)?$`)
this.allThousandSeparatorsRegex = new RegExp(`${thousandSeparator}`, 'g')
Expand Down
Loading