diff --git a/CHANGELOG.md b/CHANGELOG.md index 10bd6539eb..69cdfeec19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ _Note: Gaps between patch versions are faulty/broken releases._ See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog. +## 5.2.2 + + * **Internal** + * Allow `util.arrayify` to take arbitrary types and coerce it into an array. + ## 5.2.1 * **Bug Fix** diff --git a/src/babel/util.js b/src/babel/util.js index 3f6e12e756..8304d6e17c 100644 --- a/src/babel/util.js +++ b/src/babel/util.js @@ -88,7 +88,7 @@ export function arrayify(val: any, mapFn?: Function): Array { return val; } - throw new TypeError("illegal type for arrayify"); + return [val]; } export function booleanify(val: any): boolean { diff --git a/test/core/util.js b/test/core/util.js index 13df528b74..d299ef04e6 100644 --- a/test/core/util.js +++ b/test/core/util.js @@ -72,10 +72,7 @@ suite("util", function () { assert.deepEqual(util.arrayify("foo"), ["foo"]); assert.deepEqual(util.arrayify("foo,bar"), ["foo", "bar"]); assert.deepEqual(util.arrayify(["foo", "bar"]), ["foo", "bar"]); - - assert.throws(function () { - util.arrayify({}); - }, /illegal type for arrayify/); + assert.deepEqual(util.arrayify({ foo: "bar" }), [{ foo: "bar" }]); }); test("regexify", function () {