/
toTitleCase.ts
44 lines (43 loc) · 1.43 KB
/
toTitleCase.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
36
37
38
39
40
41
42
43
44
import { toTitleCase } from '@terascope/utils';
import { FieldType } from '@terascope/types';
import {
FieldTransformConfig,
ProcessMode,
FunctionDefinitionType,
FunctionDefinitionCategory,
} from '../interfaces';
export const toTitleCaseConfig: FieldTransformConfig = {
name: 'toTitleCase',
type: FunctionDefinitionType.FIELD_TRANSFORM,
process_mode: ProcessMode.INDIVIDUAL_VALUES,
category: FunctionDefinitionCategory.STRING,
description: 'Converts one or more words into a whitespace separated string with each word starting with a capital letter',
examples: [
{
args: {},
config: { version: 1, fields: { testField: { type: FieldType.String } } },
field: 'testField',
input: 'HELLO there',
output: 'HELLO There'
},
{
args: {},
config: { version: 1, fields: { testField: { type: FieldType.String } } },
field: 'testField',
input: 'billy',
output: 'Billy',
},
{
args: {},
config: { version: 1, fields: { testField: { type: FieldType.String } } },
field: 'testField',
input: 'Hey There',
output: 'Hey There'
},
],
create() {
// toTitleCase handles cases input is not string
return (input: unknown) => toTitleCase(input as string);
},
accepts: [FieldType.String],
};