Skip to content

Commit 1c162a2

Browse files
committed
adde Object.equals, so you can compare dicts, for example like this: if my_dict.equals(other_dict).
1 parent 76cf8bb commit 1c162a2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sunsnake_compiler.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,11 @@ Object.prototype.values = function() {
605605
return Object.values(this)
606606
}
607607
Object.prototype.includes = function(key) { // to allow for if name in dict, instad of having to do if name in dict.keys()
608-
return Object.keys(this).includes(key);
609-
};
608+
return Object.keys(this).includes(key)
609+
}
610+
Object.prototype.equals = function(other) {
611+
return JSON.stringify(this) == JSON.stringify(other)
612+
}
610613

611614
function tuple(arr) {
612615
return arr

0 commit comments

Comments
 (0)