10000 refactor!: rename `String` type to `Text` · unjs/undio@764f03b · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 764f03b

Browse files
committed
refactor!: rename String type to Text
1 parent 271389e commit 764f03b

18 files changed

+209
-210
lines changed

README.md

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
- [Number Array][Number Array]
2929
- [ReadableStream][ReadableStream]
3030
- [Response][Response]
31-
- [String][String]
31+
- [Text][Text]
3232
- [Uint8Array][Uint8Array]
3333

3434
## Usage
@@ -87,10 +87,10 @@ Undio automatically detects the input type and uses the proper method to convert
8787
**Example:**
8888

8989
```ts
90-
import { detectType, toString, toReadableStream } from "undio";
90+
import { detectType, toText, toReadableStream } from "undio";
9191

9292
// Convert any supported type (auto-detected)
93-
const string = await toString(value);
93+
const string = await toText(value);
9494
const stream = await toReadableStream(value);
9595

9696
// "ArrayBuffer" | "Blob"| "DataView" | "NumberArray" | "ReadableStream" | "String" | "Uint8Array";
@@ -157,9 +157,9 @@ Convert from [ArrayBuffer][ArrayBuffer] to [ReadableStream][ReadableStream]
157157

158158
Convert from [ArrayBuffer][ArrayBuffer] to [Response][Response]
159159

160-
### `arrayBufferToString(arrayBuffer)`
160+
### `arrayBufferToText(arrayBuffer)`
161161

162-
Convert from [ArrayBuffer][ArrayBuffer] to [String][String]
162+
Convert from [ArrayBuffer][ArrayBuffer] to [Text][Text]
163163

164164
### `arrayBufferToUint8Array(arrayBuffer)`
165165

@@ -181,7 +181,7 @@ Convert from any value to [ArrayBuffer][ArrayBuffer]
181181

182182
### `assertBase64(input, opts?)`
183183

184-
Assert that input is an instance of [String][String] and matches the [Base64][Base64] pattern or throw a `TypeError`.
184+
Assert that input is an instance of [Text][Text] and matches the [Base64][Base64] pattern or throw a `TypeError`.
185185

186186
### `base64ToArrayBuffer(string, base64Options?)`
187187

@@ -207,9 +207,9 @@ Convert from [Base64][Base64] to [ReadableStream][ReadableStream]
207207

208208
Convert from [Base64][Base64] to [Response][Response]
209209

210-
### `base64ToString(string, opts?)`
210+
### `base64ToText(string, opts?)`
211211

212-
Convert from [Base64][Base64] to [String][String]
212+
Convert from [Base64][Base64] to [Text][Text]
213213

214214
### `base64ToUint8Array(string, base64Options?)`
215215

@@ -253,9 +253,9 @@ Convert from [Blob][Blob] to [ReadableStream][ReadableStream]
253253

254254
Convert from [Blob][Blob] to [Response][Response]
255255

256-
### `blobToString(blob)`
256+
### `blobToText(blob)`
257257

258-
Convert from [Blob][Blob] to [String][String]
258+
Convert from [Blob][Blob] to [Text][Text]
259259

260260
### `blobToUint8Array(blob)`
261261

@@ -299,9 +299,9 @@ Convert from [DataView][DataView] to [ReadableStream][ReadableStream]
299299

300300
Convert from [DataView][DataView] to [Response][Response]
301301

302-
### `dataViewToString(dataView)`
302+
### `dataViewToText(dataView)`
303303

304-
Convert from [DataView][DataView] to [String][String]
304+
Convert from [DataView][DataView] to [Text][Text]
305305

306306
### `dataViewToUint8Array(dataView)`
307307

@@ -345,9 +345,9 @@ Convert from [Number Array][Number Array] to [DataView][DataView]
345345

346346
Convert from [Number Array][Number Array] to [ReadableStream][ReadableStream]
347347

348-
### `numberArrayToString(numberArray)`
348+
### `numberArrayToText(numberArray)`
349349

350-
Convert from [Number Array][Number Array] to [String][String]
350+
Convert from [Number Array][Number Array] to [Text][Text]
351351

352352
### `numberArrayToUint8Array(numberArray)`
353353

@@ -387,9 +387,9 @@ Convert from [ReadableStream][ReadableStream] to [DataView][DataView]
387387

388388
Convert from [ReadableStream][ReadableStream] to [Number Array][Number Array]
389389

390-
### `readableStreamToString(readableStream)`
390+
### `readableStreamToText(readableStream)`
391391

392-
Convert from [ReadableStream][ReadableStream] to [String][String]
392+
Convert from [ReadableStream][ReadableStream] to [Text][Text]
393393

394394
### `readableStreamToUint8Array(readableStream)`
395395

@@ -437,51 +437,57 @@ Convert from [Response][Response] to [Number Array][Number Array]
437437

438438
Convert from [Response][Response] to [ReadableStream]ReadableStream]
439439

440-
### `responseToString(response)`
440+
### `responseToText(response)`
441441

442-
Convert from [Response][Response] to [String][String]
442+
Convert from [Response][Response] to [Text][Text]
443443

444444
### `responseToUint8Array(response)`
445445

446446
Convert from [Response][Response] to [Uint8Array][Uint8Array]
447447

448448
## String
449449

450-
### `assertString(input)`
450+
### `toText(input)`
451451

452-
Assert that input is an instance of [String][String] or throw a `TypeError`.
452+
Convert from any value to [Text][Text]
453453

454-
### `isString(input)`
454+
## Text
455455

456-
Test if input is an instance of [String][String] and return `true` or `false`.
456+
### `assertText(input)`
457457

458-
### `stringToArrayBuffer(string)`
458+
Assert that input is an instance of [Text][Text] or throw a `TypeError`.
459459

460-
Convert from [string][string] to [ArrayBuffer][ArrayBuffer]
460+
### `isText(input)`
461461

462-
### `stringToBase64(string, opts?)`
462+
Test if input is an instance of [Text][Text] and return `true` or `false`.
463463

464-
Convert from [string][string] to [Base64][Base64]
464+
### `textToArrayBuffer(string)`
465465

466-
### `stringToBlob(string, options?)`
466+
Convert from [Text][Text] to [ArrayBuffer][ArrayBuffer]
467467

468-
Convert from [string][string] to [Blob][Blob]
468+
### `textToBase64(string, opts?)`
469469

470-
### `stringToDataView(string)`
470+
Convert from [Text][Text] to [Base64][Base64]
471471

472-
Convert from [string][string] to [DataView][DataView]
472+
### `textToBlob(string, options?)`
473473

474-
### `stringToNumberArray(string)`
474+
Convert from [Text][Text] to [Blob][Blob]
475475

476-
Convert from [string][string] to [Number Array][Number Array]
476+
### `textToDataView(string)`
477477

478-
### `stringToReadableStream(string)`
478+
Convert from [Text][Text] to [DataView][DataView]
479479

480-
Convert from [string][string] to [ReadableStream][ReadableStream]
480+
### `textToNumberArray(string)`
481481

482-
### `stringToUint8Array(string)`
482+
Convert from [Text][Text] to [Number Array][Number Array]
483483

484-
Convert from [string][string] to [Uint8Array][Uint8Array]
484+
### `textToReadableStream(string)`
485+
486+
Convert from [Text][Text] to [ReadableStream][ReadableStream]
487+
488+
### `textToUint8Array(string)`
489+
490+Convert from [Text][Text] to [Uint8Array][Uint8Array]
485491

486492
## Uint8 Array
487493

@@ -525,9 +531,9 @@ Convert from [Uint8Array][Uint8Array] to [ReadableStream][ReadableStream]
525531

526532
Convert from [Uint8Array][Uint8Array] to [Response][Response]
527533

528-
### `uint8ArrayToString(uint8Array)`
534+
### `uint8ArrayToText(uint8Array)`
529535

530-
Convert from [Uint8Array][Uint8Array] to [String][String]
536+
Convert from [Uint8Array][Uint8Array] to [Text][Text]
531537

532538
### `convertTo(toType, input, fromType?)`
533539

@@ -543,7 +549,7 @@ Convert from [Number Array][Number Array] to [Response][Response]
543549

544550
Convert from [ReadableStream][ReadableStream] to [Response][Response]
545551

546-
### `stringToResponse(string, init?)`
552+
### `textToResponse(string, init?)`
547553

548554
<!-- /automd -->
549555

scripts/gen-maps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const types = [
88
"numberArray",
99
"readableStream",
1010
"response",
11-
"string",
11+
"text",
1212
"uint8Array",
1313
];
1414

0 commit comments

Comments
 (0)
0