@schukai/monster 3.17.0 → 3.18.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schukai/monster",
3
- "version": "3.17.0",
3
+ "version": "3.18.0",
4
4
  "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
5
5
  "keywords": [
6
6
  "framework",
@@ -186,6 +186,33 @@ function transform(value) {
186
186
  case "tolowercase":
187
187
  validateString(value);
188
188
  return value.toLowerCase();
189
+
190
+ case "contains":
191
+ if (isString(value)) {
192
+ return value.includes(args[0]);
193
+ }
194
+
195
+ if (isArray(value)) {
196
+ return value.includes(args[0]);
197
+ }
198
+
199
+ if (isObject(value)) {
200
+ return value.hasOwnProperty(args[0]);
201
+ }
202
+
203
+ return false;
204
+
205
+ case "has-entries":
206
+ case "hasentries":
207
+ if (isObject(value)) {
208
+ return Object.keys(value).length > 0;
209
+ }
210
+
211
+ if (isArray(value)) {
212
+ return value.length > 0;
213
+ }
214
+
215
+ return false;
189
216
 
190
217
  case "isundefined":
191
218
  case "is-undefined":
@@ -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.17.0");
145
+ monsterVersion = new Version("3.18.0");
146
146
 
147
147
  return monsterVersion;
148
148
  }
@@ -28,6 +28,18 @@ describe('Transformer', function () {
28
28
  describe('Transformer.run()', function () {
29
29
 
30
30
  [
31
+ ['has-entries', {}, false],
32
+ ['has-entries', {a:4}, true],
33
+ ['has-entries', [], false],
34
+ ['has-entries', "", false],
35
+ ['has-entries', [1,2,3], true],
36
+ ['has-entries', [1], true],
37
+ ['has-entries', ["1"], true],
38
+ ['has-entries', [true], true],
39
+ ['contains:x', "asd wxd sdf", true],
40
+ ['contains:x', "asd wd sdf", false],
41
+ ['contains:b', ["a","b","c"], true],
42
+ ['contains:x', ["a","b","c"], false],
31
43
  ['isundefined', "a", false],
32
44
  ['isundefined', null, false],
33
45
  ['isundefined', undefined, true],
@@ -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.17.0")
10
+ monsterVersion = new Version("3.18.0")
11
11
 
12
12
  let m = getMonsterVersion();
13
13