How to use the filesize.partial function in filesize

To help you get started, we’ve selected a few filesize 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 tableflip / ipld-explorer-cli / src / formatters / dag-node.js View on Github external
const filesize = require('filesize').partial({ unix: true })
const Chalk = require('chalk')
const formatPaths = require('./paths')
const formatData = require('./data')

module.exports = function formatDagNode (cid, info, paths) {
  const out = []

  out.push(Chalk.magenta(`${cid.codec} DAG Node`))

  const cidStr = cid.toBaseEncodedString()

  if (info.remainderPath) {
    out.push(`${Chalk.gray('Path:')} ${cidStr}/${info.remainderPath}`)
  } else {
    out.push(`${Chalk.gray('CID:')} ${cidStr}`)
  }
github ipfs-shipyard / ipfs-webui / src / explore / object-info / ObjectInfo.js View on Github external
import React from 'react'
import { ObjectInspector, chromeLight } from '@tableflip/react-inspector'
import filesize from 'filesize'
import LinksTable from './LinksTable'
const humansize = filesize.partial({ round: 0 })

const objectInspectorTheme = {
  ...chromeLight,
  BASE_FONT_SIZE: '13px',
  BASE_LINE_HEIGHT: '19px',
  TREENODE_FONT_SIZE: '13px',
  TREENODE_LINE_HEIGHT: '19px'
}

const nodeStyles = {
  'dag-cbor': { shortName: 'CBOR', name: 'CBOR DAG Node', color: '#28CA9F' },
  'dag-pb': { shortName: 'PB', name: 'Protobuf DAG Node', color: '#244e66' }
}

export function shortNameForNode (type) {
  const style = nodeStyles[type]
github tableflip / ipld-explorer-cli / src / formatters / paths.js View on Github external
const Table = require('cli-table')
const filesize = require('filesize').partial({ unix: true })
const Chalk = require('chalk')

const tableOptions = {
  chars: {
    'top': '',
    'top-mid': '',
    'top-left': '',
    'top-right': '',
    'bottom': '',
    'bottom-mid': '',
    'bottom-left': '',
    'bottom-right': '',
    'left': '',
    'left-mid': '',
    'mid': '',
    'mid-mid': '',
github tableflip / ipld-explorer-cli / src / formatters / dag.js View on Github external
const { inspect } = require('util')
const filesize = require('filesize').partial({ unix: true })
const Chalk = require('chalk')
const formatLinks = require('./links')

module.exports = function formatDag (node) {
  let formattedLinks = ''

  if (node.links.length) {
    formattedLinks = `

${Chalk.gray('Links:')}

${formatLinks(node.cid, node.links)}`
  }

  let formattedSize = ''
github ipfs-shipyard / ipfs-webui / src / status / NodeBandwidthChart.js View on Github external
import React from 'react'
import ReactDOM from 'react-dom'
import { Line } from 'react-chartjs-2'
import { withTranslation } from 'react-i18next'
import { connect } from 'redux-bundler-react'
import PropTypes from 'prop-types'
import filesize from 'filesize'
import { Title } from './Commons'

const chartsize = filesize.partial({ round: 1, exponent: 2, bits: true })
const tootltipSize = filesize.partial({ round: 0, bits: true, output: 'array' })

const defaultSettings = {
  defaultFontFamily: "'Inter UI', system-ui, sans-serif",
  responsive: true,
  tooltips: {
    mode: 'x',
    position: 'nearest',
    enabled: false
  },
  hover: { mode: 'index' },
  scales: {
    xAxes: [{
      type: 'time',
      time: {
        minUnit: 'second'
      }
github ipfs-shipyard / ipfs-webui / src / status / NodeBandwidthChart.js View on Github external
import React from 'react'
import ReactDOM from 'react-dom'
import { Line } from 'react-chartjs-2'
import { withTranslation } from 'react-i18next'
import { connect } from 'redux-bundler-react'
import PropTypes from 'prop-types'
import filesize from 'filesize'
import { Title } from './Commons'

const chartsize = filesize.partial({ round: 1, exponent: 2, bits: true })
const tootltipSize = filesize.partial({ round: 0, bits: true, output: 'array' })

const defaultSettings = {
  defaultFontFamily: "'Inter UI', system-ui, sans-serif",
  responsive: true,
  tooltips: {
    mode: 'x',
    position: 'nearest',
    enabled: false
  },
  hover: { mode: 'index' },
  scales: {
    xAxes: [{
      type: 'time',
      time: {
        minUnit: 'second'
github ipfs-shipyard / ipfs-webui / src / status / PeerBandwidthTable.js View on Github external
import React, { Component } from 'react'
import { connect } from 'redux-bundler-react'
import { withTranslation } from 'react-i18next'
import PropTypes from 'prop-types'
import filesize from 'filesize'
import CountryFlag from 'react-country-flag'
import Box from '../components/box/Box'
import { Title } from './Commons'
import ComponentLoader from '../loader/ComponentLoader.js'

const isWindows = window.navigator.appVersion.indexOf('Win') !== -1
const humansize = filesize.partial({ round: 0 })

export class PeerBandwidthTable extends Component {
  static propTypes = {
    peerBandwidthPeers: PropTypes.array.isRequired,
    peerLocations: PropTypes.object.isRequired
  }

  state = {
    sort: { field: 'rateOut', direction: -1 },
    showAll: false
  }

  getSorter ({ field, direction }) {
    return (a, b) => {
      if (a.bw[field].gt(b.bw[field])) return direction
      if (a.bw[field].lt(b.bw[field])) return -direction

filesize

JavaScript library to generate a human readable String describing the file size

BSD-3-Clause
Latest version published 1 month ago

Package Health Score

83 / 100
Full package analysis

Popular filesize functions