JSPM

halis-pad

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q29289F
  • License MIT

Pad left, right or both (to your heart's content)

Package Exports

  • halis-pad

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (halis-pad) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

halis-pad

Pad left, right or both (to your heart's content)

Install

npm install halis-pad --save

Unit Tests

npm run test

Usage

Minimal usage:

const padWith = ' ';
const pad = require( 'halis-pad' ) ( padWith ); // pass in character to pad with

console.log( pad.both( 'Hello' ) ); // " Hello "
console.log( pad.both2( 'Hello' ) ); // "  Hello  "
console.log( pad.both3( 'Hello' ) ); // "   Hello   "
console.log( pad.both4( 'Hello' ) ); // "    Hello    "
console.log( pad.bothUntil( 'Hello', 14 ) ); // "      Hi      "

console.log( pad.left( 'Hello' ) ); // " Hello"
console.log( pad.left2( 'Hello' ) ); // "  Hello"
console.log( pad.left3( 'Hello' ) ); // "   Hello"
console.log( pad.left4( 'Hello' ) ); // "    Hello"
console.log( pad.leftUntil( 'Hello', 14 ) ); // "            Hi"

console.log( pad.right( 'Hello' ) ); // "Hello "
console.log( pad.right2( 'Hello' ) ); // "Hello  "
console.log( pad.right3( 'Hello' ) ); // "Hello   "
console.log( pad.right4( 'Hello' ) ); // "Hello    "
console.log( pad.rightUntil( 'Hello', 14 ) ); // "Hi            "

const star = '*';
const padStars = require( 'halis-pad' ) ( star );
console.log( padStars.both3( ' Hello ') ); // "*** Hello ***";

const bad = require( 'halis-pad' ) ( '   ' );
// ERROR: length on padWith cannot be more than 1

const good = require( 'halis-pad' ) ( );
// Okay: if padWith is empty defaults to ' '