Skip to content
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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

feat: added string-store #118

wants to merge 5 commits into from

Conversation

kyranet
Copy link
Member

@kyranet kyranet commented May 24, 2021

TODO

  • Dynamically increase size on size-unknown payloads.
  • Add tests, lots of tests
    • Does this thing even work? Endianness is a pain.

.github/CODEOWNERS Outdated Show resolved Hide resolved
packages/string-store/package.json Outdated Show resolved Hide resolved
Comment on lines 4 to 6
public readBit(): Bit {
return this.read(1n) as Bit;
}
Copy link
Contributor

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.

Comment on lines 14 to 19
public writeBit(bit: Bit): void {
this.memoryData <<= 1n;
this.memoryData |= bit & 0b0001n;
this.memoryBits += 1n;
this.ensureCurrentByte();
}
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump, kyra

.github/workflows/cd-string-store.yml Outdated Show resolved Hide resolved
packages/string-store/CHANGELOG.md Outdated Show resolved Hide resolved
packages/string-store/README.md Outdated Show resolved Hide resolved
packages/string-store/package.json Outdated Show resolved Hide resolved
@favna favna force-pushed the main branch 2 times, most recently from 1b1ed93 to a3e5cf0 Compare August 11, 2021 23:30
@Lioness100
Copy link
Collaborator

Lioness100 commented Oct 19, 2021

Fancy jargon too fancy for me D:
What exactly is the use case of this?

Edit: answered in discord

@favna favna force-pushed the feat/added-string-store branch 2 times, most recently from db89866 to 1680a5b Compare January 20, 2022 21:26

![Sapphire Logo](https://cdn.skyra.pw/gh-assets/sapphire-banner.png)

# @sapphire/stopwatch
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"version": "0.0.1",
"version": "1.0.0",

Comment on lines +25 to +27
"dependencies": {
"tslib": "^2.4.0"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump, kyra

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

None yet

6 participants