wrap non-arrays/strings/falsys in an array in util.list - fixes babel/babelify#69
This commit is contained in:
parent
b7a08100a6
commit
c715d96e46
@ -59,8 +59,10 @@ export function list(val: string): Array<string> {
|
|||||||
return [];
|
return [];
|
||||||
} else if (Array.isArray(val)) {
|
} else if (Array.isArray(val)) {
|
||||||
return val;
|
return val;
|
||||||
} else {
|
} else if (typeof val === "string") {
|
||||||
return val.split(",");
|
return val.split(",");
|
||||||
|
} else {
|
||||||
|
return [val];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -58,6 +58,10 @@ suite("util", function () {
|
|||||||
assert.deepEqual(util.list("foo"), ["foo"]);
|
assert.deepEqual(util.list("foo"), ["foo"]);
|
||||||
assert.deepEqual(util.list("foo,bar"), ["foo", "bar"]);
|
assert.deepEqual(util.list("foo,bar"), ["foo", "bar"]);
|
||||||
assert.deepEqual(util.list(["foo", "bar"]), ["foo", "bar"]);
|
assert.deepEqual(util.list(["foo", "bar"]), ["foo", "bar"]);
|
||||||
|
assert.deepEqual(util.list(/foo/), [/foo/]);
|
||||||
|
|
||||||
|
var date = new Date;
|
||||||
|
assert.deepEqual(util.list(date), [date]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("arrayify", function () {
|
test("arrayify", function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user