-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathor.transform.js
More file actions
23 lines (18 loc) · 840 Bytes
/
or.transform.js
File metadata and controls
23 lines (18 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { createOr } from '../../function/logical/or.js'
import { factory } from '../../utils/factory.js'
import { isCollection } from '../../utils/is.js'
const name = 'or'
const dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', 'concat']
export const createOrTransform = /* #__PURE__ */ factory(name, dependencies, ({ typed, matrix, equalScalar, DenseMatrix, concat }) => {
const or = createOr({ typed, matrix, equalScalar, DenseMatrix, concat })
function orTransform (args, math, scope) {
const condition1 = args[0].compile().evaluate(scope)
if (!isCollection(condition1) && or(condition1, false)) {
return true
}
const condition2 = args[1].compile().evaluate(scope)
return or(condition1, condition2)
}
orTransform.rawArgs = true
return orTransform
}, { isTransformFunction: true })