Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
206
Frontend-Learner/node_modules/@sindresorhus/base62/base.d.ts
generated
vendored
Normal file
206
Frontend-Learner/node_modules/@sindresorhus/base62/base.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
export type Options = {
|
||||
/**
|
||||
Custom alphabet containing exactly 62 unique characters.
|
||||
|
||||
@default '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
||||
*/
|
||||
readonly alphabet?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
A Base62 encoder/decoder that supports custom alphabets.
|
||||
|
||||
@example
|
||||
```
|
||||
import {Base62} from '@sindresorhus/base62';
|
||||
|
||||
// Use default alphabet
|
||||
const base62 = new Base62();
|
||||
console.log(base62.encodeInteger(1337));
|
||||
//=> 'LZ'
|
||||
|
||||
// Use custom alphabet
|
||||
const customBase62 = new Base62({
|
||||
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
||||
});
|
||||
console.log(customBase62.encodeInteger(1337));
|
||||
//=> 'Vj'
|
||||
```
|
||||
*/
|
||||
export class Base62 {
|
||||
/**
|
||||
Create a new Base62 encoder/decoder.
|
||||
|
||||
@param options - Options for the encoder/decoder.
|
||||
*/
|
||||
constructor(options?: Options);
|
||||
|
||||
/**
|
||||
Encodes a string to a Base62 string.
|
||||
|
||||
@param string - The string to encode.
|
||||
@returns The Base62 encoded string.
|
||||
*/
|
||||
encodeString(string: string): string;
|
||||
|
||||
/**
|
||||
Decodes a Base62 encoded string created with `encodeString()` back to the original string.
|
||||
|
||||
@param encodedString - The Base62 encoded string to decode.
|
||||
@returns The decoded string.
|
||||
*/
|
||||
decodeString(encodedString: string): string;
|
||||
|
||||
/**
|
||||
Encodes bytes to a Base62 string.
|
||||
|
||||
@param bytes - The bytes to encode.
|
||||
@returns The Base62 encoded string.
|
||||
*/
|
||||
encodeBytes(bytes: Uint8Array): string;
|
||||
|
||||
/**
|
||||
Decodes a Base62 string created with `encodeBytes()` back to bytes.
|
||||
|
||||
@param encodedString - The Base62 encoded string to decode.
|
||||
@returns The decoded bytes as Uint8Array.
|
||||
*/
|
||||
decodeBytes(encodedString: string): Uint8Array;
|
||||
|
||||
/**
|
||||
Encodes a non-negative integer to a Base62 string.
|
||||
|
||||
@param integer - The integer to encode.
|
||||
@returns The Base62 encoded string.
|
||||
*/
|
||||
encodeInteger(integer: number): string;
|
||||
|
||||
/**
|
||||
Decodes a Base62 encoded string to an integer.
|
||||
|
||||
@param encodedString - The Base62 string to decode.
|
||||
@returns The decoded integer.
|
||||
*/
|
||||
decodeInteger(encodedString: string): number;
|
||||
|
||||
/**
|
||||
Encodes a non-negative bigint to a Base62 string.
|
||||
|
||||
@param bigint - The bigint to encode.
|
||||
@returns The Base62 encoded string.
|
||||
*/
|
||||
encodeBigInt(bigint: bigint): string;
|
||||
|
||||
/**
|
||||
Decodes a Base62 encoded string to a bigint.
|
||||
|
||||
@param encodedString - The Base62 string to decode.
|
||||
@returns The decoded bigint.
|
||||
*/
|
||||
decodeBigInt(encodedString: string): bigint;
|
||||
}
|
||||
|
||||
/**
|
||||
Encodes a string to a Base62 string.
|
||||
|
||||
@param string - The string to encode.
|
||||
@returns The Base62 encoded string.
|
||||
|
||||
@example
|
||||
```
|
||||
import base62 from '@sindresorhus/base62';
|
||||
|
||||
const encodedString = base62.encodeString('Hello world!');
|
||||
console.log(encodedString);
|
||||
//=> '28B5ymDkgSU62aA0v'
|
||||
|
||||
console.log(base62.decodeString(encodedString));
|
||||
//=> 'Hello world!'
|
||||
|
||||
console.log(base62.encodeString('🦄'));
|
||||
//=> '95s3vg'
|
||||
|
||||
console.log(base62.encodeInteger(1337));
|
||||
//=> 'LZ'
|
||||
```
|
||||
*/
|
||||
export function encodeString(string: string): string;
|
||||
|
||||
/**
|
||||
Decodes a Base62 encoded string created with `encodeString()` back to the original string.
|
||||
|
||||
@param encodedString - The Base62 encoded string to decode.
|
||||
@returns The decoded string.
|
||||
|
||||
@example
|
||||
```
|
||||
import base62 from '@sindresorhus/base62';
|
||||
|
||||
const encodedString = base62.encodeString('Hello world!');
|
||||
console.log(encodedString);
|
||||
//=> '28B5ymDkgSU62aA0v'
|
||||
|
||||
console.log(base62.decodeString(encodedString));
|
||||
//=> 'Hello world!'
|
||||
|
||||
console.log(base62.encodeString('🦄'));
|
||||
//=> '95s3vg'
|
||||
```
|
||||
*/
|
||||
export function decodeString(encodedString: string): string;
|
||||
|
||||
/**
|
||||
Encodes bytes to a Base62 string.
|
||||
|
||||
@param bytes - The bytes to encode.
|
||||
@returns The Base62 encoded string.
|
||||
*/
|
||||
export function encodeBytes(bytes: Uint8Array): string;
|
||||
|
||||
/**
|
||||
Decodes a Base62 string created with `encodeBytes()` back to bytes.
|
||||
|
||||
@param encodedString - The Base62 encoded string to decode.
|
||||
@returns The decoded bytes as Uint8Array.
|
||||
*/
|
||||
export function decodeBytes(encodedString: string): Uint8Array;
|
||||
|
||||
/**
|
||||
Encodes a non-negative integer to a Base62 string.
|
||||
|
||||
@param integer - The integer to encode.
|
||||
@returns The Base62 encoded string.
|
||||
|
||||
@example
|
||||
```
|
||||
import base62 from '@sindresorhus/base62';
|
||||
|
||||
console.log(base62.encodeInteger(1337));
|
||||
//=> 'LZ'
|
||||
```
|
||||
*/
|
||||
export function encodeInteger(integer: number): string;
|
||||
|
||||
/**
|
||||
Decodes a Base62 encoded string to an integer.
|
||||
|
||||
@param encodedString - The Base62 string to decode.
|
||||
@returns The decoded integer.
|
||||
*/
|
||||
export function decodeInteger(encodedString: string): number;
|
||||
|
||||
/**
|
||||
Encodes a non-negative bigint to a Base62 string.
|
||||
|
||||
@param bigint - The bigint to encode.
|
||||
@returns The Base62 encoded string.
|
||||
*/
|
||||
export function encodeBigInt(bigint: bigint): string;
|
||||
|
||||
/**
|
||||
Decodes a Base62 encoded string to a bigint.
|
||||
|
||||
@param encodedString - The Base62 string to decode.
|
||||
@returns The decoded bigint.
|
||||
*/
|
||||
export function decodeBigInt(encodedString: string): bigint;
|
||||
177
Frontend-Learner/node_modules/@sindresorhus/base62/base.js
generated
vendored
Normal file
177
Frontend-Learner/node_modules/@sindresorhus/base62/base.js
generated
vendored
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
/* eslint-disable no-bitwise */
|
||||
|
||||
const BASE = 62;
|
||||
const BASE_BIGINT = 62n;
|
||||
const DEFAULT_ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||
|
||||
const cachedEncoder = new globalThis.TextEncoder();
|
||||
const cachedDecoder = new globalThis.TextDecoder();
|
||||
|
||||
function assertString(value, label) {
|
||||
if (typeof value !== 'string') {
|
||||
throw new TypeError(`The \`${label}\` parameter must be a string, got \`${value}\` (${typeof value}).`);
|
||||
}
|
||||
}
|
||||
|
||||
function validateAlphabet(alphabet) {
|
||||
if (typeof alphabet !== 'string') {
|
||||
throw new TypeError(`The alphabet must be a string, got \`${alphabet}\` (${typeof alphabet}).`);
|
||||
}
|
||||
|
||||
if (alphabet.length !== BASE) {
|
||||
throw new TypeError(`The alphabet must be exactly ${BASE} characters long, got ${alphabet.length}.`);
|
||||
}
|
||||
|
||||
const uniqueCharacters = new Set(alphabet);
|
||||
if (uniqueCharacters.size !== BASE) {
|
||||
throw new TypeError(`The alphabet must contain ${BASE} unique characters, got ${uniqueCharacters.size}.`);
|
||||
}
|
||||
}
|
||||
|
||||
export class Base62 {
|
||||
constructor(options = {}) {
|
||||
const alphabet = options.alphabet ?? DEFAULT_ALPHABET;
|
||||
validateAlphabet(alphabet);
|
||||
this.alphabet = [...alphabet];
|
||||
this.indices = new Map(this.alphabet.map((character, index) => [character, index]));
|
||||
}
|
||||
|
||||
#getIndex(character) {
|
||||
const index = this.indices.get(character);
|
||||
|
||||
if (index === undefined) {
|
||||
throw new TypeError(`Unexpected character for Base62 encoding: \`${character}\`.`);
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
encodeString(string) {
|
||||
assertString(string, 'string');
|
||||
return this.encodeBytes(cachedEncoder.encode(string));
|
||||
}
|
||||
|
||||
decodeString(encodedString) {
|
||||
assertString(encodedString, 'encodedString');
|
||||
return cachedDecoder.decode(this.decodeBytes(encodedString));
|
||||
}
|
||||
|
||||
encodeBytes(bytes) {
|
||||
if (!(bytes instanceof Uint8Array)) {
|
||||
throw new TypeError('The `bytes` parameter must be an instance of Uint8Array.');
|
||||
}
|
||||
|
||||
if (bytes.length === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Prepend 0x01 to the byte array before encoding to ensure the BigInt conversion
|
||||
// does not strip any leading zeros and to prevent any byte sequence from being
|
||||
// interpreted as a numerically zero value.
|
||||
let value = 1n;
|
||||
|
||||
for (const byte of bytes) {
|
||||
value = (value << 8n) | BigInt(byte);
|
||||
}
|
||||
|
||||
return this.encodeBigInt(value);
|
||||
}
|
||||
|
||||
decodeBytes(encodedString) {
|
||||
assertString(encodedString, 'encodedString');
|
||||
|
||||
if (encodedString.length === 0) {
|
||||
return new Uint8Array();
|
||||
}
|
||||
|
||||
let value = this.decodeBigInt(encodedString);
|
||||
|
||||
const byteArray = [];
|
||||
while (value > 0n) {
|
||||
byteArray.push(Number(value & 0xFFn));
|
||||
value >>= 8n;
|
||||
}
|
||||
|
||||
// Remove the 0x01 that was prepended during encoding.
|
||||
return Uint8Array.from(byteArray.reverse().slice(1));
|
||||
}
|
||||
|
||||
encodeInteger(integer) {
|
||||
if (!Number.isInteger(integer)) {
|
||||
throw new TypeError(`Expected an integer, got \`${integer}\` (${typeof integer}).`);
|
||||
}
|
||||
|
||||
if (integer < 0) {
|
||||
throw new TypeError('The integer must be non-negative.');
|
||||
}
|
||||
|
||||
if (integer === 0) {
|
||||
return this.alphabet[0];
|
||||
}
|
||||
|
||||
let encodedString = '';
|
||||
while (integer > 0) {
|
||||
encodedString = this.alphabet[integer % BASE] + encodedString;
|
||||
integer = Math.floor(integer / BASE);
|
||||
}
|
||||
|
||||
return encodedString;
|
||||
}
|
||||
|
||||
decodeInteger(encodedString) {
|
||||
assertString(encodedString, 'encodedString');
|
||||
|
||||
let integer = 0;
|
||||
for (const character of encodedString) {
|
||||
integer = (integer * BASE) + this.#getIndex(character);
|
||||
}
|
||||
|
||||
return integer;
|
||||
}
|
||||
|
||||
encodeBigInt(bigint) {
|
||||
if (typeof bigint !== 'bigint') {
|
||||
throw new TypeError(`Expected a bigint, got \`${bigint}\` (${typeof bigint}).`);
|
||||
}
|
||||
|
||||
if (bigint < 0) {
|
||||
throw new TypeError('The bigint must be non-negative.');
|
||||
}
|
||||
|
||||
if (bigint === 0n) {
|
||||
return this.alphabet[0];
|
||||
}
|
||||
|
||||
let encodedString = '';
|
||||
while (bigint > 0n) {
|
||||
encodedString = this.alphabet[Number(bigint % BASE_BIGINT)] + encodedString;
|
||||
bigint /= BASE_BIGINT;
|
||||
}
|
||||
|
||||
return encodedString;
|
||||
}
|
||||
|
||||
decodeBigInt(encodedString) {
|
||||
assertString(encodedString, 'encodedString');
|
||||
|
||||
let bigint = 0n;
|
||||
for (const character of encodedString) {
|
||||
bigint = (bigint * BASE_BIGINT) + BigInt(this.#getIndex(character));
|
||||
}
|
||||
|
||||
return bigint;
|
||||
}
|
||||
}
|
||||
|
||||
// Create default instance with standard alphabet
|
||||
const defaultBase62 = new Base62();
|
||||
|
||||
// Export convenience functions using the default alphabet for backward compatibility
|
||||
export const encodeString = string => defaultBase62.encodeString(string);
|
||||
export const decodeString = encodedString => defaultBase62.decodeString(encodedString);
|
||||
export const encodeBytes = bytes => defaultBase62.encodeBytes(bytes);
|
||||
export const decodeBytes = encodedString => defaultBase62.decodeBytes(encodedString);
|
||||
export const encodeInteger = integer => defaultBase62.encodeInteger(integer);
|
||||
export const decodeInteger = encodedString => defaultBase62.decodeInteger(encodedString);
|
||||
export const encodeBigInt = bigint => defaultBase62.encodeBigInt(bigint);
|
||||
export const decodeBigInt = encodedString => defaultBase62.decodeBigInt(encodedString);
|
||||
2
Frontend-Learner/node_modules/@sindresorhus/base62/index.d.ts
generated
vendored
Normal file
2
Frontend-Learner/node_modules/@sindresorhus/base62/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * as default from './base.js';
|
||||
export {Base62, type Options} from './base.js';
|
||||
2
Frontend-Learner/node_modules/@sindresorhus/base62/index.js
generated
vendored
Normal file
2
Frontend-Learner/node_modules/@sindresorhus/base62/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * as default from './base.js';
|
||||
export {Base62} from './base.js';
|
||||
9
Frontend-Learner/node_modules/@sindresorhus/base62/license
generated
vendored
Normal file
9
Frontend-Learner/node_modules/@sindresorhus/base62/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
65
Frontend-Learner/node_modules/@sindresorhus/base62/package.json
generated
vendored
Normal file
65
Frontend-Learner/node_modules/@sindresorhus/base62/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
"name": "@sindresorhus/base62",
|
||||
"version": "1.0.0",
|
||||
"description": "Encode & decode strings, bytes, and integers to Base62",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/base62",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"base.js",
|
||||
"base.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"base62",
|
||||
"base",
|
||||
"base64",
|
||||
"base-62",
|
||||
"encode",
|
||||
"decode",
|
||||
"shorten",
|
||||
"compress",
|
||||
"compact",
|
||||
"alphanumeric",
|
||||
"serialization",
|
||||
"url",
|
||||
"safe",
|
||||
"text",
|
||||
"string",
|
||||
"number",
|
||||
"integer",
|
||||
"bigint",
|
||||
"bytes",
|
||||
"uint8array",
|
||||
"algorithm",
|
||||
"transformation",
|
||||
"encoder",
|
||||
"decoder",
|
||||
"encoding",
|
||||
"decoding",
|
||||
"url-friendly",
|
||||
"url-safe"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^6.1.2",
|
||||
"xo": "^0.58.0"
|
||||
}
|
||||
}
|
||||
120
Frontend-Learner/node_modules/@sindresorhus/base62/readme.md
generated
vendored
Normal file
120
Frontend-Learner/node_modules/@sindresorhus/base62/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
# base62
|
||||
|
||||
> Encode & decode strings, bytes, and integers to [Base62](https://en.wikipedia.org/wiki/Base62)
|
||||
|
||||
Base62 is ideal for URL shortening, creating readable codes, and compact data representation, because it compresses large values into shorter, alphanumeric strings, maximizing space efficiency and readability.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install @sindresorhus/base62
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import base62 from '@sindresorhus/base62';
|
||||
|
||||
const encodedString = base62.encodeString('Hello world!');
|
||||
console.log(encodedString);
|
||||
//=> '28B5ymDkgSU62aA0v'
|
||||
|
||||
console.log(base62.decodeString(encodedString));
|
||||
//=> 'Hello world!'
|
||||
|
||||
console.log(base62.encodeString('🦄'));
|
||||
//=> '95s3vg'
|
||||
|
||||
console.log(base62.encodeInteger(1337));
|
||||
//=> 'LZ'
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> The output may differ from other Base62 encoders due to variations in alphabet order and byte encoding.
|
||||
|
||||
## API
|
||||
|
||||
It uses the most common alphabet for Base62: `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
|
||||
|
||||
### `encodeString(string: string): string`
|
||||
|
||||
Encodes a string to a Base62 string.
|
||||
|
||||
> [!CAUTION]
|
||||
> The result format is not yet guaranteed to be stable across package versions. Avoid using it for persistent storage.
|
||||
|
||||
### `decodeString(encodedString: string): string`
|
||||
|
||||
Decodes a Base62 encoded string created with `encodeString()` back to the original string.
|
||||
|
||||
### `encodeBytes(bytes: Uint8Array): string`
|
||||
|
||||
Encodes bytes to a Base62 string.
|
||||
|
||||
> [!CAUTION]
|
||||
> The result format is not yet guaranteed to be stable across package versions. Avoid using it for persistent storage.
|
||||
|
||||
### `decodeBytes(encodedString: string): Uint8Array`
|
||||
|
||||
Decodes a Base62 string created with `encodeBytes()` back to bytes.
|
||||
|
||||
### `encodeInteger(integer: number): string`
|
||||
|
||||
Encodes a non-negative integer to a Base62 string.
|
||||
|
||||
### `decodeInteger(encodedString: string): number`
|
||||
|
||||
Decodes a Base62 string to an integer.
|
||||
|
||||
### `encodeBigInt(integer: bigint): string`
|
||||
|
||||
Encodes a non-negative bigint to a Base62 string.
|
||||
|
||||
### `decodeBigInt(encodedString: string): bigint`
|
||||
|
||||
Decodes a Base62 string to a bigint.
|
||||
|
||||
### Custom alphabets
|
||||
|
||||
You can use a custom alphabet by using the `Base62` class:
|
||||
|
||||
```js
|
||||
import {Base62} from '@sindresorhus/base62';
|
||||
|
||||
// Create instance with custom alphabet
|
||||
const customBase62 = new Base62({
|
||||
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
|
||||
});
|
||||
|
||||
console.log(customBase62.encodeInteger(1337));
|
||||
//=> 'Vj' (different from default 'LZ')
|
||||
|
||||
// Or use special characters
|
||||
const symbolBase62 = new Base62({
|
||||
alphabet: '!@#$%^&*()_+-=[]{}|;:,.<>?/~`0123456789ABCDEFGHIJKLMNOPQRSTUVW'
|
||||
});
|
||||
console.log(symbolBase62.encodeInteger(42));
|
||||
//=> 'D'
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> The alphabet must be exactly 62 unique characters.
|
||||
|
||||
### `Base62`
|
||||
|
||||
#### `constructor(options?)`
|
||||
|
||||
Create a new Base62 encoder/decoder instance.
|
||||
|
||||
##### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
###### alphabet
|
||||
|
||||
Type: `string`\
|
||||
Default: `'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'`
|
||||
|
||||
Custom alphabet containing exactly 62 unique characters.
|
||||
|
||||
The `Base62` class has the same methods as the exported functions: `encodeString()`, `decodeString()`, `encodeBytes()`, `decodeBytes()`, `encodeInteger()`, `decodeInteger()`, `encodeBigInt()`, and `decodeBigInt()`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue