MCPcopy Create free account
hub / github.com/abaplint/transpiler / set

Method set

packages/runtime/src/types/xstring.ts:29–57  ·  view source on GitHub ↗
(value: ICharacter | INumeric | string | number)

Source from the content-addressed store, hash-verified

27 }
28
29 public set(value: ICharacter | INumeric | string | number) {
30 if (typeof value === "string") {
31 // the input is interpreted as hexadecimal digits, the conversion stops at
32 // the first character which is not an uppercase hex digit
33 this.value = /^[0-9A-F]*/.exec(value)?.[0] || "";
34 if (this.value.length % 2 === 1) {
35 this.value = this.value + "0";
36 }
37 } else if (typeof value === "number") {
38 this.value = Math.round(value).toString(16).toUpperCase();
39 if (this.value.length % 2 === 1) {
40 this.value = "0" + this.value;
41 }
42 } else {
43 let v = value.get();
44 if (value instanceof Float) {
45 v = value.getRaw();
46 this.set(v);
47 } else if (value instanceof Character) {
48 this.set(value.getTrimEnd());
49 } else if (typeof v === "number") {
50 this.value = v.toString(16).toUpperCase();
51 if (this.value.length % 2 === 1) {
52 this.value = "0" + this.value;
53 }
54 } else {
55 this.set(v);
56 }
57 }
58 return this;
59 }
60

Callers 3

bitorFunction · 0.95
bitandFunction · 0.95
bitxorFunction · 0.95

Calls 5

toStringMethod · 0.80
roundMethod · 0.80
getTrimEndMethod · 0.80
getMethod · 0.65
getRawMethod · 0.45

Tested by

no test coverage detected