Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
truncate-middle
Advanced tools
There are cases where important information is at the end of the string and truncating the end isn't helpful.
var book1 = "America Again: Re-becoming the Greatness We Never Weren't by Stephen Colbert (978-0446583978)";
var truncateMiddle = require('truncate-middle');
var display = truncateMiddle(book1, 30, 16, '...');
// You get 'America Again: Re-becoming the...(978-0446583978)'
Install from npm
.
npm install --save truncate-middle
Requiring in JavaScript
var truncateMiddle = require('truncate-middle');
truncateMiddle('the quick brown', 5, 3, '...');
// Result:
// 'the q...own'
Defaults:
truncateMiddle('the quick brown');
// Result:
// 'the quick brown'
Specifying a front length of 5:
truncateMiddle('the quick brown', 5);
// Result:
// 'the q…'
Specifying a front length of 5 and back length of 3:
truncateMiddle('the quick brown', 5, 3);
// Result:
// 'the q…own'
When there isn't anything to truncate:
truncateMiddle('the quick brown', 50, 50);
// Result:
// 'the quick brown'
truncateMiddle(str, frontLen, backLen, truncateStr)
…
Return is always the truncated string.
MIT
FAQs
Truncates in the middle.
The npm package truncate-middle receives a total of 4,485 weekly downloads. As such, truncate-middle popularity was classified as popular.
We found that truncate-middle 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.