Skip to content

Commit 1869a2a

Browse files
committed
rm type.d.ts
1 parent 0e5eb1e commit 1869a2a

5 files changed

Lines changed: 28 additions & 45 deletions

File tree

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
"./make": {
1313
"types": "./dist/make.d.ts",
1414
"default": "./dist/make.js"
15-
},
16-
"./type": {
17-
"types": "./type.d.ts"
1815
}
1916
},
2017
"scripts": {
@@ -23,8 +20,7 @@
2320
"prepublishOnly": "node --run test"
2421
},
2522
"files": [
26-
"dist",
27-
"type.d.ts"
23+
"dist"
2824
],
2925
"repository": {
3026
"type": "git",

src/main.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import type {
2-
Type_bytesToBase64,
3-
Type_base64ToBytes,
4-
Type_encode,
5-
Type_decode,
6-
Type_decodeToString,
7-
} from '../type.d.ts'
8-
91
import {
2+
type bytesToBase64Func,
3+
type base64ToBytesFunc,
104
make_bytesToBase64,
115
make_base64ToBytes,
126
make_base64ToBytes_NodeJS,
@@ -23,7 +17,7 @@ export const alphabeturl = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
2317
* A boolean specifying whether to omit padding characters (=) at the end of the base64 string.
2418
* The default is false.
2519
*/
26-
export const _bytesToBase64: Type_bytesToBase64 = /*@__PURE__*/ (
20+
export const _bytesToBase64: bytesToBase64Func = /*@__PURE__*/ (
2721
typeof Uint8Array.prototype.toBase64 == 'function' // Node.js v25
2822
? (bytes, omitPadding) => Uint8Array.prototype.toBase64.call(bytes, { omitPadding })
2923
: typeof Buffer == 'function' && Buffer.prototype && typeof Buffer.prototype.base64Slice == 'function'
@@ -41,7 +35,7 @@ export const _bytesToBase64: Type_bytesToBase64 = /*@__PURE__*/ (
4135
* A boolean specifying whether to omit padding characters (=) at the end of the base64 string.
4236
* The default is false.
4337
*/
44-
export const _bytesToBase64url: Type_bytesToBase64 = /*@__PURE__*/ (
38+
export const _bytesToBase64url: bytesToBase64Func = /*@__PURE__*/ (
4539
typeof Uint8Array.prototype.toBase64 == 'function' // Node.js v25
4640
? (bytes, omitPadding) => Uint8Array.prototype.toBase64.call(bytes, { alphabet: 'base64url', omitPadding })
4741
: typeof Buffer == 'function' && Buffer.prototype && typeof Buffer.prototype.base64urlSlice == 'function'
@@ -57,15 +51,15 @@ export const _bytesToBase64url: Type_bytesToBase64 = /*@__PURE__*/ (
5751
: make_bytesToBase64(alphabeturl)
5852
)
5953

60-
export const _base64ToBytes: Type_base64ToBytes = /*@__PURE__*/ (
54+
export const _base64ToBytes: base64ToBytesFunc = /*@__PURE__*/ (
6155
typeof Uint8Array.fromBase64 == 'function' // Node.js v25
6256
? base64 => Uint8Array.fromBase64(base64)
6357
: typeof Buffer == 'function' && Buffer.prototype && typeof Buffer.prototype.base64Write == 'function'
6458
? make_base64ToBytes_NodeJS(Buffer.prototype.base64Write)
6559
: make_base64ToBytes(alphabet)
6660
)
6761

68-
export const _base64urlToBytes: Type_base64ToBytes = /*@__PURE__*/ (
62+
export const _base64urlToBytes: base64ToBytesFunc = /*@__PURE__*/ (
6963
typeof Uint8Array.fromBase64 == 'function' // Node.js v25
7064
? base64 => Uint8Array.fromBase64(base64, { alphabet: 'base64url' })
7165
: typeof Buffer == 'function' && Buffer.prototype && typeof Buffer.prototype.base64urlWrite == 'function'

src/make.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
import type {
2-
Type_bytesToBase64,
3-
Type_base64ToBytes,
4-
Type_encode,
5-
Type_decode,
6-
Type_decodeToString,
7-
} from '../type.d.ts'
1+
/**
2+
* @param omitPadding
3+
* A boolean specifying whether to omit padding characters (=) at the end of the base64 string.
4+
* The default is false.
5+
*/
6+
export type bytesToBase64Func = (bytes: Uint8Array, omitPadding?: boolean) => string
7+
8+
export type base64ToBytesFunc = (base64: string) => Uint8Array<ArrayBuffer>
9+
10+
export type encodeFunc = (input: Uint8Array | string, omitPadding?: boolean) => string
11+
12+
export type decodeFunc = base64ToBytesFunc
13+
14+
export type decodeToStringFunc = (input: string, textDecoder?: TextDecoder) => string
815

916
let __textEncoder: TextEncoder | undefined
1017
let __textDecoder: TextDecoder | undefined
1118

12-
export function make_bytesToBase64(alphabet: string): Type_bytesToBase64 {
19+
export function make_bytesToBase64(alphabet: string): bytesToBase64Func {
1320
if (typeof alphabet != 'string' || alphabet.length !== 64) throw TypeError(`invalid alphabet format`);
1421
const _alphabet = new Uint8Array(64)
1522
for (let code, i = 0; i < 64; i++) {
@@ -41,7 +48,7 @@ export function make_bytesToBase64(alphabet: string): Type_bytesToBase64 {
4148
}
4249
}
4350

44-
export function make_base64ToBytes(alphabet: string): Type_base64ToBytes {
51+
export function make_base64ToBytes(alphabet: string): base64ToBytesFunc {
4552
if (typeof alphabet != 'string' || alphabet.length !== 64) throw TypeError(`invalid alphabet length`);
4653
const _alphabet = new Uint8Array(128).fill(64)
4754
for (let code, i = 0; i < 64; i++) {
@@ -84,7 +91,7 @@ export function make_base64ToBytes(alphabet: string): Type_base64ToBytes {
8491

8592
export function make_base64ToBytes_NodeJS(
8693
base64Write: (this: Uint8Array, base64: string) => number
87-
): Type_base64ToBytes {
94+
): base64ToBytesFunc {
8895
return base64 => {
8996
const b64len = base64.length
9097
, out = new Uint8Array(b64len * .75 - (
@@ -98,7 +105,7 @@ export function make_base64ToBytes_NodeJS(
98105
}
99106
}
100107

101-
export function make_encode(toBase64: Type_bytesToBase64): Type_encode {
108+
export function make_encode(toBase64: bytesToBase64Func): encodeFunc {
102109
return (input, omitPadding) => toBase64(
103110
typeof input == 'string'
104111
? (__textEncoder ||= new TextEncoder).encode(input)
@@ -107,11 +114,11 @@ export function make_encode(toBase64: Type_bytesToBase64): Type_encode {
107114
)
108115
}
109116

110-
export function make_decode(toBytes: Type_base64ToBytes): Type_decode {
117+
export function make_decode(toBytes: base64ToBytesFunc): decodeFunc {
111118
return base64 => toBytes('' + base64)
112119
}
113120

114-
export function make_decodeToString(_decode: Type_decode): Type_decodeToString {
121+
export function make_decodeToString(_decode: decodeFunc): decodeToStringFunc {
115122
return (input, textDecoder) =>
116123
(textDecoder || (__textDecoder ||= new TextDecoder)).decode(_decode(input))
117124
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"declarationDir": "dist",
1212
"strict": true
1313
},
14-
"include": ["src/**/*", "type.d.ts"],
14+
"include": ["src"],
1515
"exclude": ["dist", "node_modules"]
1616
}

type.d.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)