
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.
split-text-smartly
Advanced tools
Smart way to split a text on white-space unless it's limited by the maximum allowed characters per line.
It's for the need of splitting up long text when fulfilling personal information forms with multiple first names, and last names like fields limited by the number of characters.
In other words given "name1", "name2", and "name3" form fields limited by 10 characters for each, and the "Jon Snow From Winterfell" name can be split up into [ 'Jon Snow ', 'From ', 'Winterfell' ] rows automatically.
Thanks to that form validation will improve a business process by taking off the need for human intervention.
Default options:
trimSentence = falsemaxAllowedRowLength = 20maxNumberOfRows = 100fulfillEmptyRows = falseExample text:
···Lorem·ipsum·dolor·sit·amet,·consectetur·adipiscingelit.···
trimSentencePreserves all the characters without trimming them at the edge of lines, when false, like below.
Set trimSentence = true:
[
'Lorem·ipsum·dolor·', // spaces are trimmed at the start
'sit·amet,·',
'consectetur·',
'adipiscing·elit.' // spaces are trimmed at the end
]
Set trimSentence = false:
[
'···Lorem·ipsum·dolor', // spaces are NOT trimmed at the start
'·sit·amet,·',
'consectetur·',
'adipiscing elit.···' // spaces are NOT trimmed at the end
]
maxAllowedRowLengthSplits lines at the charaters length when there is no white-space.
Set maxAllowedRowLength = 20:
[
'···Lorem·ipsum·dolor',
'·sit·amet,·',
'consectetur·',
'adipiscing elit.···'
]
Set maxAllowedRowLength = 5:
[
'···', 'Lorem', '·',
'ipsum', '·', 'dolor',
' sit ', 'amet,', '·',
'conse', 'ctetu', 'r·',
'adipi', 'scing', '·',
'elit.', '···'
]
maxNumberOfRowsLimits the number of rows after splitting a text and keeps the rest of text in the last line when text is limited by the number of lines.
maxNumberOfRows = 3:
[
'···Lorem·ipsum·dolor',
'·sit·amet,·',
'consectetur·adipiscing·elit.···' // more characters with the rest of text
]
maxNumberOfRows = 2:
[
'···Lorem·ipsum·dolor',
'·sit·amet,·consectetur·adipiscing elit.···' // more characters with the rest of text
]
fulfillEmptyRowsReturns empty lines in case text is shorter than allowed number of lines after slpitting it.
Set fulfillEmptyRows = true:
[
'···Lorem·ipsum·dolor',
' sit·amet,·',
'consectetur·',
'adipiscing elit.···',
'',
'',
'',
'',
'',
''
]
Set fulfillEmptyRows = false:
[
'···Lorem·ipsum·dolor',
' sit·amet,·',
'consectetur·',
'adipiscing elit.···'
]
FAQs
Split up the text at given position and by whitespace if possible
The npm package split-text-smartly receives a total of 5 weekly downloads. As such, split-text-smartly popularity was classified as not popular.
We found that split-text-smartly 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.