1.1.0 • Published 6 years ago

is-base64 v1.1.0

Weekly downloads
196,615
License
MIT
Repository
github
Last release
6 years ago

is-base64

Predicate that returns true if base64 string.

Install

npm install is-base64

Usage

var isBase64 = require('is-base64');

var string = 'iVBORw0KGgoAAAAN ... kSuQmCC';
var stringWithMime = 'data:image/png;base64,iVBORw0KGgoAAAA ... AAElFTkSuQmCC';

console.log(isBase64(string)); // true
console.log(isBase64(stringWithMime)); // false
console.log(isBase64(stringWithMime, {allowMime: true})); // true
console.log(isBase64(string, {mimeRequired: true})); // false
console.log(isBase64(stringWithMime, {mimeRequired: true})); // true
console.log(isBase64('1342234')); // false
console.log(isBase64('afQ$%rfew')); // false
console.log(isBase64('dfasdfr342')); // false
console.log(isBase64('uuLMhh==')); // true
console.log(isBase64('uuLMhh')); // false
console.log(isBase64('uuLMhh', {paddingRequired: false})); // true
console.log(isBase64('')); // true
console.log(isBase64('', {allowEmpty: false})); // false

API

isBase64(string, options)

CLI

Install CLI:

npm install -g is-base64

CLI example:

$ is-base64 aGVsbG8gd29ybGQ=
true

Piping example:

$ echo aGVsbG8gd29ybGQ= | is-base64
true

FAQ

  • Q: Why is empty string "" a valid base64 string by default?

License

MIT

anghamimediaenginesingpass-myinfo-oidc-helpernode-red-contrib-txgruppi-image-toolsoutput-service@infinitebrahmanuniverse/nolb-is-bactivepieces-youtrackpiece-line@everything-registry/sub-chunk-1932@anjirauto/piece-gmail@anjirauto/piece-openai@anjirauto/piece-telegram-bot@anjirauto/piece-woocommerce@anjirauto/ap-google-my-business@anjirauto/piece-spotifyshopwptest-specifiedsvg-to-pdfvoicestashinstall-isimage-pixelshollaex-node-libhomebridge-ultimate-goveehemmeliggupackageinsomnia-plugin-reqresp-base64like-js-interfacelink-preview-generatorlowcode-ailnrpc-node-clientknot-cloudmdr-cli@webweld/piece-web@wedof/piece-wedof@wmbullseye/piece-bullseye-lead@wusoma/piece-namecloud@xanthous/dgraph-js@tuyendaovan6789/piece-intercom@tuyendaovan6789/piece-pipedrive@tookey-io/piece-cryptomus@tookey-io/piece-epn@tookey-io/piece-ethereum@tookey-io/piece-instant-form@tookey-io/piece-internetcomputer@tookey-io/piece-moonbeam@tookey-io/piece-polygon-id@tookey-io/piece-telegram-bot@tookey-io/piece-uniswap-v3@tookey-io/piece-wallet@tookey-io/piece-alchemy@tookey-io/piece-allbridge@tookey-io/piece-bitcoin@tookey-io/piece-cloudinary@tookey-io/piece-coingecko@tookey-io/piece-cryptoapi@telelogx/piece-mokhatbat@telelogx/piece-analytick@voicespin/piece-voicespin@unumid/server-sdk@youkuohao/react-components@youzanyun-fe/youzanyun-data-security@xpay-ph/xpay-api-librariesakke-lpak-easyinvoiceags_authrestact-piece-simple-secretb64-to-file-cliapipost-sendfuzionx-node-lib@taskmagic/piece-csveasyinvoiceeasy-saveeasypdf-ioexpress-tusetz-encryptorffcateflexos-flarefastify-request-logs@abtnode/core@activepieces/piece-tidycal@activepieces/piece-totalcms@activepieces/piece-trello@activepieces/piece-twilio@activepieces/piece-vbout@activepieces/piece-vtex@activepieces/piece-vtiger@activepieces/piece-webflow@activepieces/piece-tags@activepieces/piece-taskade@activepieces/piece-telegram-bot@acedempire/piece-acumbamail@acedempire/piece-ringcentral@acedempire/piece-twilio-response@acedempire/piece-twilio-v2@activepieces/piece-schedule@activepieces/piece-segment@activepieces/piece-gotify@activepieces/piece-hackernews@activepieces/piece-heartbeat@activepieces/piece-instagram-business@activepieces/piece-interfaces
1.1.0

6 years ago

1.0.0

6 years ago

0.1.0

7 years ago

0.0.6

7 years ago

0.0.5

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

9 years ago

0.0.1

11 years ago