Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@waiting/base64
Advanced tools
Readme
Base64 encoding/decoding in pure JS on both modern Browsers and Node.js based on base64-js.
Also supports URL-safe base64
string
, number
and bigint
ArrayBuffer
or Uint8Array
TextEncoder
/TextDecoder
under browser and Buffer
under Node.jsESM
, UMD
and CJS
bigint
base64 encodingutf-8
and utf-16le
npm install @waiting/base64
See the Docs for details
import { b64encode, b64fromBuffer, b64urlEncode } from '@waiting/base64'
b64encode('A') === 'QQ=='
b64encode('schöne') === 'c2Now7ZuZQ=='
b64encode(1n) === b64encode(1) // bigint -> 'MQ=='
b64encode('𠮷') === b64encode('\uD842\uDFB7') === b64encode('\u{20BB7}') // '8KCutw=='
const u8arr = Uint8Array.from([0xe4, 0xb8, 0xad, 0xe6, 0x96, 0x87])
b64fromBuffer(u8arr) === b64encode('中文') // '5Lit5paH'
// URL-safe
b64urlEncode('A') === 'QQ'
b64urlEncode('中文测试') === '5Lit5paH5rWL6K-V'
import { b64decode, b64urlDecode } from '@waiting/base64'
b64decode('MQ==') === '1'
b64urlDecode('MQ') === '1'
import { b64toURLSafe, b64fromURLSafe } from '@waiting/base64'
// base64 -> URL-safe base64
b64toURLSafe('QQ==') === 'QQ'
b64toURLSafe('5Lit5paH5rWL6K+V') === '5Lit5paH5rWL6K-V'
// URL-safe base64 -> base64
b64fromURLSafe('QQ') === 'QQ=='
b64fromURLSafe('0J_RgNC40LLQtdGCLCDQvNC40YAh') === '0J/RgNC40LLQtdGCLCDQvNC40YAh'
See the Docs for details
<script type="module">
import { b64encode, b64urlEncode } from './base64.esm.min.js'
console.log( b64encode('A') ) // 'QQ=='
console.log( b64urlEncode('A') ) // 'QQ'
console.log( b64encode('\uD842\uDFB7') ) // '8KCutw=='
</script>
<!-- polyfill for Edge
Note: text-encoder-lite parse 4-bytes UTF-8 char incorrectly,
so use text-encoding instead.
see: https://github.com/solderjs/TextEncoderLite/issues/16
-->
<!--
<script src="https://raw.githubusercontent.com/inexorabletash/text-encoding/master/lib/encoding-indexes.js"></script>
<script src="https://raw.githubusercontent.com/inexorabletash/text-encoding/master/lib/encoding.js"></script>
-->
<script src="./base64.umd.min.js"></script>
<script>
// global variable base64
console.log( base64.b64encode('A') )
console.log( base64.b64urlEncode('A') )
console.log( base64.b64encode('\uD842\uDFB7') )
</script>
npm run test
# for browsers FireFox and Chrome
npm run test:browser
# for browsers all available on this client
cd .config && npm i
npm run browser:detect
FAQs
Base64 encoding/decoding in pure JS on both modern Browsers and Node.js. Also supports URL-safe base64
We found that @waiting/base64 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.