@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
@@ -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":
|
package/source/types/version.mjs
CHANGED
@@ -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],
|
package/test/cases/monster.mjs
CHANGED