GithubHelp home page GithubHelp logo

vishwagauravin / string-tools-pro Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 24 KB

๐Ÿค Tiny & versatile ๐Ÿ”ฅ Node.js library for in-depth text analysis, manipulation and data extraction.

Home Page: https://www.npmjs.com/package/string-tools-pro

License: Apache License 2.0

JavaScript 100.00%
character-counter cookie parse-email parse-url punctuation text-analysis text-manipulation vowels whitespace word-count

string-tools-pro's Introduction


String Tools Pro

What is String Tools Pro?

Tiny & versatile Node.js library for in-depth text analysis, including character, word, and sentence counting, punctuation analysis, case sensitivity, email and URL detection, and more. Perform text manipulation and data extraction effortlessly. No external dependencies needed.

Installation

To get started with string-tools-pro, you can easily install it via npm:

npm install string-tools-pro

Usage

Importing the Package

To use string-tools-pro in your Node.js project, import it as follows:

const stringTools = require('string-tools-pro');

Functions and Sub-Functions

analyzeText(inputText)

The analyzeText function serves as a one-stop solution for comprehensive text analysis. It computes a variety of metrics related to the input text, providing a detailed overview of its characteristics.

Usage:

const inputText = 'This is a sample text. It contains sentences.';
const analysisResult = stringTools.analyzeText(inputText);
console.log(analysisResult);

Example of the Returned Object:

{
  charCount: 41,
  wordCount: 8,
  sentenceCount: 2,
  newLineCount: 0,
  punctuationCount: 3,
  consonantCount: 20,
  vowelCount: 21,
  spaceConsumedOnDisk: 41,
  capitalLetters: 3,
  capitalPercentage: '7.32',
  smallLetters: 18,
  smallPercentage: '43.90',
  consonantPercentage: '51.28',
  vowelPercentage: '48.72',
  isEmail: false,
  isURL: false,
  alphanumericText: 'ThisisasampletextItcontainssentences',
  whitespaceCount: 7
}

In this example, the input text is "This is a sample text. It contains sentences." The analyzeText function returns an object with various metrics related to the text, including character count, word count, sentence count, punctuation count, and more. The metrics provide a detailed analysis of the input text.

findQueryFromURL(url)

The findQueryFromURL function extracts and returns the query parameters from a URL in the form of a JSON object.

Usage:

const url = 'https://www.example.com/search?query=test&page=1';
const queryParameters = stringTools.findQueryFromURL(url);
console.log(queryParameters);

Example of the Returned Object:

{
  query: 'test',
  page: '1'
}

The function retrieves the query parameters from the given URL and returns them as a JSON object. The resulting JSON object represents the key-value pairs from the URL's query string.

findDomainFromURL(url)

The findDomainFromURL function extracts and returns the domain from a URL.

Usage:

const url = 'https://www.example.com/search?query=test&page=1';
const domain = stringTools.findDomainFromURL(url);
console.log(domain);

Example of the Returned String:

'www.example.com'

This function isolates the domain portion of the provided URL and returns it as a string. The extracted domain typically represents the host of the URL.

extractCookie(cookieString)

The extractCookie function parses a cookie string and returns the cookies as a JSON object.

Usage:

const cookieString = 'cookie1=value1; cookie2=value2; cookie3=value3';
const cookies = stringTools.extractCookie(cookieString);
console.log(cookies);

Example of the Returned Object:

{
  cookie1: 'value1',
  cookie2: 'value2',
  cookie3: 'value3'
}

This function takes a semicolon-delimited cookie string and separates it into key-value pairs. The result is returned as a JSON object with the cookie names as keys and their corresponding values as values.

extractEmails(inputText)

The extractEmails function extracts all email addresses from the input text and returns them as an array.

Usage:

const inputText = 'This is an email: [email protected] and another one: [email protected]';
const emails = stringTools.extractEmails(inputText);
console.log(emails);

Example of the Returned Array:

This function utilizes regular expressions to identify email addresses within the input text. All discovered email addresses are returned as an array of strings.

extractURLs(inputText)

The extractURLs function identifies and returns all URLs present in the input text as an array.

Usage:

const inputText = 'Visit our website at https://www.example.com or check out our blog at http://blog.example.com';
const urls = stringTools.extractURLs(inputText);
console.log(urls);

Example of the Returned Array:

['https://www.example.com', 'http://blog.example.com']

This function employs regular expressions to locate URLs in the input text. The discovered URLs are returned as an array of strings.

License

string-tools-pro is distributed under the Apache 2.0 license.

Contributions

Contributions to this package are encouraged. If you encounter issues or have suggestions for enhancements, please feel free to open

an issue or submit a pull request on GitHub.

Author

This package was developed by Vishwa Gaurav.

Support

For support and inquiries, please contact [email protected].

We hope that string-tools-pro proves to be an invaluable asset for your text analysis and manipulation needs. Enjoy the functionality it offers!

string-tools-pro's People

Contributors

vishwagauravin avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.