Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
string-analyzer
Advanced tools
A JavaScript package that provides a function to analyze a given string and returns various details about it, such as its length, character count, word count, presence of numbers, special characters, whitespace, and whether it's a palindrome. Additionally
This JavaScript function, analyzeString()
, analyzes a given string and returns various details about it.
This function does not require any installation. You can simply include it in your JavaScript code.
The analyzeString()
function takes a string as input and returns an object containing the following details:
const input = "A man, a plan, a canal, Panama!";
const stringDetails = analyzeString(input);
{
"length": 30,
"characterCount": 27,
"wordCount": 6,
"containsNumbers": false,
"containsSpecialCharacters": true,
"containsWhitespace": true,
"isAllUpperCase": false,
"isAllLowerCase": false,
"isPalindrome": true
}
In addition to the functionalities described above, the analyzeString()
function now includes the following additional features:
characterFrequency: Returns an object containing the frequency of each character in the input string.
const input = "hello";
const characterFreq = analyzeString(input).characterFrequency;
{
"h": 1,
"e": 1,
"l": 2,
"o": 1
}
vowelCount: Number of vowels in the string.
const input = "hello world";
const vowelCount = analyzeString(input).vowelCount;
3
consonantCount: Number of consonants in the string.
const input = "hello world";
const consonantCount = analyzeString(input).consonantCount;
7
isAnagram: Determines whether two input strings are anagrams of each other.
const input1 = "listen";
const input2 = "silent";
const isAnagram = analyzeString(input1).isAnagram(input1, input2);
true
isAntigram: Determines whether two input strings are antigrams of each other.
const input1 = "hello";
const input2 = "world";
const isAntigram = analyzeString(input1).isAntigram(input1, input2);
false
countSubstringOccurrences: Counts the number of occurrences of a substring in the input string.
const input = "hello world hello";
const substring = "hello";
const count = analyzeString(input).countSubstringOccurrences(input, substring);
2
startsWith: Checks if the input string starts with a certain substring.
const input = "hello world";
const substring = "hello";
const startsWith = analyzeString(input).startsWith(input, substring);
true
endsWith: Checks if the input string ends with a certain substring.
const input = "hello world";
const substring = "world";
const endsWith = analyzeString(input).endsWith(input, substring);
true
longestWord: Returns the longest word in the input string.
const input = "hello beautiful world";
const longestWord = analyzeString(input).longestWord;
"beautiful"
reverseWords: Reverses the order of words in the input string.
const input = "hello world";
const reversedWords = analyzeString(input).reverseWords(input);
"world hello"
These additional functionalities enhance the capabilities of the analyzeString()
function, providing users with a comprehensive tool for string analysis and manipulation.
FAQs
A JavaScript package that provides a function to analyze a given string and returns various details about it, such as its length, character count, word count, presence of numbers, special characters, whitespace, and whether it's a palindrome. Additionally
The npm package string-analyzer receives a total of 0 weekly downloads. As such, string-analyzer popularity was classified as not popular.
We found that string-analyzer demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.