npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

words-frequency

v1.1.1

Published

simple module to calculate the frequency of words in a sentence

Downloads

3

Readme

words-frequency

module for helping to group and count number of words in a sentence

version history

  • v1.0.0 - the very first version
Hello World :)
  • v1.1.0 - minor changes
1. improve code
2. Add total of words in result form

How To Use

npm i words-frequency --save

// <Import the function>
const wordsFrequency = require('words-frequency');

// <example sentence> :
const sentencesEx = 'RegExr was created by gskinner.com, and is proudly hosted by Media Temple. Edit the Expression & Text to see matches. Roll over matches or the expression for details. PCRE & JavaScript flavors of RegEx are supported. Validate your expression with Tests mode. The side bar includes a Cheatsheet, full Reference, and Help. You can also Save & Share with the Community, and view patterns you create or favorite in My Patterns. Explore results with the Tools below. Replace & List output custom results. Details lists capture groups. Explain describes your expression in plain English !'

const groupOfSentences = wordsFrequency(sentencesEx);
console.log(groupOfSentences);

result :

{
    total: 91,
    data : {
      a: 1,also: 1,and: 3,are: 1,
      bar: 1,below: 1,by: 2,
      can: 1,capture: 1,cheatsheet: 1,com: 1,community: 1,create: 1,created: 1,custom: 1,
      describes: 1,details: 2,
      edit: 1,english: 1,explain: 1,explore: 1,expression: 4,
      favorite: 1,flavors: 1,for: 1,full: 1,
      groups: 1,gskinner: 1,
      help: 1,hosted: 1,
      in: 2,includes: 1,is: 1,
      javascript: 1,
      list: 1,lists: 1,
      matches: 2,media: 1,
      mode: 1,my: 1,
      of: 1,or: 2,output: 1,over: 1,
      patterns: 2,pcre: 1,plain: 1,proudly: 1,
      reference: 1,regex: 1,regexr: 1,replace: 1,results: 2,roll: 1,
      save: 1,see: 1,share: 1,side: 1,supported: 1,
      temple: 1,tests: 1,text: 1,the: 5,to: 1,tools: 1,
      validate: 1,view: 1,
      was: 1,with: 3,
      you: 2,your: 2 
    }
}