Skip to content

reverse function removed from string (try to solve reverse functions problem)#407

Open
Bhavesh-Parmar wants to merge 1 commit into
helpers:masterfrom
Bhavesh-Parmar:master
Open

reverse function removed from string (try to solve reverse functions problem)#407
Bhavesh-Parmar wants to merge 1 commit into
helpers:masterfrom
Bhavesh-Parmar:master

Conversation

@Bhavesh-Parmar

@Bhavesh-Parmar Bhavesh-Parmar commented Mar 26, 2022

Copy link
Copy Markdown

reverse function removed form string because it's overwrite revers function of array
in array reverse function is defined which is used for both string reverse and array reverse so we don't need string revers function because it make problem. it's overwrite array's revers function so when we use reverse function it always call string reverse function and it can't revers array.
String's reverse function

helpers.reverse = function(str) {

helpers.reverse = function(str) { if (!util.isString(str)) return ''; return str.split('').reverse().join(''); };
Array's reverse function
helpers.reverse = function(val) {

helpers.reverse = function(val) { if (Array.isArray(val)) { val.reverse(); return val; } if (val && typeof val === 'string') { return val.split('').reverse().join(''); } };

@HardikKaliyani

Copy link
Copy Markdown

Yes we actually need to fix this problem

@Bhavesh-Parmar Bhavesh-Parmar changed the title revers function removed from string reverse function removed from string (try to solve reverse functions problem) Mar 28, 2022
@demius

demius commented Apr 1, 2022

Copy link
Copy Markdown

Can this please be merged in? Is this repo still being maintained at all?

@jonschlinkert

Copy link
Copy Markdown
Member

@demius, this is you, right?

image

@VijaytParmar

Copy link
Copy Markdown

This is actually create a problem...
Need to merged this...

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.

5 participants