How to use pretty-bytes - 10 common examples

To help you get started, we’ve selected a few pretty-bytes 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 GoogleChromeLabs / critters / src / index.js View on Github external
}

        const percent = sheetInverse.length / before.length * 100;
        afterText = `, reducing non-inlined size ${percent | 0}% to ${prettyBytes(sheetInverse.length)}`;
        style.$$assets[style.$$assetName] = new sources.LineToLineMappedSource(sheetInverse, style.$$assetName, before);
      } else {
        this.logger.warn('pruneSource is enabaled, but a style (' + name + ') has no corresponding Webpack asset.');
      }
    }

    // replace the inline stylesheet with its critical'd counterpart
    setNodeText(style, sheet);

    // output stats
    const percent = sheet.length / before.length * 100 | 0;
    this.logger.info('\u001b[32mInlined ' + prettyBytes(sheet.length) + ' (' + percent + '% of original ' + prettyBytes(before.length) + ') of ' + name + afterText + '.\u001b[39m');
  }
}
github beakerbrowser / beaker / app / builtin-pages / com / settings / dat-network-activity.js View on Github external
async onDeleteFiles (archive) {
    try {
      if (!confirm('This will delete this archive. Are you sure?')) {
        return
      }
      const res = await beaker.archives.delete(archive.key)
      toast.create(`Files deleted (${prettyBytes(res.bytes)} freed)`, '', 5e3)
      this.fetchArchives()
    } catch (e) {
      console.error(e)
      toast.create('Something went wrong', 'error')
      return
    }
  }
github sebastian-software / preppy / src / progressPlugin.js View on Github external
async generateBundle(outputOptions, bundle, isWrite) {
        for (const fileName in bundle) {
          const entry = bundle[fileName]
          console.log(
            `${chalk.green(figures.tick)} Written: ${chalk.green(
              path.relative(root, outputOptions.file)
            )} in ${chalk.blue(formatDuration(start))} [${prettyBytes(entry.code.length)}]`
          )
        }
      }
    }
github processing / p5.js-web-editor / client / modules / IDE / components / AssetList.jsx View on Github external
{assetList.map(asset =>
                (
                  
                    {asset.name}
                    {prettyBytes(asset.size)}
                    View
                    {asset.sketchName}
                  
                ))}
github beakerbrowser / beaker / app / shell-window / ui / navbar / datsite-menu.js View on Github external
<img class="favicon">
              <h1 class="page-title">
                ${page.siteInfo.title &amp;&amp; page.siteInfo.title.length
                  ? page.siteInfo.title
                  : yo`<em>Untitled</em>`
                }
              </h1>
            

            <div class="peer-count">
              ${page.siteInfo.peers || '0'} ${pluralize(page.siteInfo.peers, 'peer')} seeding these files.
              <a class="link"> this.onOpenPage(HELP_DOCS_URL)}&gt;Learn more.</a>
            </div>

            <div class="net-stats">
              <div><span class="fa fa-arrow-down"></span> ${prettyBytes(downloadTotal)}</div>
              <div><span class="fa fa-arrow-up"></span> ${prettyBytes(uploadTotal)}</div>
            </div>
          

          ${this.rehostSlider ? this.rehostSlider.render() : ''}

          <div class="network-url">
            <a> this.onOpenPage(`beaker://library/${page.siteInfo.url}#network`)}&gt;
              <i class="fa fa-cog"></i>
              View network activity
            </a>
          </div>
        
      `
  }
github beakerbrowser / beaker / app / builtin-pages / com / files-browser / files-flat-view.js View on Github external
function rFile (filesBrowser, node, depth) {
  return yo`
    <a href="${node.url}" title="${node.name}" class="item file"> onClickNode(e, filesBrowser, node)}
      oncontextmenu=${e =&gt; onContextmenuNode(e, filesBrowser, node)}
    &gt;
      <i class="far fa-file"></i>
      <div class="name-container"><div class="name">${node.name}</div></div>
      <div class="updated">${niceMtime(node.mtime)}</div>
      <div class="size">${typeof node.size === 'number' ? prettyBytes(node.size) : '--'}</div>
    </a>
  `
}
github machawk1 / wail / wail-core / managers / archiveManager.js View on Github external
async _colFromSeedsColDirExists (colPath, col, seeds) {
    const aColStats = await getFsStats(colPath)
    const colCreateTime = moment(aColStats.birthtime)
    let colLastUpdated
    if (seeds.length > 0) {
      colLastUpdated = moment.max(seeds.map(s => moment(s.lastUpdated)))
    } else {
      colLastUpdated = moment().format()
    }
    let colSize = '0 B', ensures = 'index'
    const colWarcP = path.join(colPath, 'archive')
    if (await checkPathExists(colWarcP)) {
      colSize = prettyBytes(await CollectionsUtils.getColSize(colWarcP))
    } else {
      ensures = 'both'
    }
    await CollectionsUtils.ensureColDirs(colPath, ensures)
    let backUpMdata = {description: `Recreated by WAIL after found to be not existing`, title: col}
    let metadata
    try {
      metadata = await getYamlOrWriteIfAbsent(path.join(colPath, 'metadata.yaml'), backUpMdata)
    } catch (getYamlError) {
      backUpMdata.description = `${backUpMdata.description} but could not create file on disk.`
    }
    return {
      _id: col,
      name: col,
      colPath,
      size: colSize,
github sanity-io / sanity / packages / @sanity / client / src / scripts / print-bundle-size.js View on Github external
function size(bytes) {
  const color = bytes > 1024 * 50 ? 'red' : 'green'
  return chalk[color](prettyBytes(bytes))
}
github ezpaarse-project / ezpaarse / client / components / Process / LogFiles.vue View on Github external
totalFileSize () {
      const size = this.logFiles.reduce((prev, { file }) => prev + file.size, 0);
      return prettyBytes(size);
    }
  },
github heyuxian / mcloud / mcloud-console / src / routes / Dashboard / Monitoring / Details.js View on Github external
{prettyBytes(memory.used.heap.value)}/{prettyBytes(memory.max.heap.value)}
                        
                      
                    }
                    percent={(memory.used.heap.value / memory.max.heap.value).toFixed(2)}
                  /&gt;
                
                
                  
                        <b>Non Heap</b>
                        <br>
                        <span>
                          {prettyBytes(memory.used.nonheap.value)}/{prettyBytes(
                            memory.max.nonheap.value
                          )}
                        </span>
                      
                    }
                    percent={(memory.used.nonheap.value / memory.max.nonheap.value).toFixed(2)}
                  /&gt;
                
              
            ) : null}
          
        
      
    );
  }
}

pretty-bytes

Convert bytes to a human readable string: 1337 → 1.34 kB

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis

Popular pretty-bytes functions