How to use byte-size - 7 common examples

To help you get started, we’ve selected a few byte-size 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 aragon / aragon-cli / packages / toolkit / src / ipfs / data-viz.js View on Github external
export function stringifyMerkleDAGNode(merkleDAG) {
  // ${merkleDAG.isDir ? '📁' : ''}
  const cid = merkleDAG.cid
  const name = merkleDAG.name || 'root'
  const parsedSize = byteSize(merkleDAG.size)
  const size = parsedSize.value + parsedSize.unit
  const delimiter = chalk.gray(' - ')

  return [name, size, chalk.gray(cid)].join(delimiter)
}
github badgen / badgen.net / api / bundlephobia.ts View on Github external
}
  }

  const { size, gzip } = resp

  switch (topic) {
    case 'min':
      return {
        subject: 'minified size',
        status: byteSize(size, { units: 'iec' }).toString().replace(/iB\b/, 'B'),
        color: 'blue'
      }
    case 'minzip':
      return {
        subject: 'minzipped size',
        status: byteSize(gzip, { units: 'iec' }).toString().replace(/iB\b/, 'B'),
        color: 'blue'
      }
    default:
      return {
        subject: 'bundlephobia',
        status: 'unknown topic',
        color: 'grey'
      }
  }
}
github circlecell / jsoncompare.com / packages / frontend / js / linteditor / index.js View on Github external
.calc('size', 'code', (code) => {
                const bytes = new Blob([code], {
                    type: 'text/javascript'
                }).size;
                const { value, unit } = byteSize(bytes, {
                    units: 'iec'
                });

                return bytes ? value + unit : '';
            })
            .calc('code', {
github aragon / aragon-cli / packages / toolkit / src / ipfs / config.js View on Github external
getFolderSize(repoPath, (err, size) => {
      if (err) {
        reject(err)
      } else {
        const humanReadableSize = byteSize(size)
        resolve(humanReadableSize)
      }
    })
  })
github zenorocha / browser-calories / src / scripts / result.js View on Github external
toBytes(data) {
    var obj = {};

    for (var prop in data) {
      if (data.hasOwnProperty(prop)) {
        obj[prop] = bytes(data[prop], { precision: 1 });
      }
    }

    return obj;
  }
github badgen / badgen.net / api / bundlephobia.ts View on Github external
if (!resp) {
    return {
      subject: 'bundlephobia',
      status: 'unknown',
      color: 'grey'
    }
  }

  const { size, gzip } = resp

  switch (topic) {
    case 'min':
      return {
        subject: 'minified size',
        status: byteSize(size, { units: 'iec' }).toString().replace(/iB\b/, 'B'),
        color: 'blue'
      }
    case 'minzip':
      return {
        subject: 'minzipped size',
        status: byteSize(gzip, { units: 'iec' }).toString().replace(/iB\b/, 'B'),
        color: 'blue'
      }
    default:
      return {
        subject: 'bundlephobia',
        status: 'unknown topic',
        color: 'grey'
      }
  }
}
github circlecell / jsoncompare.com / frontend / js / editor-init / showsize-option.js View on Github external
const changeSize = () => {
            const bytes = getBytes(editor.getValue());
            sizeBlock.innerHTML = bytes ? byteSize(bytes, {
                units: 'iec'
            }) : '';
        };

byte-size

Convert a bytes or octets value (e.g. 34565346) to a human-readable string ('34.6 MB'). Choose between metric or IEC units.

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis

Popular byte-size functions