Socket
Socket
Sign inDemoInstall

bytesize

Package Overview
Dependencies
1
Maintainers
6
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

bytesize


Version published
Weekly downloads
849
increased by25.04%
Maintainers
6
Created
Weekly downloads
 

Readme

Source

#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'

FAQs

Last updated on 08 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc