Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@hazae41/binary
Advanced tools
Readme
npm i @hazae41/binary
class MyObject implements Writable {
constructor(
readonly x: number,
readonly y: number
) {}
size() {
return 1 + 2
}
write(cursor: Cursor): Result<void, Error> {
return Result.unthrowSync(() => {
cursor.tryWriteUint8(this.x).throw()
cursor.tryWriteUint16(this.y).throw()
return Ok.void()
})
}
}
const myobject = new MyObject(1, 515)
const bytes = Writable.tryWriteToBytes(myobject).unwrap() // Uint8Array([1, 2, 3])
class MyObject {
constructor(
readonly x: number,
readonly y: number
) {}
static read(cursor: Cursor): Result<MyObject, Error> {
return Result.unthrowSync(() => {
const x = cursor.tryReadUint8().throw()
const y = cursor.tryReadUint16().throw()
return new Ok(new this(x, y))
})
}
}
const bytes = new Uint8Array([1, 2, 3])
const myobject = Readable.tryReadFromBytes(MyObject, bytes).unwrap() // MyObject(1, 515)
This is a binary data type that just holds bytes, it can be used when a binary data type is required
const bytes = new Uint8Array([1, 2, 3])
const opaque = Readable.tryReadFromBytes(SafeOpaque, bytes).unwrap() // Opaque(Uint8Array([1, 2, 3]))
const myobject = opaque.tryInto(MyObject).unwrap() // MyObject(1, 515)
const myobject = new MyObject(1, 515)
const opaque = Opaque.tryWriteFrom(myobject).unwrap() // Opaque(Uint8Array([1, 2, 3]))
const bytes = Writable.tryWriteToBytes(opaque).unwrap() // Uint8Array([1, 2, 3])
FAQs
Zero-copy binary data types
The npm package @hazae41/binary receives a total of 4 weekly downloads. As such, @hazae41/binary popularity was classified as not popular.
We found that @hazae41/binary demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.