![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
human-format
Advanced tools
Readme
Converts a number to/from a human readable string:
1337
↔1.34kB
Installation of the npm package:
> npm install --save human-format
Then require the package:
var humanFormat = require('human-format');
You can directly use the build provided at unpkg.com:
<script src="https://unpkg.com/human-format@0.10/index.js"></script>
humanFormat(1337)
//=> '1.34 k'
// The number of decimals can be changed.
humanFormat(1337, {
decimals: 1
})
//=> '1.3 k'
// Units and scales can be specified.
humanFormat(65536, {
scale: 'binary',
unit: 'B'
})
//=> 64 kiB
// A custom separator can be specified.
humanFormat(1337, {
separator: ' - '
})
//=> 1.34 - k
// Custom scales can be created!
var timeScale = new humanFormat.Scale({
seconds: 1,
minutes: 60,
hours: 3600,
days: 86400,
months: 2592000,
})
humanFormat(26729235, { scale: timeScale })
//=> 10.31 months
// You can force a prefix to be used.
humanFormat(100, { unit: 'm', prefix: 'k' })
//=> 0.1 km
// You can access the raw result.
humanFormat.raw(100, { prefix: 'k' })
//=> {
// prefix: 'k',
// value: 0.09999999999999999 // Close value, not rounded.
// }
humanFormat.parse('1.34 kiB', { scale: 'binary' })
//=> 1372.16
// Fallbacks when possible if the prefix is incorrectly cased.
humanFormat.parse('1 g')
// => 1000000000
// You can access the raw result.
humanFormat.parse.raw('1.34 kB')
//=> {
// factor: 1000,
// prefix: 'k',
// unit: 'B',
// value: 1.34
//}
Contributions are very welcomed, either on the documentation or on the code.
You may:
Contributors:
ISC © Julien Fontanet
FAQs
Converts a number to/from a human readable string: `1337` ↔ `1.34kB`
The npm package human-format receives a total of 94,612 weekly downloads. As such, human-format popularity was classified as popular.
We found that human-format demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.