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

fmat

v1.0.5

Published

A barebones yet feature-rich string formatter.

Downloads

95

Readme

code style: prettier

fmat

A barebones but feature-rich string formatter

Usage

Installation

$ npm install fmat

Usage

Import fmat into your project.

import fmat from 'fmat';

Use it by calling the function with an input value and options, this will always return a string.

const formattedString = fmat('hello', {}); // -> 'hello'

Options

delimiter: string

Set the delimiter to insert at every format value index within the input string.

Default: " "

Usage

const formattedString = fmat('hello', { format: [1], delimiter: '!' }); // -> 'h!ello'

execution: 'loop' | 'hang' | 'exec'

Set the behaviour when the string is longer than the available format indexes.

  • loop - loops the format until the end of the input string.
  • hang - loops the last format value until the end of the input string.
  • exec - runs just the format and quits after.

Default: 'exec'

Usage

const formattedString = fmat('hello', { format: [1], execution: 'loop' }); // -> 'h e l l o'
const formattedString = fmat('hello', { format: [2, 1], execution: 'hang' }); // -> 'he l l o'
const formattedString = fmat('hello', { format: [2, 1], execution: 'exec' }); // -> 'he l lo'

format: Array<number | { step: number, delimiter: string}>

Set the steps which represent indexes to add a delimiter to. You can specify an array of just a number or an object with the step value and a delimiter for that specific step. These options can be mixed together.

Default: []

Usage

const formattedString = fmat('hello', { format: [1] }); // -> 'h ello'
const formattedString = fmat('hello', { format: [1, { step: 2, delimiter: '-' }] }); // -> 'h el-lo'

prefix: string

Set a prefix for your input to be included in formatting.

Default: ""

Usage

const formattedString = fmat('1234567890', { format: [4, 2], execution: 'hang', prefix: "+316" }); // -> '+316 12 34 56 78 90'

Contributing

Want to contribute? Great! Please branch out from the master version from using a branchname such as feature/{insert-descriptive-feature-name} and create a pull request when ready.

Use npm run build to build the project.