How to use the any-base.BIN function in any-base

To help you get started, we’ve selected a few any-base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github oliver-moran / jimp / packages / core / src / index.js View on Github external
import composite from './composite';
import promisify from './utils/promisify';
import * as MIME from './utils/mime';
import { parseBitmap, getBuffer, getBufferAsync } from './utils/image-bitmap';
import * as constants from './constants';

const alphabet =
  '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_';

// an array storing the maximum string length of hashes at various bases
// 0 and 1 do not exist as possible hash lengths
const maxHashLength = [NaN, NaN];

for (let i = 2; i < 65; i++) {
  const maxHash = anyBase(anyBase.BIN, alphabet.slice(0, i))(
    new Array(64 + 1).join('1')
  );
  maxHashLength.push(maxHash.length);
}

// no operation
function noop() {}

// error checking methods

function isArrayBuffer(test) {
  return (
    Object.prototype.toString
      .call(test)
      .toLowerCase()
      .indexOf('arraybuffer') > -1

any-base

Converter from any base to other any base

MIT
Latest version published 7 years ago

Package Health Score

65 / 100
Full package analysis