extractwords
Advanced tools
Comparing version 1.2.0 to 2.0.0
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" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9337
Yes
11
62
1
1