Skip to content

Commit 75d5f3c

Browse files
committed
Allow empty strings in first position of input. Fix #4
1 parent cf8b4ad commit 75d5f3c

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

index.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,10 @@ function replaceString(str, match, fn) {
5353
return result;
5454
}
5555

56-
module.exports = function reactStringReplace(str, match, fn) {
57-
if (isString(str)) {
58-
str = [str];
59-
}
60-
61-
if (!isArray(str) || !str[0]) {
62-
throw new TypeError('First argument to react-string-replace must be an array or non-empty string');
63-
}
56+
module.exports = function reactStringReplace(source, match, fn) {
57+
if (!isArray(source)) source = [source];
6458

65-
return flatten(str.map(function(x) {
59+
return flatten(source.map(function(x) {
6660
return isString(x) ? replaceString(x, match, fn) : x;
6761
}));
6862
};

0 commit comments

Comments
 (0)