forked from josdejong/mathjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitOr.transform.js
More file actions
31 lines (26 loc) · 1002 Bytes
/
bitOr.transform.js
File metadata and controls
31 lines (26 loc) · 1002 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
26
27
28
29
30
31
import { createBitOr } from '../../function/bitwise/bitOr.js'
import { factory } from '../../utils/factory.js'
import { isCollection } from '../../utils/is.js'
const name = 'bitOr'
const dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', 'concat']
export const createBitOrTransform = /* #__PURE__ */ factory(name, dependencies, ({ typed, matrix, equalScalar, DenseMatrix, concat }) => {
const bitOr = createBitOr({ typed, matrix, equalScalar, DenseMatrix, concat })
function bitOrTransform (args, math, scope) {
const condition1 = args[0].compile().evaluate(scope)
if (!isCollection(condition1)) {
if (isNaN(condition1)) {
return NaN
}
if (condition1 === (-1)) {
return -1
}
if (condition1 === true) {
return 1
}
}
const condition2 = args[1].compile().evaluate(scope)
return bitOr(condition1, condition2)
}
bitOrTransform.rawArgs = true
return bitOrTransform
}, { isTransformFunction: true })