bytesize
##Installation
Last updated 3 years ago by orthagonal1 .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install bytesize 
SYNC missed versions from official npm registry.

#bytesize

##Installation

npm install bytesize

##Usage

const bytesize = require('bytesize');

//string size
const size = bytesize.stringSize('1 12 3 123 123');
//size == 14

//string size
const size = bytesize.stringSize('1 12 3 123 123', true);
//size == 14B

//file size (returns a Promise that you can await)
try {
  const size = await bytesize.fileSize(__dirname + '/fixtures/test.txt');
  //size == 6660
} catch(exc) {
  console.log(exc);
}

//pretty file size
try {
  const size = await bytesize.fileSize(__dirname + '/fixtures/test.txt', true);
  //size == '6.50KB'
} catch(exc) {
  console.log(exc);
}

//gzip file size
try{
  const size = await bytesize.gzipSize(__dirname + '/fixtures/test.txt');
  //size == 190
} catch(exc) {
  console.log(exc);
}

//pretty gzip file size
const size = await bytesize.gzipSize(__dirname + '/fixtures/test.txt', true);
//size == '190B'

Current Tags

  • 1.1.0                                ...           latest (3 years ago)

4 Versions

  • 1.1.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
  • 0.2.0                                ...           8 years ago
  • 0.1.0                                ...           8 years ago
Downloads
Today 0
This Week 0
This Month 7
Last Day 0
Last Week 6
Last Month 7
Dependencies (1)
Dev Dependencies (4)

Copyright 2014 - 2016 © taobao.org |