Skip to content

Commit b8e2871

Browse files
authored
Update README.md
1 parent 6614f42 commit b8e2871

File tree

1 file changed

+44
-68
lines changed

1 file changed

+44
-68
lines changed

README.md

Lines changed: 44 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,65 @@
1-
<p align="center">
2-
<img width="100px" src="https://raw.githubusercontent.com/localtools/nodejs-base64/main/.github/images/favicon512x512-npm.png" align="center" alt=":package: nodejs-base64" />
3-
<h2 align="center">:package: nodejs-base64</h2>
4-
<p align="center">Node.js Base64 Text Encoder/Decoder</p>
5-
<p align="center">
6-
<a href="https://github.com/localtools/nodejs-base64/issues">
7-
<img alt="Issues" src="https://img.shields.io/github/issues/localtools/nodejs-base64?style=flat&color=336791" />
8-
</a>
9-
<a href="https://github.com/localtools/nodejs-base64/pulls">
10-
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/localtools/nodejs-base64?style=flat&color=336791" />
11-
</a>
12-
<a href="https://github.com/localtools/nodejs-base64">
13-
<img alt="GitHub Downloads" src="https://img.shields.io/npm/dw/nodejs-base64?style=flat&color=336791" />
14-
</a>
15-
<a href="https://github.com/localtools/nodejs-base64">
16-
<img alt="GitHub Total Downloads" src="https://img.shields.io/npm/dt/nodejs-base64?color=336791&label=Total%20downloads" />
17-
</a>
18-
<a href="https://github.com/localtools/nodejs-base64">
19-
<img alt="GitHub release" src="https://img.shields.io/github/release/localtools/nodejs-base64.svg?style=flat&color=336791" />
20-
</a>
21-
<br />
22-
<br />
23-
<a href="https://github.com/localtools/nodejs-base64/issues/new/choose">Report Bug</a>
24-
<a href="https://github.com/localtools/nodejs-base64/issues/new/choose">Request Feature</a>
25-
</p>
26-
<h3 align="center">Systems on which it has been tested:</h3>
27-
<p align="center">
28-
<a href="https://www.apple.com/br/macos/">
29-
<img alt="Macos" src="https://img.shields.io/badge/mac%20os-000000?style=for-the-badge&logo=apple&logoColor=white&style=flat" />
30-
</a>
31-
<a href="https://ubuntu.com/download">
32-
<img alt="Ubuntu" src="https://img.shields.io/badge/Ubuntu-E95420?style=for-the-badge&logo=ubuntu&logoColor=white&style=flat" />
33-
</a>
34-
<a href="https://www.microsoft.com/pt-br/windows/">
35-
<img alt="Windows" src="https://img.shields.io/badge/Windows-0078D6?style=for-the-badge&logo=windows&logoColor=white&style=flat" />
36-
</a>
37-
</p>
38-
<p align="center">Did you like the project? Please, considerate <a href="https://www.buymeacoffee.com/hebertcisco">a donation</a> to help improve!</p>
39-
40-
<p align="center"><strong>Node.js Base64 Text Encoder/Decoder</strong>✨</p>
41-
42-
[![codecov](https://codecov.io/gh/localtools/nodejs-base64/branch/main/graph/badge.svg?token=Q9fr548J0D)](https://codecov.io/gh/localtools/nodejs-base64)
43-
44-
# Getting started
1+
# @localtools/base64
452

46-
## Installation
3+
A Node.js library for encoding and decoding text as Base64.
474

48-
> Clone this repository: `git clone https://github.com/localtools/nodejs-base64`
5+
## Installation
496

50-
### Open the directory and run the script line
7+
To install `@localtools/base64`, run the following command:
518

52-
```bash
53-
cd nodejs-base64
9+
```ts
10+
npm install @localtools/base64
5411
```
5512

56-
```bash
57-
npm i # or yarn
58-
```
13+
## Usage
14+
15+
To use `@localtools/base64`, import the `Base64` class and call its `encode` and `decode` methods:
16+
17+
```ts
18+
import { Base64 } from '@localtools/base64';
19+
20+
const encodedText = Base64.encode({ text: 'hello world' });
21+
console.log(encodedText); // Outputs: "aGVsbG8gd29ybGQ="
5922

60-
```bash
61-
rm -rf .git && git init && git add . && git commit -m "Initial commit" #Optional
23+
const decodedText = Base64.decode({ base64Text: encodedText });
24+
console.log(decodedText); // Outputs: "hello world"
6225
```
6326

64-
Or create use the button "Use this template"
27+
The `encode` method takes an object with a `text` field, and returns the Base64 encoding of the text. The `decode` method takes an object with a `base64Text` field, and returns the text represented by the Base64 encoding.
28+
29+
## API
30+
31+
### `Base64.encode(args: EncodeArgs): string`
32+
33+
Encodes a text string as a Base64 string.
34+
35+
#### Parameters
36+
37+
- `args` (`EncodeArgs`): An object with the following fields:
38+
- `text` (`string`): The text to encode.
39+
- `encoding` (`string`): The encoding to use. Defaults to `'base64'`.
40+
- `start` (`number`): The index of the first character in the text to encode. Defaults to `0`.
41+
- `end` (`number`): The index of the last character in the text to encode. Defaults to `text.length`.
6542

66-
Edit the Icon on Figma:
43+
#### Returns
6744

68-
<a href="https://www.figma.com/file/vpevGX3j9tmtW8OyLQ9eUm/nodejs-base64-icon?node-id=0%3A1">
69-
<img alt="Figma Icon" src="https://raw.githubusercontent.com/localtools/nodejs-base64/main/.github/images/figma-badge.png"/>
70-
</a>
45+
A Base64-encoded string.
7146

72-
## 🤝 Contributing
47+
### `Base64.decode(args: DecodeArgs): string`
7348

74-
Contributions, issues and feature requests are welcome!<br />Feel free to check [issues page](issues).
49+
Decodes a Base64 string as a text string.
7550

76-
## Show your support
51+
#### Parameters
7752

78-
Give a ⭐️ if this project helped you!
53+
- `args` (`DecodeArgs`): An object with the following fields:
54+
- `base64Text` (`string`): The Base64 string to decode.
55+
- `fromEncoding` (`string`): The encoding of the Base64 string. Defaults to `'base64'`.
56+
- `outputEncoding` (`string`): The encoding to use for the output text. Defaults to `'utf8'`.
7957

80-
Or buy me a coffee 🙌🏾
58+
#### Returns
8159

82-
<a href="https://www.buymeacoffee.com/hebertcisco">
83-
<img src="https://img.buymeacoffee.com/button-api/?text=Buy me a coffee&emoji=&slug=hebertcisco&button_colour=FFDD00&font_colour=000000&font_family=Inter&outline_colour=000000&coffee_colour=ffffff" />
84-
</a>
60+
The text represented by the Base64 string.
8561

8662
## 📝 License
8763

88-
Copyright © 2022 [Hebert F Barros](https://github.com/hebertcisco).<br />
64+
Copyright © 2023 [LocalTools](https://github.com/localtools).<br />
8965
This project is [MIT](LICENSE) licensed.

0 commit comments

Comments
 (0)