
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
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 1 weekly downloads. As such, string-analyzer popularity was classified as not popular.
We found that string-analyzer 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
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.