affinirum 1.2.5 → 1.2.8

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/README.md CHANGED
@@ -58,6 +58,7 @@ A function is a callable code unit that produces a value.
58
58
  The set of built-in functions can be extended through configuration entries.
59
59
  Additionally, subroutines (functions defined in code) can be created.
60
60
 
61
+ ### Variables
61
62
  Valid variable and function names must start with a letter, number sign (**\#**), dollar sign (**\$**), or underscore (**\_**)
62
63
  and can be followed by any combination of alphanumeric characters, number signs, dollar signs, or underscores,
63
64
  like *x*, *\_a1$*, *abc25*.
@@ -77,7 +78,7 @@ Whitespace characters are ignored.
77
78
  - **function** for built-in, injected or script-defined subroutines
78
79
 
79
80
  Type modifier **?** can be used to make any type optional (nullable).
80
- <br>Examples: *float? optNumVar*, *array? optArrayVar*
81
+ <br>Examples: *float?*, *array?*
81
82
 
82
83
  Unknown or variant type is declared as **??**.
83
84
 
@@ -129,7 +130,7 @@ Unknown or variant type is declared as **??**.
129
130
  - **boolean Boolean.And(values: array...)** — Boolean conjunction
130
131
  - **boolean Boolean.Not(value: boolean)** — Boolean negation
131
132
  - **boolean? Boolean.Decode(value: buffer, offset: integer?)** — Decode boolean from buffer
132
- - **boolean? Boolean.ParseBoolean()** — Parse boolean from string
133
+ - **boolean? Boolean.Parse()** — Parse boolean from string
133
134
 
134
135
  #### Timestamp
135
136
  - **timestamp Timestamp.Now()** — Current date and time
@@ -170,7 +171,7 @@ Unknown or variant type is declared as **??**.
170
171
 
171
172
  #### Buffer
172
173
  - **buffer Buffer.Random(length: integer)** — Buffer of given length filled with random bytes
173
- - **buffer? Buffer.ParseBuffer(value: string)** — Parse buffer from hexadecimal string
174
+ - **buffer? Buffer.Parse(value: string)** — Parse buffer from hexadecimal string
174
175
 
175
176
  #### Array
176
177
  - **array Array.Join(values: array...)** — Join arrays of any depths into a single array
@@ -54,6 +54,13 @@ export declare class Affinirum {
54
54
  @returns Calculated value.
55
55
  */
56
56
  evaluate(values?: Record<string, Value>): Value;
57
+ /**
58
+ Produces string in Affinirum Notation.
59
+ @param value Value to format.
60
+ @param whitespace Optional white space characters for readability.
61
+ @returns String formatted in Affinirum Notation.
62
+ */
63
+ static format(value: Value, whitespace?: string): string;
57
64
  protected _list(state: ParserState, scope: StaticScope): Node;
58
65
  protected _unit(state: ParserState, scope: StaticScope): Node;
59
66
  protected _coalescence(state: ParserState, scope: StaticScope): Node;
package/dst/Affinirum.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { formatAN } from "./constant/notation/AN.js";
1
2
  import { funcOr, funcAnd, funcNot } from "./constant/Boolean.js";
2
3
  import { funcAdd } from "./constant/Aggregable.js";
3
4
  import { funcAt, funcHas } from "./constant/Iterable.js";
@@ -117,6 +118,15 @@ export class Affinirum {
117
118
  throw e;
118
119
  }
119
120
  }
121
+ /**
122
+ Produces string in Affinirum Notation.
123
+ @param value Value to format.
124
+ @param whitespace Optional white space characters for readability.
125
+ @returns String formatted in Affinirum Notation.
126
+ */
127
+ static format(value, whitespace) {
128
+ return formatAN(value, whitespace);
129
+ }
120
130
  _list(state, scope) {
121
131
  const frame = state.starts();
122
132
  const subnodes = [];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Affinirum = void 0;
4
+ const AN_js_1 = require("./constant/notation/AN.js");
4
5
  const Boolean_js_1 = require("./constant/Boolean.js");
5
6
  const Aggregable_js_1 = require("./constant/Aggregable.js");
6
7
  const Iterable_js_1 = require("./constant/Iterable.js");
@@ -120,6 +121,15 @@ class Affinirum {
120
121
  throw e;
121
122
  }
122
123
  }
124
+ /**
125
+ Produces string in Affinirum Notation.
126
+ @param value Value to format.
127
+ @param whitespace Optional white space characters for readability.
128
+ @returns String formatted in Affinirum Notation.
129
+ */
130
+ static format(value, whitespace) {
131
+ return (0, AN_js_1.formatAN)(value, whitespace);
132
+ }
123
133
  _list(state, scope) {
124
134
  const frame = state.starts();
125
135
  const subnodes = [];
@@ -30,12 +30,12 @@ const formatAN = (value, whitespace) => {
30
30
  if (Array.isArray(value)) {
31
31
  const [prefix, suffix] = whitespace ? ["\n" + whitespace, "\n"] : ["", ""];
32
32
  const lines = value.map((i) => `${prefix}${(0, exports.formatAN)(i, whitespace).split("\n").join(prefix)}`);
33
- return `[${lines.join(",")}${suffix}]`;
33
+ return lines.length ? `[${lines.join(",")}${suffix}]` : "[]";
34
34
  }
35
35
  if (typeof value === "object") {
36
- const [prefix, suffix] = whitespace ? ["\n" + whitespace, "\n"] : ["", ""];
37
- const lines = Object.entries(value).map(([k, v]) => `${prefix}"${k}":${(0, exports.formatAN)(v, whitespace).split("\n").join(prefix)}`);
38
- return `[${lines.join(",")}${suffix}]`;
36
+ const [prefix, suffix, separator] = whitespace ? ["\n" + whitespace, "\n", ": "] : ["", "", ":"];
37
+ const lines = Object.entries(value).map(([k, v]) => `${prefix}"${k}"${separator}${(0, exports.formatAN)(v, whitespace).split("\n").join(prefix)}`);
38
+ return lines.length ? `[${lines.join(",")}${suffix}]` : "[:]";
39
39
  }
40
40
  return "function";
41
41
  };
@@ -27,12 +27,12 @@ export const formatAN = (value, whitespace) => {
27
27
  if (Array.isArray(value)) {
28
28
  const [prefix, suffix] = whitespace ? ["\n" + whitespace, "\n"] : ["", ""];
29
29
  const lines = value.map((i) => `${prefix}${formatAN(i, whitespace).split("\n").join(prefix)}`);
30
- return `[${lines.join(",")}${suffix}]`;
30
+ return lines.length ? `[${lines.join(",")}${suffix}]` : "[]";
31
31
  }
32
32
  if (typeof value === "object") {
33
- const [prefix, suffix] = whitespace ? ["\n" + whitespace, "\n"] : ["", ""];
34
- const lines = Object.entries(value).map(([k, v]) => `${prefix}"${k}":${formatAN(v, whitespace).split("\n").join(prefix)}`);
35
- return `[${lines.join(",")}${suffix}]`;
33
+ const [prefix, suffix, separator] = whitespace ? ["\n" + whitespace, "\n", ": "] : ["", "", ":"];
34
+ const lines = Object.entries(value).map(([k, v]) => `${prefix}"${k}"${separator}${formatAN(v, whitespace).split("\n").join(prefix)}`);
35
+ return lines.length ? `[${lines.join(",")}${suffix}]` : "[:]";
36
36
  }
37
37
  return "function";
38
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "affinirum",
3
- "version": "1.2.5",
3
+ "version": "1.2.8",
4
4
  "description": "Affinirum Scripting Language",
5
5
  "main": "dst/cjs/index.js",
6
6
  "module": "dst/index.js",
@@ -56,12 +56,12 @@
56
56
  },
57
57
  "dependencies": {},
58
58
  "devDependencies": {
59
- "@types/jasmine": "~5.1.15",
59
+ "@types/jasmine": "~6.0.0",
60
60
  "copyfiles": "~2.4.1",
61
- "eslint": "~9.39.2",
62
- "jasmine": "~5.13.0",
61
+ "eslint": "~8.57.0",
62
+ "jasmine": "~6.0.0",
63
63
  "rimraf": "~6.1.2",
64
64
  "typescript": "~5.9.3",
65
- "typescript-eslint": "~8.53.0"
65
+ "typescript-eslint": "~8.54.0"
66
66
  }
67
67
  }