
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
string-mod package structurerepeat(obj, count) - repeats given obj as stringfill(obj, size) - creates new string with given size using objpad
pad(text, filler, length) - adds filler to match target lengthpadLeft(text, filler, length) - adds leading filler to match target lengthpadRight(text, filler, length) - adds terminating filler to match target lengthpadCenter(text, filler, length) - surrounds text with filler to match target lengthinsert
insertAt(text, sti, position) - inserts sti at given position into textinsertStep(text, sti, step) - inserts sti after each step symbols into textrepeat(obj, count) - repeats given obj as stringReturns new string with obj being repeated count times
Returns empty string if count was less that 0
Converts any obj to type string
// Repeating strings
str_mod.repeat('X', 4); // Output: XXXXX
str_mod.repeat('*-', 4); // Output: *-*-*-*-
// Repeating other types
str_mod.repeat(5, 4); // Output: 5555
srt_mod.repeat(true, 4); // Output: truetruetruetrue
str_mod.repeat({}), 4); // Output: [object Object][object Object][object Object][object Object]
fill(obj, size) - creates new string with given size using obj(cyclic)Returns new string with size length, filled by obj(cyclic)
Returns empty string if size is less than 0
Converts any obj to type string
// Filling with characters
str_mod.fill('X', 5); // Output: XXXXX
// Filling with strings
str_mod.fill('*-', 5); // Output: *-*-*
pad(text, filler, length) - adds filler to match target lengthReturns text with added filler to match given length
If length is less than 0 filler will be added to the right of text
// Left pad
str_mod.pad('xxx', '-', 5); // Output: --xxx
str_mod.pad('xxx', '-', 2); // Output: xxx
// Right pad
str_mod.pad('xxx', '-', -5); // Output: xxx--
str_mod.pad('xxx', '-', -2); // Output: xxx
padLeft(text, filler, length) - adds leading filler to match target lengthReturns text with leading filler to match given length
// Left pad
str_mod.padLeft('xxx', '-', 5); // Output: --xxx
str_mod.padLeft('xxx', '-', 2); // Output: xxx
str_mod.padLeft('xxx', '-', -5); // Output: xxx
padRight(text, filler, length) - adds terminating filler to match target lengthReturns text with terminating filler to match given length
// Right pad
str_mod.padRight('xxx', '-', 5); // Output: xxx--
str_mod.padRight('xxx', '-', 2); // Output: xxx
str_mod.padRight('xxx', '-', -5); // Output: xxx
padCenter(text, filler, length) - surrounds text with filler to match target lengthReturns text with added filler around it to match given length
Returns text if length is less than text.length
// Odd length
str_mod.padCenter('xxx', '-', 7); // Outputs: --xxx--
str_mod.padCenter('xxx', '-', 1); // Outputs: xxx
// Even length
str_mod.padCenter('xxx', '-', 6); // Outputs: -xxx--
str_mod.padCenter('xxx', '-', 4); // Outputs: xxx-
// Length is less than text.length
str_mod.padCenter('xxx', '-', 1); // Ouputs: xxx
insertAt(text, sti, position) - insert sti at given position to textReturns new string from text with sti inserted before given position
If position is negative inserts after given position, going from right to left
Throws error if position is out of bounds
// Inserting at positive position
str_mod.insertAt('xxxx', '-', 2); // Outputs: xx-xx
str_mod.insertAt('xxxx', '-', 3); // Outputs: xxx-x
// Inserting at negative position
str_mod.insertAt('xxxx', '-', -1); // Outputs: xxxx-
str_mod.insertAt('xxxx', '-', -3); // Outpus: xx-xx
// Bad insers
str_mod.insertAt('xxxx', '-', 8); // Throws error. 8 is greater than text length
str_mod.insertAt('xxxx', '-', -9); // Throws error. -9 is less than negative text length
insertStep(text, sti, step) - inserts sti after each step symbols into textReturns new string with sti inserted in text after each step symbols. Does not insert sti at the end
Returns new string with sti inserted in text after each step symbols from right to left if step is negative
Returns text if step is more than text.length
Throws error if step is 0
// Inserting with positive step
str_mod.insertStep('thetststr:)', '-', 3); // Outputs: the-tst-str-:)
str_mod.insertStep('D:thetststr', '-', 3); // Outputs: D:t-het-sts-tr
// Insert with negative step
str_mod.insertStep('thetststr:)', '-', -3); // Outputs: th-ets-tst-r:)
str_mod.insertStep('D:thetststr', '-', -3); // Outputs: D:-the-tst-str
// Inserting without end
str_mod.insertStep('thekey', '-', 3); // Outputs: the-key
// Bad insert
str_mod.insertStep('thekey', '-', 0); // Throws error. Step can not be 0
FAQs
Tools for string modification. Includes pad, fill, repeat, insert
The npm package string-mod receives a total of 4 weekly downloads. As such, string-mod popularity was classified as not popular.
We found that string-mod 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.