Skip to content

Commit 4ae8563

Browse files
committed
keep lib/make-array because it's present in the classic AMD bundles
1 parent d264bf4 commit 4ae8563

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
const { isArray } = Array;
2+
/**
3+
@module @ember/array
4+
*/
5+
/**
6+
Forces the passed object to be part of an array. If the object is already
7+
an array, it will return the object. Otherwise, it will add the object to
8+
an array. If object is `null` or `undefined`, it will return an empty array.
9+
10+
```javascript
11+
import { makeArray } from '@ember/array';
12+
import ArrayProxy from '@ember/array/proxy';
13+
14+
makeArray(); // []
15+
makeArray(null); // []
16+
makeArray(undefined); // []
17+
makeArray('lindsay'); // ['lindsay']
18+
makeArray([1, 2, 42]); // [1, 2, 42]
19+
20+
let proxy = ArrayProxy.create({ content: [] });
21+
22+
makeArray(proxy) === proxy; // false
23+
```
24+
25+
@method makeArray
26+
@static
27+
@for @ember/array
28+
@param {Object} obj the object
29+
@return {Array}
30+
@private
31+
*/
32+
function makeArray<T, TT>(obj: T): T extends TT[] ? T : T extends null | undefined ? [] : [T];
33+
function makeArray(obj: any | null | undefined): Array<any | null | undefined> {
34+
if (obj === null || obj === undefined) {
35+
return [];
36+
}
37+
return isArray(obj) ? obj : [obj];
38+
}
39+
40+
export default makeArray;

packages/@ember/array/make.ts

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1 @@
1-
const { isArray } = Array;
2-
/**
3-
@module @ember/array
4-
*/
5-
/**
6-
Forces the passed object to be part of an array. If the object is already
7-
an array, it will return the object. Otherwise, it will add the object to
8-
an array. If object is `null` or `undefined`, it will return an empty array.
9-
10-
```javascript
11-
import { makeArray } from '@ember/array';
12-
import ArrayProxy from '@ember/array/proxy';
13-
14-
makeArray(); // []
15-
makeArray(null); // []
16-
makeArray(undefined); // []
17-
makeArray('lindsay'); // ['lindsay']
18-
makeArray([1, 2, 42]); // [1, 2, 42]
19-
20-
let proxy = ArrayProxy.create({ content: [] });
21-
22-
makeArray(proxy) === proxy; // false
23-
```
24-
25-
@method makeArray
26-
@static
27-
@for @ember/array
28-
@param {Object} obj the object
29-
@return {Array}
30-
@private
31-
*/
32-
function makeArray<T, TT>(obj: T): T extends TT[] ? T : T extends null | undefined ? [] : [T];
33-
function makeArray(obj: any | null | undefined): Array<any | null | undefined> {
34-
if (obj === null || obj === undefined) {
35-
return [];
36-
}
37-
return isArray(obj) ? obj : [obj];
38-
}
39-
40-
export default makeArray;
1+
export { default } from './lib/make-array';

0 commit comments

Comments
 (0)