-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
25 lines (23 loc) · 659 Bytes
/
main.ts
File metadata and controls
25 lines (23 loc) · 659 Bytes
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
import { IMethod, ISource } from "./types"
const createMethod = (source : ISource, name: string, method: IMethod): void => {
switch(typeof source) {
case "string": {
String.prototype[name] = method
break
}
case "number": {
Number.prototype[name] = method
break
}
case "boolean": {
Boolean.prototype[name] = method
break
}
case "object": {
if ((source as any).isArray()) Array.prototype[name] = method
else Object.prototype[name] = method
break
}
}
}
export default createMethod