isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
99 lines (98 loc) • 2.09 kB
JavaScript
;
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable max-classes-per-file */
Object.defineProperty(exports, "__esModule", { value: true });
// -----
// Tests
// -----
function test(_saveData) { }
{
const saveDataWithPrimitives = {
run: {
foo: 123,
bar: "bar",
baz: true,
nested: {
foo: 123,
bar: "bar",
baz: true,
},
},
};
// Primitives and nested primitives are allowed.
test(saveDataWithPrimitives);
}
{
const saveDataWithEntity = {
run: {
foo: {},
},
};
// @ts-expect-error Isaac API classes are not serializable.
test(saveDataWithEntity);
}
{
const saveDataWithMap = {
run: {
foo: new Map(),
},
};
// Maps with primitive values are allowed.
test(saveDataWithMap);
}
{
const saveDataWithMap = {
run: {
foo: new Map(),
},
};
// @ts-expect-error Maps with function values are not serializable.
test(saveDataWithMap);
}
{
const saveDataWithMap = {
run: {
foo: new Map(),
},
};
// Nested maps are allowed.
test(saveDataWithMap);
}
{
class Foo {
someField = 123;
}
const saveDataWithClass = {
run: {
foo: new Foo(),
},
};
// Custom classes without methods are allowed.
test(saveDataWithClass);
}
{
class Foo {
someField = 123;
someMethod() { }
}
const saveDataWithClassWithMethod = {
run: {
foo: new Foo(),
},
};
// Custom classes with methods are allowed.
test(saveDataWithClassWithMethod);
}
{
class Foo {
someField = 123;
}
const saveDataWithNestedClass = {
run: {
fooMap: new Map(),
},
};
// Nested custom classes without methods are allowed.
test(saveDataWithNestedClass);
}