funcity 0.9.0 → 1.0.0

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
@@ -68,7 +68,7 @@ const text = await runScriptOnceToText(script, variables, logs);
68
68
  console.log(text);
69
69
  ```
70
70
 
71
- In other words, Funcity is a processing system that brings the power of functional programming to text template processors, enabling seamless integration into applications!
71
+ In other words, funcity is a processing system that brings the power of functional programming to text template processors, enabling seamless integration into applications!
72
72
 
73
73
  ### Features
74
74
 
package/dist/index.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: funcity
3
- * version: 0.9.0
3
+ * version: 1.0.0
4
4
  * description: A functional language interpreter with text processing
5
5
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
6
6
  * license: MIT
7
7
  * repository.url: https://github.com/kekyo/funcity
8
- * git.commit.hash: 44d20b9861b32b8f70452b8a5bd2a39e3484ba26
8
+ * git.commit.hash: af915b0e39fdf322e1c830e97cc77121ffca2d83
9
9
  */
10
10
 
11
11
  "use strict";
@@ -284,6 +284,16 @@ const tokenizeCodeTokens = (context, stopOnClose, finalizeUnknownOnEot) => {
284
284
  const location = context.cursor.location("start");
285
285
  tokens.push({
286
286
  kind: "eol",
287
+ source: "newline",
288
+ range: { start: location, end: location }
289
+ });
290
+ context.cursor.skip(1);
291
+ } else if (ch === ";") {
292
+ finalizeUnknown();
293
+ const location = context.cursor.location("start");
294
+ tokens.push({
295
+ kind: "eol",
296
+ source: "semicolon",
287
297
  range: { start: location, end: location }
288
298
  });
289
299
  context.cursor.skip(1);
@@ -965,6 +975,14 @@ const parseListExpression = (cursor, logs) => {
965
975
  }
966
976
  switch (token.kind) {
967
977
  case "eol": {
978
+ cursor.skipToken();
979
+ if (token.source === "semicolon") {
980
+ logs.push({
981
+ type: "error",
982
+ description: "Semicolon is not allowed in list expression",
983
+ range: token.range
984
+ });
985
+ }
968
986
  continue;
969
987
  }
970
988
  }
@@ -2026,29 +2044,37 @@ const _ge = async (arg0, arg1) => {
2026
2044
  const _now = async () => {
2027
2045
  return /* @__PURE__ */ new Date();
2028
2046
  };
2029
- const concatInner = (args) => {
2047
+ const concatInner = (sep, args) => {
2030
2048
  let v = "";
2049
+ let f = true;
2031
2050
  for (const arg of args) {
2051
+ let as;
2032
2052
  if (typeof arg === "string") {
2033
- v = v + arg;
2053
+ as = arg;
2034
2054
  } else {
2035
2055
  const iterable = asIterable(arg);
2036
2056
  if (iterable) {
2037
- v = v + concatInner(iterable);
2057
+ as = concatInner(sep, iterable);
2038
2058
  } else {
2039
- v = v + String(arg);
2059
+ as = convertToString(arg);
2040
2060
  }
2041
2061
  }
2062
+ if (f) {
2063
+ v = v + as;
2064
+ f = false;
2065
+ } else {
2066
+ v = v + sep + as;
2067
+ }
2042
2068
  }
2043
2069
  return v;
2044
2070
  };
2045
2071
  const _concat = async (...args) => {
2046
- const r = concatInner(args);
2072
+ const r = concatInner("", args);
2047
2073
  return r;
2048
2074
  };
2049
2075
  const _join = async (arg0, ...args) => {
2050
- const sep = String(arg0);
2051
- const r = args.map((v) => String(v)).join(sep);
2076
+ const sep = convertToString(arg0);
2077
+ const r = concatInner(sep, args);
2052
2078
  return r;
2053
2079
  };
2054
2080
  const _trim = async (arg0) => {
@@ -2266,22 +2292,22 @@ const _reduce = async (arg0, arg1, arg2) => {
2266
2292
  return acc;
2267
2293
  };
2268
2294
  const _match = async (arg0, arg1) => {
2269
- const re = arg0 instanceof RegExp ? arg0 : new RegExp(String(arg0), "g");
2270
- const results = String(arg1).match(re);
2295
+ const re = arg0 instanceof RegExp ? arg0 : new RegExp(convertToString(arg0), "g");
2296
+ const results = convertToString(arg1).match(re);
2271
2297
  return results;
2272
2298
  };
2273
2299
  const _replace = async (arg0, arg1, arg2) => {
2274
- const re = arg0 instanceof RegExp ? arg0 : new RegExp(String(arg0), "g");
2275
- const replace = String(arg1);
2276
- const results = String(arg2).replace(re, replace);
2300
+ const re = arg0 instanceof RegExp ? arg0 : new RegExp(convertToString(arg0), "g");
2301
+ const replace = convertToString(arg1);
2302
+ const results = convertToString(arg2).replace(re, replace);
2277
2303
  return results;
2278
2304
  };
2279
2305
  const _regex = async (arg0, arg1) => {
2280
2306
  if (arg1) {
2281
- const re = new RegExp(String(arg0), String(arg1));
2307
+ const re = new RegExp(convertToString(arg0), convertToString(arg1));
2282
2308
  return re;
2283
2309
  } else {
2284
- const re = new RegExp(String(arg0));
2310
+ const re = new RegExp(convertToString(arg0));
2285
2311
  return re;
2286
2312
  }
2287
2313
  };
@@ -2387,7 +2413,8 @@ const standardVariables = Object.freeze({
2387
2413
  regex: _regex,
2388
2414
  bind: _bind,
2389
2415
  url: _url,
2390
- delay: _delay
2416
+ delay: _delay,
2417
+ console
2391
2418
  });
2392
2419
  const buildCandidateVariables = (...variablesList) => {
2393
2420
  return combineVariables(standardVariables, ...variablesList);