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

Add code to handle replacing $eye variables in case the eyes are not … #43

Merged
merged 2 commits into from
Nov 5, 2018

Conversation

jasonkhanlar
Copy link
Contributor

Add code to handle replacing $eye variables in case the eyes are not adjacent to each other

@jasonkhanlar
Copy link
Contributor Author

Note, the /g in the regex is not included, so that only the first instance of $eye is replaced with the first character of $eyes, and second instance of $eye is replaced with the second character of $eyes.

lib/replacer.js Outdated
@@ -1,5 +1,7 @@
module.exports = function (cow, variables) {
var eyes = escapeRe(variables.eyes);
var eyeL = eyes.substr(0,1);
Copy link
Owner

Choose a reason for hiding this comment

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

From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr

screen shot 2018-11-02 at 16 07 23

Can you please use eyeL = eyes.charAt(0); and eyeR = eyes.charAt(1); it's more readable.

@piuccio
Copy link
Owner

piuccio commented Nov 2, 2018

Looks good, I was wondering if we should support any number of eyes but I guess all files have 2 eyes

@piuccio piuccio merged commit df5cdf6 into piuccio:master Nov 5, 2018
ofarukcaki pushed a commit to ofarukcaki/cowsay that referenced this pull request Jul 29, 2023
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.

2 participants