npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

str2ab

v1.2.1

Published

Convert between string (including base64 and base64url), ArrayBuffer and Buffer.

Downloads

1,202

Readme

str2ab

npm version License: MIT

Convert between string (including base64 and base64url), ArrayBuffer and Buffer.

Usage

ESM

import str2ab from 'str2ab';

str2ab.string2arraybuffer('this is sample.');

CommonJS

const str2ab = require('str2ab');

str2ab.string2arraybuffer('this is sample.');

API

| From/To | string | ArrayBuffer | Base64URL | Base64 | Buffer | | :---------: | :--------------------------------------: | :------------------------------------: | :-----------------------------------------: | :--------------------------------------: | :--------------------------------------: | | string | x | 1.1 | 2.1 | 3.1 | 4.1 | | ArrayBuffer | 1.2 | x | 5.1 | 6.1 | 7.1 | | Base64URL | 2.2 | 5.2 | x | 8.1 | 9.1 | | Base64 | 3.2 | 6.2 | 8.2 | x | 10.1 | | Buffer | 4.2 | 7.2 | 9.2 | 10.2 | x |

1. String <-> ArrayBuffer

1.1 string2arraybuffer(string)

  • Returns ArrayBuffer

1.2 arraybuffer2string(ArrayBuffer)

  • Returns string

2. String <-> Base64URL

2.1 string2base64url(string)

  • Returns Base64URL encoded string

2.2 base64url2string(string)

  • Returns string

3. String <-> Base64

3.1 string2base64(string)

  • Returns Base64 encoded string

3.2 base642string(string)

  • Returns string

4. String <-> Buffer

4.1 string2buffer(string)

  • Returns Buffer

4.2 buffer2string(Buffer)

  • Returns string

5. ArrayBuffer <-> Base64URL

5.1 arraybuffer2base64url(ArrayBuffer)

  • Returns Base64 URL encoded string

5.2 base64url2arraybuffer(string)

  • Returns ArrayBuffer

6. ArrayBuffer <-> Base64

6.1 arraybuffer2base64(ArrayBuffer)

  • Returns Base64 encoded string

6.2 base642arraybuffer(string)

  • Returns ArrayBuffer

7. ArrayBuffer <-> Buffer

7.1 arraybuffer2buffer(ArrayBuffer)

  • Returns Buffer

7.2 buffer2arraybuffer(Buffer)

  • Returns ArrayBuffer

8. Base64URL <-> Base64

8.1 base64url2base64(string)

  • Returns Base64 encoded string

8.2 base642base64url(string)

  • Returns Base64 URL encoded string

9. Base64URL <-> Buffer

9.1 base64url2buffer(string)

  • Returns Buffer

9.2 buffer2base64url(Buffer)

  • Returns Base64 URL encoded string

10. Base64 <-> Buffer

10.1 base642buffer(string)

  • Returns Buffer

10.2 buffer2base64(Buffer)

  • Returns Base64 encoded string

isBase64url(string)

  • When input parameter is Base64 URL encoded string, returns true.
  • Otherwise returns false.

isBase64(string)

  • When input parameter is Base64 encoded string, returns true.
  • Otherwise returns false.

Install

npm

npm install str2ab

License

MIT