@fincity/kirun-js 2.1.2 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fincity/kirun-js",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "Javascript Runtime for Kinetic Instructions",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,59 @@
1
+ import { Schema } from '../../../json/schema/Schema';
2
+ import { SchemaType } from '../../../json/schema/type/SchemaType';
3
+ import { Event } from '../../../model/Event';
4
+ import { EventResult } from '../../../model/EventResult';
5
+ import { FunctionOutput } from '../../../model/FunctionOutput';
6
+ import { FunctionSignature } from '../../../model/FunctionSignature';
7
+ import { Parameter } from '../../../model/Parameter';
8
+ import { Namespaces } from '../../../namespaces/Namespaces';
9
+ import { FunctionExecutionParameters } from '../../../runtime/FunctionExecutionParameters';
10
+ import { AbstractFunction } from '../../AbstractFunction';
11
+
12
+ const VALUE = 'source';
13
+ const DELIMITTER = 'delimiter';
14
+ const OUTPUT = 'result';
15
+
16
+ const SIGNATURE = new FunctionSignature('Join')
17
+ .setNamespace(Namespaces.SYSTEM_ARRAY)
18
+ .setParameters(
19
+ new Map([
20
+ [
21
+ VALUE,
22
+ new Parameter(
23
+ VALUE,
24
+ Schema.ofArray(
25
+ VALUE,
26
+ Schema.of(
27
+ 'each',
28
+ SchemaType.STRING,
29
+ SchemaType.INTEGER,
30
+ SchemaType.LONG,
31
+ SchemaType.DOUBLE,
32
+ SchemaType.FLOAT,
33
+ SchemaType.NULL,
34
+ ),
35
+ ),
36
+ ),
37
+ ],
38
+ [
39
+ DELIMITTER,
40
+ new Parameter(DELIMITTER, Schema.ofString(DELIMITTER).setDefaultValue('')),
41
+ ],
42
+ ]),
43
+ )
44
+ .setEvents(new Map([Event.outputEventMapEntry(new Map([[OUTPUT, Schema.ofString(OUTPUT)]]))]));
45
+
46
+ export class Join extends AbstractFunction {
47
+ public getSignature(): FunctionSignature {
48
+ return SIGNATURE;
49
+ }
50
+
51
+ protected async internalExecute(context: FunctionExecutionParameters): Promise<FunctionOutput> {
52
+ let source: any[] = context?.getArguments()?.get(VALUE);
53
+ let delimitter: string = context?.getArguments()?.get(DELIMITTER);
54
+
55
+ return new FunctionOutput([
56
+ EventResult.outputOf(new Map([[OUTPUT, source.join(delimitter)]])),
57
+ ]);
58
+ }
59
+ }
@@ -30,6 +30,9 @@ export class StringFunctionRepository implements Repository<Function> {
30
30
  (a, b) => a.indexOf(b) != -1,
31
31
  ),
32
32
  AbstractStringFunction.ofEntryAsStringBooleanOutput('EndsWith', (a, b) => a.endsWith(b)),
33
+ AbstractStringFunction.ofEntryAsStringBooleanOutput('StartsWith', (a, b) =>
34
+ a.startsWith(b),
35
+ ),
33
36
  AbstractStringFunction.ofEntryAsStringBooleanOutput(
34
37
  'EqualsIgnoreCase',
35
38
  (a, b) => a.toUpperCase() == b.toUpperCase(),