mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Remove helpers.deepFreeze and call Object.freeze only on things that need it for ~11% time reduction measured via profile-fixture.mjs on Apple Silicon M1.
This commit is contained in:
parent
b6471fba31
commit
936c876810
5 changed files with 110 additions and 97 deletions
|
@ -953,40 +953,6 @@ test("applyFixes", (t) => {
|
|||
}
|
||||
});
|
||||
|
||||
test("deepFreeze", (t) => {
|
||||
t.plan(6);
|
||||
const obj = {
|
||||
"prop": true,
|
||||
"func": () => true,
|
||||
"sub": {
|
||||
"prop": [ 1 ],
|
||||
"sub": {
|
||||
"prop": "one"
|
||||
}
|
||||
}
|
||||
};
|
||||
t.is(helpers.deepFreeze(obj), obj, "Did not return object.");
|
||||
for (const scenario of [
|
||||
() => {
|
||||
obj.prop = false;
|
||||
},
|
||||
() => {
|
||||
obj.func = () => false;
|
||||
},
|
||||
() => {
|
||||
obj.sub.prop = [];
|
||||
},
|
||||
() => {
|
||||
obj.sub.prop[0] = 0;
|
||||
},
|
||||
() => {
|
||||
obj.sub.sub.prop = "zero";
|
||||
}
|
||||
]) {
|
||||
t.throws(scenario, null, "Assigned to frozen object.");
|
||||
}
|
||||
});
|
||||
|
||||
test("forEachLink", (t) => {
|
||||
t.plan(291);
|
||||
const testCases = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue