@schukai/monster 3.13.1 → 3.14.1

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": "@schukai/monster",
3
- "version": "3.13.1",
3
+ "version": "3.14.1",
4
4
  "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
5
5
  "keywords": [
6
6
  "framework",
@@ -169,6 +169,13 @@ class RestAPI extends Server {
169
169
  }
170
170
  }
171
171
 
172
+ /**
173
+ * @private
174
+ * @param init
175
+ * @param key
176
+ * @param callback
177
+ * @returns {Promise<string>}
178
+ */
172
179
  function fetchData(init, key, callback) {
173
180
  const self = this;
174
181
  let response;
@@ -53,6 +53,7 @@ class Datasource extends Base {
53
53
  */
54
54
  constructor() {
55
55
  super();
56
+
56
57
  this[internalSymbol] = new ProxyObserver({
57
58
  options: extend({}, this.defaults),
58
59
  });
@@ -8,7 +8,7 @@
8
8
  import {Base} from "../types/base.mjs";
9
9
  import {getGlobal, getGlobalObject} from "../types/global.mjs";
10
10
  import {ID} from "../types/id.mjs";
11
- import {isArray, isObject, isString} from "../types/is.mjs";
11
+ import {isArray, isObject, isString, isPrimitive} from "../types/is.mjs";
12
12
  import {getDocumentTranslations, Translations} from "../i18n/translations.mjs";
13
13
  import {
14
14
  validateFunction,
@@ -397,6 +397,34 @@ function transform(value) {
397
397
 
398
398
  return new Pathfinder(value).exists(key);
399
399
 
400
+ case "concat":
401
+ let pf2 = new Pathfinder(value);
402
+ let concat = "";
403
+ while (args.length > 0) {
404
+ key = args.shift();
405
+ if (key === undefined) {
406
+ throw new Error("missing key parameter");
407
+ }
408
+
409
+ // add empty strings
410
+ if (isString(key)&&key.trim()==="") {
411
+ concat += key;
412
+ continue;
413
+ }
414
+
415
+ if (!pf2.exists(key)) {
416
+ concat += key;
417
+ continue;
418
+ }
419
+ let v = pf2.getVia(key);
420
+ if(!isPrimitive(v)) {
421
+ throw new Error("value is not primitive");
422
+ }
423
+
424
+ concat += v;
425
+ }
426
+
427
+ return concat;
400
428
  case "path":
401
429
  key = args.shift();
402
430
  if (key === undefined) {
@@ -474,7 +502,7 @@ function transform(value) {
474
502
  if (key === undefined) {
475
503
  key = value;
476
504
  }
477
-
505
+
478
506
  defaultValue = args.shift() || undefined;
479
507
  return translations.getText(key, defaultValue);
480
508
 
@@ -142,7 +142,7 @@ function getMonsterVersion() {
142
142
  }
143
143
 
144
144
  /** don't touch, replaced by make with package.json version */
145
- monsterVersion = new Version("3.13.1");
145
+ monsterVersion = new Version("3.14.1");
146
146
 
147
147
  return monsterVersion;
148
148
  }
@@ -27,6 +27,10 @@ describe('Transformer', function () {
27
27
  describe('Transformer.run()', function () {
28
28
 
29
29
  [
30
+ ['concat:a.b.c:test:a.b.d', {a: {b: {c: 4, d: 6}}}, "4test6"],
31
+ ['concat:a.b.c:\\ \\ :a.b.d', {a: {b: {c: 4, d: 6}}}, "4 6"],
32
+ ['concat:a.b.c:,:a.b.d', {a: {b: {c: 4, d: 6}}}, "4,6"],
33
+ ['concat:a.b.c:,:\\ :a.b.d', {a: {b: {c: 4, d: 6}}}, "4, 6"],
30
34
  ['??:a', null, 'a'],
31
35
  ['??:a', undefined, 'a'],
32
36
  ['??:a', 'true', 'true'],
@@ -237,11 +241,11 @@ describe('Transformer', function () {
237
241
  });
238
242
 
239
243
  [
240
- [ 'i18n:test1',"", "xyz"],
241
- [ 'i18n:',"test1", "xyz"], // key by value
242
- [ 'i18n::',"test1", "xyz"], // key by value no default
243
- [ 'i18n::eee',"test2", "eee"], // key by value with default
244
- [ 'i18n::ddd',"test2", "ddd"], // key by value and default
244
+ ['i18n:test1', "", "xyz"],
245
+ ['i18n:', "test1", "xyz"], // key by value
246
+ ['i18n::', "test1", "xyz"], // key by value no default
247
+ ['i18n::eee', "test2", "eee"], // key by value with default
248
+ ['i18n::ddd', "test2", "ddd"], // key by value and default
245
249
 
246
250
  ].forEach(function (data) {
247
251
 
@@ -249,7 +253,7 @@ describe('Transformer', function () {
249
253
  let b = data.shift()
250
254
  let c = data.shift()
251
255
 
252
- it('should transform('+a+').run('+b+') return ' + JSON.stringify(c), function () {
256
+ it('should transform(' + a + ').run(' + b + ') return ' + JSON.stringify(c), function () {
253
257
  const t = new Transformer(a);
254
258
  expect(t.run(b)).to.be.eql(c);
255
259
  });
@@ -7,7 +7,7 @@ describe('Monster', function () {
7
7
  let monsterVersion
8
8
 
9
9
  /** don´t touch, replaced by make with package.json version */
10
- monsterVersion = new Version("3.13.1")
10
+ monsterVersion = new Version("3.14.1")
11
11
 
12
12
  let m = getMonsterVersion();
13
13