![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
immutable-class
Advanced tools
Readme
A little library to facilitate creating and testing serializable, immutable classes.
This library is really just a set of templates and testing tools to allow for quick construction of immutable classes.
An object Blah
is considered a immutable class of it meats the following criteria:
Blah.isBlah
method for checking if something is an instance of the given classBlah.fromJS
method for deserializing classesblah.valueOf
method that return a minimally serialized object (preserving all sub classes as immutable classes)blah.toJS
method that return a fully serialized object (recursively serializing all sub classes)blah.toJSON
method that returns the same as the toJS method allowing the object to be passed into JSON.stringify
blah.toString
method that is implemented in some way (and returns a string
)blah.equals
method that can be used to compare this object to other classes to check for equivalence.Immutable Class provides one testing function for testing potential immutable classes: testImmutableClass
It is used like so:
testImmutableClass(MyImmutableClassConstructor, [
{ "potential": 1 }
{ "distinct": 2 }
{ "js": 3 }
{ "immutable classes": 4 }
]);
This function will then try to call fromJS
on each candidate and run it through a series of tests to ensure that it
corresponds to the rules above. It will also do an equality check of every object with every other object and make sure
that it only equals itself.
For an example of the usage of this library look at these files: source, tests.
FAQs
A template for creating immutable classes
We found that immutable-class demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers 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
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.