Installations
npm install pad
Developer Guide
Typescript
No
Module System
ESM
Min. Node Version
>= 4.0.0
Node Version
20.17.0
NPM Version
10.8.2
Score
98.3
Supply Chain
100
Quality
76.6
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (67.02%)
JavaScript (32.98%)
Developer
Download Statistics
Total Downloads
72,069,495
Last Day
51,110
Last Week
210,491
Last Month
921,719
Last Year
11,832,885
GitHub Statistics
42 Stars
164 Commits
13 Forks
4 Watching
1 Branches
7 Contributors
Package Meta Information
Latest Version
3.3.0
Package Id
pad@3.3.0
Unpacked Size
58.43 kB
Size
12.84 kB
File Count
8
NPM Version
10.8.2
Node Version
20.17.0
Publised On
29 Sept 2024
Total Downloads
Cumulative downloads
Total Downloads
72,069,495
Last day
-1.1%
51,110
Compared to previous day
Last week
-9%
210,491
Compared to previous week
Last month
-1.7%
921,719
Compared to previous month
Last year
-13.8%
11,832,885
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
Dev Dependencies
31
Optional Dependencies
1
Node.js pad
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.
Usage
The API is quite simple:
1import pad from "pad"; 2// Or const pad = require("pad") 3pad("pad", 5); // "pad " 4pad(5, "pad"); // " pad" 5pad("pad", 5, "+"); // "pad++" 6pad(5, "pad", "+"); // "++pad"
For TypeScript users, the type definition files are located in "./lib/index.d.ts" and declared inside the "package.json" file.
Bundles
Node Pad comes in multiple flavours depending on your target environment:
- CommonJS:
dist/pad.cjs.js
Bundle used by Node.js and compatible with ES5. It is declared inside thepackage.json
by themain
property and used by default withrequire("pad")
in a Node.js environment. - ES module:
dist/pad.esm.js
Bundle using the ECMAScript standard defined in ES6 for working with modules. The path to the ES module is declared inside thepackage.json
by themodule
property for ESM-aware tools like Rollup and webpack 2+.
The CommonJS syntax to import Node Pad is:
1const pad = require("pad/dist/pad.cjs.js"); 2// Or simply 3const pad = require("pad");
While the ES Modules syntax is:
1import pad from "pad/dist/pad.esm.js"; 2// Or for ESM-aware tools 3import pad from "pad";
Options
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)
The character used to fill the gap.colors
(boolean)
Ajust to hidden terminal color characters, you may also userequire 'pad/lib/colors'
to avoid passing this option.strip
(boolean)
Remove characters from text if length smaller than text length, default to "false".fixed_width
(boolean)
An optimization option to disable the usage of the wcwdith package to handle the discovery of characters using more than one column for display. one column to displaywcwidth_options
(object)
Options passed to the wcwidth package used to calculate the display width of characters using more than one column.
Left padding: pad(length, text, [options])
Left padding occurs when the first argument is a number and the second argument is a string.
1import pad from "pad"; 2pad(5, "pad", "-").should.eql("--pad");
Right padding: pad(text, length, [options])
Right padding occurs when the first argument is a string and the second argument is a number.
1import pad from "pad"; 2pad("pad", 6).should.eql("pad ");
Installing
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:
1npm install pad
Via git (or downloaded tarball), copy or link the project from a discoverable Node.js directory:
1git clone http://github.com/adaltas/node-pad.git
Testing
Clone the repo, install the development dependencies and run the suite:
1git clone http://github.com/adaltas/node-pad.git . 2npm install 3make test
Contributors
The project is sponsored by Adaltas based in Paris, France. Adaltas offers support and consulting on distributed systems, big data and open source.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: BSD 3-Clause "New" or "Revised" License: LICENSE:0
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/publish.yml:21
Reason
2 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-7q7g-4xm8-89cq
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/publish.yml:1
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/adaltas/node-pad/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/adaltas/node-pad/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/adaltas/node-pad/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/adaltas/node-pad/publish.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/adaltas/node-pad/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/adaltas/node-pad/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/adaltas/node-pad/test.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/publish.yml:34
- Info: 0 out of 7 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3.6
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More