allow util.arrayify to take arbitrary types and coerce it into an array - #1398
This commit is contained in:
parent
f3b6f2fc61
commit
d9169a87ad
@ -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.
|
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
|
## 5.2.1
|
||||||
|
|
||||||
* **Bug Fix**
|
* **Bug Fix**
|
||||||
|
|||||||
@ -88,7 +88,7 @@ export function arrayify(val: any, mapFn?: Function): Array {
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new TypeError("illegal type for arrayify");
|
return [val];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function booleanify(val: any): boolean {
|
export function booleanify(val: any): boolean {
|
||||||
|
|||||||
@ -72,10 +72,7 @@ suite("util", function () {
|
|||||||
assert.deepEqual(util.arrayify("foo"), ["foo"]);
|
assert.deepEqual(util.arrayify("foo"), ["foo"]);
|
||||||
assert.deepEqual(util.arrayify("foo,bar"), ["foo", "bar"]);
|
assert.deepEqual(util.arrayify("foo,bar"), ["foo", "bar"]);
|
||||||
assert.deepEqual(util.arrayify(["foo", "bar"]), ["foo", "bar"]);
|
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/);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("regexify", function () {
|
test("regexify", function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user