UNPKG

689 BPlain TextView Raw
1import sortBy from './index'
2
3// OK
4sortBy(['a', 'b', 'c']);
5sortBy([1, 2, 3]);
6sortBy([{name: 'claudio'}, {name: 'klaus'}]);
7sortBy([{name: 'claudio'}, {name: 'klaus'}], 'name');
8sortBy([
9 {user: 'fabio', details: {city: "Milan", age: 34}},
10 {user: 'max', details: {city: "Munich", age: 29}},
11 {user: 'zacarias', details: {city: "Sao Paulo", age: 44}},
12], function(o) {
13 return o.details.age;
14});
15
16// NOT OK
17// @ts-expect-error
18sortBy();
19// @ts-expect-error
20sortBy({});
21// @ts-expect-error
22sortBy({}, 'name');
23// @ts-expect-error
24sortBy({}, function(){});
25// @ts-expect-error
26sortBy([1, 2, 3], 1);
27// @ts-expect-error
28sortBy([1, 2, 3], []);
29// @ts-expect-error
30sortBy([1, 2, 3], {});