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

Substr #10

Merged
merged 8 commits into from
Apr 30, 2017
Merged

Substr #10

merged 8 commits into from
Apr 30, 2017

Conversation

nainemom
Copy link
Contributor

As you know, the substring and substr function are different. substring parameters are begin and end point from string, but substr accept begin and length. Also some people use substr more than substring (like me), so i write it for stringz.

@codecov-io
Copy link

codecov-io commented Apr 29, 2017

Codecov Report

Merging #10 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #10   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           2      2           
  Lines          28     47   +19     
=====================================
+ Hits           28     47   +19
Impacted Files Coverage Δ
src/index.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e91f751...842330d. Read the comment docs.

@nainemom nainemom closed this Apr 29, 2017
@sallar
Copy link
Owner

sallar commented Apr 29, 2017

@nainemom hi, why did you close the PR? :)

@nainemom
Copy link
Contributor Author

@sallar Hi. I just try to understand why @codecov-io did this to me :D. My code coverege is 97.56% and misses one thing! I opened that again, but how can i do this test, before submitting PR?

@nainemom nainemom reopened this Apr 29, 2017
@sallar
Copy link
Owner

sallar commented Apr 29, 2017

@nainemom when you run yarn test from the command line it will show you the code coverage at the end of the test results. You can fix that and commit and codecov will update here automatically.

@nainemom
Copy link
Contributor Author

@sallar Ok i will fix that :)

@nainemom
Copy link
Contributor Author

@sallar check this again.

Copy link
Owner

@sallar sallar left a comment

Choose a reason for hiding this comment

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

I have requested some (mostly styling) changes. Also please add the proper documentation for this function to README. Thank you.

src/index.js Outdated
}
// Calculating postive version of negative value.
else if(begin < 0) {
begin+= strLength;
Copy link
Owner

Choose a reason for hiding this comment

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

Space needed between begin and +=

src/index.js Outdated
}

let end = undefined;
if(typeof len === "undefined"){
Copy link
Owner

Choose a reason for hiding this comment

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

This whole section needs a bit of reformatting. suggestion:

let end;

if (typeof len === "undefined"){
    end = strLength;
} else {
    // Fix type
    if (typeof len !== "number"){
        len = parseInt(len, 10);
    }

    if (len >= 0) {
        end = len + begin;
    } else {
        end = begin;
    }
}

src/index.js Outdated

// Fix type
if (typeof begin !== "number") {
begin = parseInt(begin);
Copy link
Owner

Choose a reason for hiding this comment

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

parseInt(begin) needs to have a radix of 10. parseInt(begin, 10)

src/index.js Outdated
return "";
}
// Calculating postive version of negative value.
else if(begin < 0) {
Copy link
Owner

Choose a reason for hiding this comment

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

Since the previous if returns something, this doesn't need to be else if and a simple if is enough. Also space needed between if and (. Please use ESLint to see all the styling issues.

src/index.js Outdated
}

// Return zero-length string if got oversize number.
if(begin >= strLength){
Copy link
Owner

Choose a reason for hiding this comment

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

Space needed between if and (;

Copy link
Owner

@sallar sallar left a comment

Choose a reason for hiding this comment

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

👍 Great job.

@sallar sallar merged commit cceec0f into sallar:master Apr 30, 2017
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.

3 participants