Socket
Socket
Sign inDemoInstall

extractwords

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extractwords - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

license

33

index.js

@@ -1,24 +0,13 @@

const defaults = {
lowercase: false,
punctuation: false
};
export default function extractWords(input, { lowercase = false, punctuation = false } = {}) {
if (typeof input !== 'string') {
throw new TypeError(`Expected a string, got ${typeof input}`);
}
module.exports = (string, options = {}) => {
options = {
...defaults,
...options
};
const words = punctuation
? input.match(/\S+/g) || []
: input.match(/[a-zA-Z]+('[a-zA-Z]+)?/g) || [];
let words;
if (options.punctuation) {
words = string.match(/\S+/g) || [];
} else {
words = string.match(/[a-zA-Z]+('[a-zA-Z]+)?/g) || [];
}
if (options.lowercase) {
words = words.map(string => string.toLowerCase());
}
return words;
};
return lowercase
? words.map(str => str.toLowerCase())
: words;
}
{
"name": "extractwords",
"version": "1.2.0",
"version": "2.0.0",
"description": "Extract the words from a string",
"main": "index.js",
"scripts": {
"test": "node test.js && xo index.js"
"license": "CC0-1.0",
"repository": "muhashi/extractwords",
"author": {
"name": "muhashi",
"email": "muhamedoes+muhashi@gmail.com",
"url": "https://muhashi.com"
},
"author": "Faraz",
"type": "module",
"exports": "./index.js",
"sideEffects": false,
"engines": {
"node": ">=8.3.0"
"node": ">=18"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/f-a-r-a-z/extractwords.git"
"scripts": {
"test": "ava"
},

@@ -31,5 +34,6 @@ "files": [

],
"dependencies": {},
"devDependencies": {
"xo": "^0.32.0"
"ava": "^6.1.2"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc