New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: added string-store #118
base: main
Are you sure you want to change the base?
Conversation
public readBit(): Bit { | ||
return this.read(1n) as Bit; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a helper generator instead of re-implementing the same function innumerable times.
This could be done as follows, for instance:
function readBitX<T>(this: UnalignedBuffer, x: Size) {
return () => {
return this.read(x) as T;
}
}
And then applying the generated functions to the class. This is as close to a macro as TypeScript will allow, but more readable and convenient.
public writeBit(bit: Bit): void { | ||
this.memoryData <<= 1n; | ||
this.memoryData |= bit & 0b0001n; | ||
this.memoryBits += 1n; | ||
this.ensureCurrentByte(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as with readBit
.
@@ -0,0 +1,40 @@ | |||
import type { IType } from './IType'; | |||
|
|||
export function Array<SType, DType>(type: IType<SType, DType>, length: number | null = null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export function Array<SType, DType>(type: IType<SType, DType>, length: number | null = null) { | |
export function Array<SType, DType>(type: IType<SType, DType>, length: number | null = null) { |
It is largely unclear what SType and DType relate to here. Given that Type
is implied by their usage, ignoring them, it's roughly as vague as S
and D
, which appear to have no real standardized use. Consider swapping those out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump, kyra
1b1ed93
to
a3e5cf0
Compare
Edit: answered in discord |
db89866
to
1680a5b
Compare
4faef40
to
10daf42
Compare
|
||
![Sapphire Logo](https://cdn.skyra.pw/gh-assets/sapphire-banner.png) | ||
|
||
# @sapphire/stopwatch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll stop your watch
|
||
[![GitHub](https://img.shields.io/github/license/sapphiredev/utilities)](https://github.com/sapphiredev/utilities/blob/main/LICENSE.md) | ||
[![codecov](https://codecov.io/gh/sapphiredev/utilities/branch/main/graph/badge.svg?token=OEGIV6RFDO)](https://codecov.io/gh/sapphiredev/utilities) | ||
[![npm bundle size](https://img.shields.io/bundlephobia/min/@sapphire/stopwatch?logo=webpack&style=flat-square)](https://bundlephobia.com/result?p=@sapphire/stopwatch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll stop your clock
[![GitHub](https://img.shields.io/github/license/sapphiredev/utilities)](https://github.com/sapphiredev/utilities/blob/main/LICENSE.md) | ||
[![codecov](https://codecov.io/gh/sapphiredev/utilities/branch/main/graph/badge.svg?token=OEGIV6RFDO)](https://codecov.io/gh/sapphiredev/utilities) | ||
[![npm bundle size](https://img.shields.io/bundlephobia/min/@sapphire/stopwatch?logo=webpack&style=flat-square)](https://bundlephobia.com/result?p=@sapphire/stopwatch) | ||
[![npm](https://img.shields.io/npm/v/@sapphire/stopwatch?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/@sapphire/stopwatch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll stop your chronometer
You can use the following command to install this package, or replace `npm install` with your package manager of choice. | ||
|
||
```sh | ||
npm install @sapphire/stopwatch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll stop your ticker
@@ -0,0 +1,64 @@ | |||
{ | |||
"name": "@sapphire/string-store", | |||
"version": "0.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"version": "0.0.1", | |
"version": "1.0.0", |
"dependencies": { | ||
"tslib": "^2.4.0" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"dependencies": { | |
"tslib": "^2.4.0" | |
}, |
Should not be needed when compiling with tsup but I suppose check the dist output
export * from './lib/data/writer/AlignedWriter'; | ||
export * from './lib/data/writer/IWriter'; | ||
export * from './lib/StringStore'; | ||
export * as Types from './lib/Types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export * as Types from './lib/Types'; | |
export * from './lib/Types'; |
Any particular reason why you made it namespaced under Types
?
} | ||
|
||
public finish(): void { | ||
// NOP: Aligned writer does not use a double buffer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// NOP: Aligned writer does not use a double buffer. | |
// NO-OP: Aligned writer does not use a double buffer. |
Not I know but it's "no operation" so it needs 2 O's. No one uses "NOP".
@@ -0,0 +1,40 @@ | |||
import type { IType } from './IType'; | |||
|
|||
export function Array<SType, DType>(type: IType<SType, DType>, length: number | null = null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bump, kyra
TODO