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

sqrup

v0.1.4

Published

![](https://i.imgur.com/MvMTdgF.png)

Downloads

3

Readme

sqrup

Surround text with a rectangle and draw attention to it.

const sqrup = require('sqrup');

const result = sqrup('Hello,\nworld!');

console.log(result);

Output:

************
*  Hello,  *
*  world!  *
************

Install

npm i sqrup

API

Function signature:

function sqrup(text, options)

With TypeScript types:

function sqrup(text: string | string[], options: string | sqrup.SquareUpOptions): string
type SquareUpOptions = {
  default?: string;
  // Sides
  left?: string;
  right?: string;
  top?: string;
  bottom?: string;
  // Corners
  topLeft?: string;
  topRight?: string;
  bottomLeft?: string;
  bottomRight?: string;
  // Pad
  padLeft?: number;
  padRight?: number;
  padBottom?: number;
  padTop?: number;
}

Or you can just take a look at the included index.d.ts file.

Examples

1. Use custom character

(Instead of the default asterisk *)

sqrup('One,\nTwo,\nThree.', 'x');
xxxxxxxxxxxx
x  One,    x
x  Two,    x
x  Three.  x
xxxxxxxxxxxx

2. Control the padding between the text and the square

sqrup('WELCOME\n HOME', {
                   // defaults:
    default: 'o',  // '*'
    padLeft: 8,    // 2
    padRight: 8,   // 2
    padTop: 2,     // 0
    padBottom: 2,  // 0
});
ooooooooooooooooooooooooo
o                       o
o                       o
o        WELCOME        o
o         HOME          o
o                       o
o                       o
ooooooooooooooooooooooooo

3. Fine grained customization

sqrup('Look Ma,\n I\'m in a box!', {
  // default:  ...,
  // The `default` option does nothing in this specific scenario
  // since all of the edge charactrers are specified individually
  // in the options at the bottom.

  // Pad
  padLeft: 8,
  padRight: 2,
  padBottom: 0,
  padTop: 2,

  // All of the following options use the character specifeid
  // in the `defeault` if not given any value:

  // Sides
  left: '▶',
  right: '◀',
  top: '▼',
  bottom: '▲',
  // Corners
  topLeft: '◢',
  topRight: '◣',
  bottomLeft: '◥',
  bottomRight: '◤',
});
◢▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼▼◣
▶                        ◀
▶                        ◀
▶        Look Ma,        ◀
▶         I'm in a box!  ◀
◥▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲◤

Defaults

type SquareUpOptions = {
  default?: string;      // '*'

  // Pad
  padLeft?: number;      // 2
  padRight?: number;     // 2
  padBottom?: number;    // 0
  padTop?: number;       // 0

  // The following 8 options will all use the value of the `default`
  // option if they are not explicitly specified.

  // Sides
  left?: string;         // use `default`
  right?: string;        // use `default`
  top?: string;          // use `default`
  bottom?: string;       // use `default`
  // Corners
  topLeft?: string;      // use `default`
  topRight?: string;     // use `default`
  bottomLeft?: string;   // use `default`
  bottomRight?: string;  // use `default`
}

Extra - How to produce the image at the top

sqrup('\u001b[32msqrup\u001b[39m', {
  default: '\u001b[33m*\u001b[39m',
  // Sides
  left: '\u001b[33m⁑\u001b[39m',
  right: '\u001b[33m⁑\u001b[39m',
  // Pad
  padLeft: 6,
  padRight: 6,
  padBottom: 2,
  padTop: 2,
})

License

ISC