Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mys1024/base64-esm
A Base64 library written in ESM.
https://github.com/mys1024/base64-esm
base64 javascript-library npm-package
Last synced: about 1 month ago
JSON representation
A Base64 library written in ESM.
- Host: GitHub
- URL: https://github.com/mys1024/base64-esm
- Owner: mys1024
- License: mit
- Created: 2022-08-19T08:03:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-10T15:33:06.000Z (over 1 year ago)
- Last Synced: 2024-10-01T16:09:33.084Z (about 2 months ago)
- Topics: base64, javascript-library, npm-package
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/base64-esm
- Size: 113 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# base64-esm
A Base64 library written in ESM.
## Usage
### Base64
```typescript
import { base64Encode, base64Decode, base64DecodeToStr } from 'base64-esm'// encode
base64Encode(new Uint8Array([80, 171, 243, 128])) // UKvzgA==
base64Encode('Hello, world!') // SGVsbG8sIHdvcmxkIQ==// decode
base64Decode('UKvzgA==') // Uint8Array(4) [80, 171, 243, 128]
base64DecodeToStr('SGVsbG8sIHdvcmxkIQ==') // Hello, world!
```### Base64Url
```typescript
import { base64urlEncode, base64urlDecode, base64urlDecodeToStr } from 'base64-esm'// encode
base64urlEncode(new Uint8Array([80, 171, 243, 128])) // UKvzgA
base64urlEncode('你好,🌏!这是一个处理 Base64 的 ESM 库。') // 5L2g5aW977yM8J-Mj--8gei_meaYr-S4gOS4quWkhOeQhiBCYXNlNjQg55qEIEVTTSDlupPjgII// decode
base64urlDecode('UKvzgA') // Uint8Array(4) [80, 171, 243, 128]
base64urlDecodeToStr('5L2g5aW977yM8J-Mj--8gei_meaYr-S4gOS4quWkhOeQhiBCYXNlNjQg55qEIEVTTSDlupPjgII') // 你好,🌏!这是一个处理 Base64 的 ESM 库。
```## References
- Base64: [RFC 4648: Base 64 Encoding](https://datatracker.ietf.org/doc/html/rfc4648#section-4)
- Base64Url: [RFC 4648: Base 64 Encoding with URL and Filename Safe Alphabet](https://datatracker.ietf.org/doc/html/rfc4648#section-5)
## License
MIT