Skip to content

Commit

Permalink
Use prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik99999 committed Feb 20, 2024
1 parent eeb44f3 commit 7683388
Show file tree
Hide file tree
Showing 18 changed files with 6,873 additions and 7,046 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}

steps:
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.x
- name: Install Dependencies
run: bun install
- name: Build
env:
BASE_PATH: '/${{ github.event.repository.name }}'
run: bun run build
- name: Upload Artifacts
uses: actions/upload-pages-artifact@v2
with:
path: 'build'
- uses: actions/configure-pages@v3
- name: Deploy
id: deployment
uses: actions/deploy-pages@v2
- uses: actions/checkout@v3
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.x
- name: Install Dependencies
run: bun install
- name: Build
env:
BASE_PATH: '/${{ github.event.repository.name }}'
run: bun run build
- name: Upload Artifacts
uses: actions/upload-pages-artifact@v2
with:
path: 'build'
- uses: actions/configure-pages@v3
- name: Deploy
id: deployment
uses: actions/deploy-pages@v2
20 changes: 20 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"trailingComma": "es5",
"useTabs": true,
"semi": true,
"singleQuote": true,
"printWidth": 120,
"plugins": ["prettier-plugin-svelte"],
"overrides": [
{
"files": ["*.html", "*.svelte"],
"options": {
"printWidth": 600
}
},
{
"files": "*.svelte",
"options": { "parser": "svelte" }
}
]
}
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.2.1",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
Expand Down
4 changes: 2 additions & 2 deletions src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
Expand Down
148 changes: 74 additions & 74 deletions src/lib/bitstream.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
/**
* based off
* https://github.com/mid-kid/pmdrtdx_passwords/blob/master/password.py#L44
*/
export class BitstreamReader {
bytes: bigint[];
bytesize: bigint;
pos: number;
bits: bigint;
value: bigint;
constructor(bytes: number[], bytesize: number) {
this.bytes = [];
for (const byte of bytes) {
this.bytes.push(BigInt(byte));
}
this.bytesize = BigInt(bytesize);
this.pos = 0;
this.bits = 0n;
this.value = 0n;
}

remaining(): boolean {
if (this.pos < this.bytes.length) return true;
if (this.bits > 0n) return true;
return false;
}

read(count: number | bigint): number {
if (typeof count === 'number') count = BigInt(count);
while (this.bits < count) {
if (this.pos >= this.bytes.length) break;
this.value |= (this.bytes[this.pos] & ((1n << this.bytesize) - 1n)) << this.bits;
this.bits += this.bytesize;
this.pos++;
}
const ret = this.value & ((1n << count) - 1n);
this.value >>= count;
this.bits -= count;
return Number(ret);
}
}

/**
* based off
* https://github.com/mid-kid/pmdrtdx_passwords/blob/master/password.py#L72
*/
export class BitstreamWriter {
bytes: number[];
bytesize: bigint;
bits: bigint;
value: bigint;
constructor(bytesize: number) {
this.bytes = [];
this.bytesize = BigInt(bytesize);
this.bits = 0n;
this.value = 0n;
}

finish(): number[] {
if (this.bits > 0) this.bytes.push(Number(this.value & ((1n << this.bytesize) - 1n)));
return this.bytes;
}

write(value: number | bigint, bits: number | bigint): void {
if (typeof value === 'number') value = BigInt(value);
if (typeof bits === 'number') bits = BigInt(bits);
this.value |= (value & ((1n << bits) - 1n)) << this.bits;
this.bits += bits;
while (this.bits >= this.bytesize) {
this.bytes.push(Number(this.value & ((1n << this.bytesize) - 1n)));
this.value >>= this.bytesize;
this.bits -= this.bytesize;
}
}
/**
* based off
* https://github.com/mid-kid/pmdrtdx_passwords/blob/master/password.py#L44
*/
export class BitstreamReader {
bytes: bigint[];
bytesize: bigint;
pos: number;
bits: bigint;
value: bigint;
constructor(bytes: number[], bytesize: number) {
this.bytes = [];
for (const byte of bytes) {
this.bytes.push(BigInt(byte));
}
this.bytesize = BigInt(bytesize);
this.pos = 0;
this.bits = 0n;
this.value = 0n;
}

remaining(): boolean {
if (this.pos < this.bytes.length) return true;
if (this.bits > 0n) return true;
return false;
}

read(count: number | bigint): number {
if (typeof count === 'number') count = BigInt(count);
while (this.bits < count) {
if (this.pos >= this.bytes.length) break;
this.value |= (this.bytes[this.pos] & ((1n << this.bytesize) - 1n)) << this.bits;
this.bits += this.bytesize;
this.pos++;
}
const ret = this.value & ((1n << count) - 1n);
this.value >>= count;
this.bits -= count;
return Number(ret);
}
}

/**
* based off
* https://github.com/mid-kid/pmdrtdx_passwords/blob/master/password.py#L72
*/
export class BitstreamWriter {
bytes: number[];
bytesize: bigint;
bits: bigint;
value: bigint;
constructor(bytesize: number) {
this.bytes = [];
this.bytesize = BigInt(bytesize);
this.bits = 0n;
this.value = 0n;
}

finish(): number[] {
if (this.bits > 0) this.bytes.push(Number(this.value & ((1n << this.bytesize) - 1n)));
return this.bytes;
}

write(value: number | bigint, bits: number | bigint): void {
if (typeof value === 'number') value = BigInt(value);
if (typeof bits === 'number') bits = BigInt(bits);
this.value |= (value & ((1n << bits) - 1n)) << this.bits;
this.bits += bits;
while (this.bits >= this.bytesize) {
this.bytes.push(Number(this.value & ((1n << this.bytesize) - 1n)));
this.value >>= this.bytesize;
this.bits -= this.bytesize;
}
}
}
Loading

0 comments on commit 7683388

Please sign in to comment.