Skip to content
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

Merged
merged 1 commit into from
Mar 28, 2017
Merged

Conversation

Haroenv
Copy link
Collaborator

@Haroenv Haroenv commented Mar 28, 2017

fixes #33

formatPkg.js Outdated
@@ -58,11 +58,17 @@ export default function formatPkg(pkg) {
}

const dependencies = cleaned.dependencies || {};
const charsToSplit = /[-/@_.]+/;
Copy link
Collaborator Author

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,
Copy link

@iam4x iam4x Mar 28, 2017

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@Haroenv
Copy link
Collaborator Author

Haroenv commented Mar 28, 2017

I removed numberOfWordsInName because it's not useful anymore when the concatenated name strategy is used.

@Haroenv Haroenv requested a review from vvo March 28, 2017 13:22
@Haroenv Haroenv merged commit d0ebb97 into master Mar 28, 2017
@Haroenv Haroenv deleted the feat/add-concatenated-name branch March 28, 2017 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add alternative name without dashes
2 participants