Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
as-container
Advanced tools
assemblyscript version of Rust Option<T> and Result<T, E> and Box<T> etc.
as-container provides some utils such as Option
and Result
inspired by Rust for other people to use.
Box is used to wrap non-nullable(or primitive) value such as i32. Box offers all operator overloads to call the inner type operator.
Box usage scenarios are mainly used when a function or field needs to be null. This is very common in the case of generic functions and generic classes. The generics you write for reference types cannot be used for basic types, and Box is a reference type.
import { Box } from "as-container";
let box = Box.from(2);
let box2 = Box.from(1);
expect(box == box2).toStrictEqual(false);
expect(box != box2).toStrictEqual(true);
More examples can be found in unit tests
Option offers some operations inspired by Rust.
import { Option } from "as-container";
const x = Option.Some("some");
expect(x.map<string>((s) => s + s).unwrap()).toBe("somesome");
More examples can be found in unit tests
Result offers some operations inspired by Rust.
import { Result } from "as-container";
const x = Result.Ok<string, string>("233");
expect(x.map<string>((s) => s + s).unwrap()).toBe("233233");
More examples can be found in unit tests
as-container
offers two versions of Result/Option. They provide the same API, but different implementations.
The default version can handle any type including primitive type. But because the primitive types need one more byte to record state, it may take more overhead.
If you always use reference types as Option/Result parameters and need better performance, then you can use the type with the same name under as-container/reference
.
FAQs
assemblyscript version of Rust Option<T> and Result<T, E> and Box<T> etc.
The npm package as-container receives a total of 13 weekly downloads. As such, as-container popularity was classified as not popular.
We found that as-container 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.