-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(data): add concatenated name #34
Conversation
formatPkg.js
Outdated
@@ -58,11 +58,17 @@ export default function formatPkg(pkg) { | |||
} | |||
|
|||
const dependencies = cleaned.dependencies || {}; | |||
const charsToSplit = /[-/@_.]+/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added .
to split on here too
formatPkg.js
Outdated
|
||
const rawPkg = { | ||
objectID: cleaned.name, | ||
name: cleaned.name, | ||
numberOfWordsInName: cleaned.name.split(/[-/@_]+/).length, | ||
concatenatedName, | ||
numberOfWordsInName: cleaned.name.split(charsToSplit).length, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'r-a-b-c'.split(/[-/@_.]+/g)
-> (4) ["r", "a", "b", "c"]
So you can directly do, instead of calling a new RegExp()
constructor 👍
const charsToSplit = /[-/@_.]+/g;
const concatenatedName = cleaned.name.replace(charsToSplit, '');
[..]
numberOfWordsInName: cleaned.name.split(charsToSplit).length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
e40b71c
to
72ab12e
Compare
I removed |
fixes #33