
Security News
Critical Security Vulnerability in React Server Components
React disclosed a CVSS 10.0 RCE in React Server Components and is advising users to upgrade affected packages and frameworks to patched versions now.
Node Pad is a simple and elegant function to pad strings in both left and right directions. It is written in Typescript and it support both CommonJS and ESM.
The API is quite simple:
import pad from "pad";
// Or const pad = require("pad")
pad("pad", 5); // "pad "
pad(5, "pad"); // " pad"
pad("pad", 5, "+"); // "pad++"
pad(5, "pad", "+"); // "++pad"
For TypeScript users, the type definition files are located in "./lib/index.d.ts" and declared inside the "package.json" file.
Node Pad comes in multiple flavours depending on your target environment:
dist/pad.cjs.jspackage.json by the main property and used by default with require("pad") in a Node.js environment.dist/pad.esm.jspackage.json by the module property for ESM-aware tools like Rollup and webpack 2+.The CommonJS syntax to import Node Pad is:
const pad = require("pad/dist/pad.cjs.js");
// Or simply
const pad = require("pad");
While the ES Modules syntax is:
import pad from "pad/dist/pad.esm.js";
// Or for ESM-aware tools
import pad from "pad";
Options are provided as a third argument and are all optional. A string argument it is interpreted as the "char" option. Accepted options include:
char (string)colors (boolean)require 'pad/lib/colors' to avoid passing this option.strip (boolean)fixed_width (boolean)wcwidth_options (object)pad(length, text, [options])Left padding occurs when the first argument is a number and the second argument is a string.
import pad from "pad";
pad(5, "pad", "-").should.eql("--pad");
pad(text, length, [options])Right padding occurs when the first argument is a string and the second argument is a number.
import pad from "pad";
pad("pad", 6).should.eql("pad ");
Starting with version 1.1.0, Node pad rely on Node.js 4.0.0 or more recent. Stick to version 1.0.x if using an older version of Node.js.
Via npm:
npm install pad
Via git (or downloaded tarball), copy or link the project from a discoverable Node.js directory:
git clone http://github.com/adaltas/node-pad.git
Clone the repo, install the development dependencies and run the suite:
git clone http://github.com/adaltas/node-pad.git .
npm install
make test
The project is sponsored by Adaltas based in Paris, France. Adaltas offers support and consulting on distributed systems, big data and open source.
3.3.0 (2024-09-29)
The 'left-pad' package is a popular utility for left-padding strings with a specified character. It is similar to 'pad' but focuses solely on left-padding functionality.
The 'string-pad' package provides both left and right padding functionalities, similar to 'pad'. It allows padding with custom characters and offers more flexibility in padding options.
The 'pad-left' package is another utility for left-padding strings. It is similar to 'left-pad' and 'pad' but focuses exclusively on left-padding.
FAQs
Left and right string padding
The npm package pad receives a total of 300,795 weekly downloads. As such, pad popularity was classified as popular.
We found that pad demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
React disclosed a CVSS 10.0 RCE in React Server Components and is advising users to upgrade affected packages and frameworks to patched versions now.

Research
/Security News
We spotted a wave of auto-generated “elf-*” npm packages published every two minutes from new accounts, with simple malware variants and early takedowns underway.

Security News
TypeScript 6.0 will be the last JavaScript-based major release, as the project shifts to the TypeScript 7 native toolchain with major build speedups.