Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Changelog
Version 3.2.0
Readme
Node Pad is a simple and elegant function to pad strings in both left and right directions.
The API is quite simple:
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.js
package.json
by the main
property and used by default with require("pad")
in a Node.js environment.dist/pad.esm.js
package.json
by the module
property for ESM-aware tools like Rollup and webpack 2+.dis/pad.umd.js
Bundle in the Universal Module Definition (UMD), a format compatible with both AMD and CommonJS.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.
var pad = require('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.
var pad = require('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/wdavidw/node-pad.git
Clone the repo, install the development dependencies and run the suite:
git clone http://github.com/wdavidw/node-pad.git .
npm install
make test
FAQs
Left and right string padding
The npm package pad receives a total of 205,471 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.