![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
as-string-sink
Advanced tools
An efficient dynamically sized string buffer (aka String Builder) for AssemblyScript
An efficient dynamically sized string buffer (aka String Builder) for AssemblyScript.
class StringSink {
constructor(initial: string = "");
get length(): i32;
get capacity(): i32;
write(src: string, start?: i32, end?: i32): void;
writeLn(src: string, start?: i32, end?: i32): void;
writeCodePoint(code: i32): void;
shrink(): void;
clear(): void;
toString(): string;
}
StringSink can be up to 8700 times faster than naive string concatenation!
100 strings:
------------
String += JS: 0.016 ms
String += AS: 0.018 ms
StringSink AS: 0.0033 ms
50,000 strings:
---------------
String += JS: 2.86 ms
String += AS: 1133.24 ms
StringSink AS: 0.57 ms
200,000 strings:
----------------
String += JS: 11.44 ms
String += AS: 17867.35 ms
StringSink AS: 2.06 ms
non efficient example:
function toList(arr: string[]): string {
let res = "";
for (let i = 0, len = arr.length; i < len; i++) {
res += arr[i] + "\n";
}
return res;
}
efficient with StringSink
:
function toList(arr: string[]): string {
let res = new StringSink();
for (let i = 0, len = arr.length; i < len; i++) {
res.write(arr[i] + "\n");
}
return res.toString();
}
even more efficient:
function toList(arr: string[]): string {
let res = new StringSink();
for (let i = 0, len = arr.length; i < len; i++) {
res.writeLn(arr[i]);
}
return res.toString();
}
non efficient example:
function toListSliced(arr: string[]): string {
let res = "";
for (let i = 0, len = arr.length; i < len; i++) {
res += arr[i].substring(1, 3);
}
return res;
}
more efficient with StringSink
:
function toListSliced(arr: string[]): string {
let res = new StringSink();
for (let i = 0, len = arr.length; i < len; i++) {
res.write(arr[i], 1, 3);
}
return res.toString();
}
FAQs
An efficient dynamically sized string buffer (aka String Builder) for AssemblyScript
The npm package as-string-sink receives a total of 6 weekly downloads. As such, as-string-sink popularity was classified as not popular.
We found that as-string-sink 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.