-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmethod.ts
34 lines (29 loc) · 839 Bytes
/
method.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import type { Interface } from '.';
export class Implementation implements Interface {
/**
* @see {@link Interface.firstOrRest}
* @param {T} value
* @returns {[T]} value packed in array
*/
firstOrRest<T>(value: T): [T];
/**
* @see {@link Interface.firstOrRest}
* @param {*} first
* @param {...T} rest
* @returns {T[]} array of parameters after the first
*/
firstOrRest<T>(first: any, ...rest: T[]): T[];
/**
* @see {@link Interface.firstOrRest}
*/
firstOrRest(first: any, ...rest: any[]): any[] {
return arguments.length > 1 ? rest : [first];
}
}
const { firstOrRest } = Implementation.prototype;
firstOrRest('first');
firstOrRest('first', 'second');
/**
* @see {@link Implementation.firstOrRest}
*/
const firstOrRestFunction = firstOrRest;