/
abs.ts
35 lines (34 loc) · 900 Bytes
/
abs.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
35
import { FieldType } from '@terascope/types';
import {
FieldTransformConfig,
ProcessMode,
FunctionDefinitionType,
FunctionDefinitionCategory,
} from '../interfaces';
import { runMathFn } from './utils';
export const absConfig: FieldTransformConfig = {
name: 'abs',
type: FunctionDefinitionType.FIELD_TRANSFORM,
process_mode: ProcessMode.INDIVIDUAL_VALUES,
category: FunctionDefinitionCategory.NUMERIC,
description: 'Returns the absolute value of a number.',
examples: [
{
args: {},
config: {
version: 1,
fields: { testField: { type: FieldType.Byte } }
},
field: 'testField',
input: -1,
output: 1
}
],
create() {
return runMathFn(Math.abs);
},
accepts: [
FieldType.Number,
],
argument_schema: {},
};