npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

murky

v1.0.1

Published

like util.format with additional placeholders

Downloads

6

Readme

murky

Build Status Coverage Status

This module is written on typescript, and contains the .d.ts file. If you write on typescript: just use it in your project and definitions will be automatically uploaded.

npm i -S murky

About

murky - it's like util.format, but with additional placeholders.

Module Demo

Exports

interface IMurky {
  (fmtStr?: string, ...replacers: Array<any>): string
  (...replacers: Array<any>): string
}

export const color: IMurky = function() { /*...*/ }
export const nocolor: IMurky = function() { /*...*/ }

const auto: IMurky = function() {
  return require('supports-color')
    ? color.apply(null, arguments) as string
    : nocolor.apply(null, arguments) as string
}

export default auto

color/nocolor mode

murky uses supports-color to detect whether a terminal supports color. So in general, you can use the default exported function to obtain the best result.

Notes:

  • if you use the color mode, all no string arguments will be painted by util.inspect.
  • if you use the nocolor mode, all the arguments will be discolored, including the format string. It uses a uncolor module.
  • in any mode all string arguments, except the format string, will be discolored, this is due to the internal module needs.

util.format compatibility

  • you can not specify a format string, like util.format(1, 2, 3) === '1 2 3'.
  • you can print a percent sign, like util.format('%%') === '%'.
  • you can specify more placeholders than you need, like util.format('%s %s', 1) === '1 %s'.
  • you can specify less placeholders than you need, like util.format('', 1) === ' 1'.

List of placeholders

  • %j - alias to %j of util.format.
  • %s - cast any value to string.
  • %l - first cast value to string and then flattens result.
  • %t - first cast value to string and then adds pad to the result, like on the demo picture. Project was started for sake of it :)
  • %d and %n - firstly, if the value is not a finite number or a string which is contained a finite number, then the value will be processed by strings handler, like %s. If the value contains a finite number, it will be formatted by severing of the digit triples.
  • %m and %ms - if the value contains a finite number, it will be formatted by pretty-large-ms. Otherwise value will be processed by strings handler, like %s.
  • %f - if the value contains a finite number, it will be formatted by filesize. Otherwise value will be processed by strings handler, like %s.

More demo's

Life Time Demo Text Block Demo File Stat Demo Unsage Input Demo