1 | import { factory } from '../../utils/factory'
|
2 | import { deepMap } from '../../utils/collection'
|
3 | import { cscNumber } from '../../plain/number'
|
4 |
|
5 | const name = 'csc'
|
6 | const dependencies = ['typed', 'BigNumber']
|
7 |
|
8 | export const createCsc = factory(name, dependencies, ({ typed, BigNumber }) => {
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | return typed(name, {
|
31 | number: cscNumber,
|
32 |
|
33 | Complex: function (x) {
|
34 | return x.csc()
|
35 | },
|
36 |
|
37 | BigNumber: function (x) {
|
38 | return new BigNumber(1).div(x.sin())
|
39 | },
|
40 |
|
41 | Unit: function (x) {
|
42 | if (!x.hasBase(x.constructor.BASE_UNITS.ANGLE)) {
|
43 | throw new TypeError('Unit in function csc is no angle')
|
44 | }
|
45 | return this(x.value)
|
46 | },
|
47 |
|
48 | 'Array | Matrix': function (x) {
|
49 | return deepMap(x, this)
|
50 | }
|
51 | })
|
52 | })
|