Last active
August 29, 2015 13:57
-
-
Save lonnen/9635489 to your computer and use it in GitHub Desktop.
a quick, simple but not very efficient answer to: https://twitter.com/peterbe/status/446139741902086145
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pySplit(str, sep, num) { | |
var pieces = str.split(sep) | |
if (arguments.length < 3) { | |
return pieces; | |
} | |
if (pieces.length < num) { | |
return pieces; | |
} | |
return pieces.slice(0, num).concat(pieces.slice(num).join(sep)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment