Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
strip-outer
Advanced tools
Package description
The strip-outer npm package is designed to remove the outermost matching substring from a given string. It is particularly useful for trimming specific characters or patterns from the start and end of strings, allowing for more precise string manipulation than traditional trim methods.
Strip specific characters from the start and end of a string
This feature allows you to remove specific characters or patterns from both the start and end of a string. In the provided code sample, the 'strip-outer' package is used to remove the '---' characters from around the 'Hello World' string.
"use strict";\nconst stripOuter = require('strip-outer');\nconsole.log(stripOuter('---Hello World---', '---')); // 'Hello World'
Strip patterns using regular expressions
This feature demonstrates the ability to use regular expressions to define the pattern to be stripped from the string. In the example, all '#' characters are removed from the start and end of the 'Hello World' string.
"use strict";\nconst stripOuter = require('strip-outer');\nconsole.log(stripOuter('###Hello World###', /#+/)); // 'Hello World'
The 'trim' package offers functionality to remove whitespace from both ends of a string. While it is similar in its purpose of trimming strings, it does not offer the flexibility of removing specific characters or patterns like 'strip-outer'.
Although 'left-pad' is more focused on adding padding to the start of a string, it is mentioned here for its relevance in string manipulation. Unlike 'strip-outer', 'left-pad' does not remove characters but adds them, serving an opposite yet related purpose.
Readme
Strip a substring from the start/end of a string
$ npm install strip-outer
import stripOuter from 'strip-outer';
stripOuter('foobarfoo', 'foo');
//=> 'bar'
stripOuter('unicorncake', 'unicorn');
//=> 'cake'
FAQs
Strip a substring from the start/end of a string
The npm package strip-outer receives a total of 3,125,554 weekly downloads. As such, strip-outer popularity was classified as popular.
We found that strip-outer 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.