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

mako-utils

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mako-utils

Internal utilities for mako and plugins.

  • 0.2.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

mako-utils

Internal utilities for mako and plugins.

npm version build status coverage npm dependencies npm dev dependencies code style

API

These utilities are used by mako core and plugins internally, but they may be useful to other plugin developers.

relative(to)

Takes the given to absolute path and gives the relative path from pwd.

NOTE: pwd is cached from startup, so this assumes that cwd never changes.

size(input, [raw])

Takes the given input (string/buffer) and returns the actual size in a human-friendly format.

The raw argument can be passed to return the size in a raw Number reflecting the number of bytes.

sizeDiff(a, b)

Takes the given numbers for a and b, computes the delta from a -> b and returns a human-friendly string showing the change.

For example:

console.log(sizeDiff(1000, 1500))
// 1 kB → 1.5 kB (+50%)

console.log(sizeDiff(1000, 250))
// 1 kB → 250 B (-75%)

timer()

Used for timing code with process.hrtime(). A function is returned that will return the time elapsed since the timer was created. (in a human-friendly format)

let timer = utils.timer()

// do stuff...

console.log('finished doing stuff (took %s)', timer())

The returned function has an optional raw argument. When set to true, it will instead return the time elapsed in the raw hrtime array format.

Keywords

FAQs

Package last updated on 14 Sep 2016

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc