
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
@bearclaw/immutable-class
Advanced tools
This library provides helper functions to extend `class-transformer` functionality to create immutable classes. It also provides helper functions to work with immutable classes using `immer`.
This library provides helper functions to extend class-transformer
functionality to create immutable classes. It also provides helper functions to work with immutable classes using immer
.
Converts a class (constructor) object to a new immutable class (constructor) object. Also works with arrays.
class MyClass {
foo!: string
}
const existing = new MyClass();
existing.foo = 'bar'; // No errors
const instance = instanceToImmutableInstance(existing);
instance.foo = 'foo'; // throws a read only property error
Converts a class (constructor) object to an immutable plain (literal) object. Also works with arrays.
class MyClass {
foo!: string
}
const instance = new MyClass();
instance.foo = 'bar'; // No errors
const plain = instanceToImmutablePlain(instance);
plain.foo = 'foo'; // throws a read only property error
Produce the next immutable class (constructor) object by patching the existing class (constructor) object. Also works with arrays.
class MyClass {
foo!: string
}
const instance = new MyClass();
instance.foo = 'bar'; // No errors
const updated = patchImmutableInstance(instance, { foo: 'some value' });
instance.foo = 'foo'; // throws a read only property error
Converts a plain (literal) object to an immutable class (constructor) object. Also works with arrays.
class MyClass {
foo!: string
}
const plain = { foo: 'example' };
plain.foo = 'bar'; // No errors
const instance = plainToImmutableInstance(MyClass, plain);
instance.foo = 'foo'; // throws a read only property error
Produce the next immutable class (constructor) object by modifying the current class (constructor) object with a recipe function. Also works with arrays.
class MyClass {
foo!: string
}
const instance = new MyClass();
instance.foo = 'bar'; // No errors
const updated = produceImmutableInstance(instance, draft => {
draft.foo = 'some value'
});
instance.foo = 'foo'; // throws a read only property error
Run nx test immutable-class
to execute the unit tests via
Jest.- immutable-class
FAQs
This library provides helper functions to extend `class-transformer` functionality to create immutable classes. It also provides helper functions to work with immutable classes using `immer`.
The npm package @bearclaw/immutable-class receives a total of 0 weekly downloads. As such, @bearclaw/immutable-class popularity was classified as not popular.
We found that @bearclaw/immutable-class demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.