Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jsenv/log

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/log - npm Package Compare versions

Comparing version 1.6.2 to 1.6.3

4

package.json
{
"name": "@jsenv/log",
"version": "1.6.2",
"version": "1.6.3",
"description": "Nice and dynamic logs in the terminal",

@@ -35,3 +35,3 @@ "license": "MIT",

"scripts": {
"test": "node ./scripts/test.mjs"
"test": "node --conditions=development ./scripts/test.mjs"
},

@@ -38,0 +38,0 @@ "dependencies": {

@@ -1,20 +0,31 @@

import { require } from "@jsenv/utils/require.js"
import { setRoundedPrecision } from "./decimals.js"
const bytes = require("bytes")
// https://github.com/visionmedia/bytes.js
export const byteAsFileSize = (metricValue) => {
return bytes(metricValue, { decimalPlaces: 2, unitSeparator: " " })
return formatBytes(metricValue)
}
export const byteAsMemoryUsage = (
metricValue,
{ fixedDecimals = true } = {},
) => {
return bytes(metricValue, {
decimalPlaces: 2,
unitSeparator: " ",
fixedDecimals,
export const byteAsMemoryUsage = (metricValue) => {
return formatBytes(metricValue, { fixedDecimals: true })
}
const formatBytes = (number, { fixedDecimals = false } = {}) => {
if (number === 0) {
return `0 B`
}
const exponent = Math.min(
Math.floor(Math.log10(number) / 3),
BYTE_UNITS.length - 1,
)
const unitNumber = number / Math.pow(1000, exponent)
const unitName = BYTE_UNITS[exponent]
const decimals = unitName === "B" ? 0 : 1
const unitNumberRounded = setRoundedPrecision(unitNumber, {
decimals,
})
if (fixedDecimals) {
return `${unitNumberRounded.toFixed(decimals)} ${unitName}`
}
return `${unitNumberRounded} ${unitName}`
}
const BYTE_UNITS = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc