|
| 1 | +@use '../get/get.bool.function' as bool; |
| 2 | +@use '../get/get.list.function' as list; |
| 3 | +@use '../get/get.map.function' as map; |
| 4 | +@use '../get/get.number.function' as number; |
| 5 | +@use '../get/get.string.function' as string; |
| 6 | +@use '../get/get.type.function' as type; |
| 7 | + |
| 8 | +// |
| 9 | +@use '../get'; |
| 10 | + |
| 11 | +// Examples `bool`. |
| 12 | +@debug get.bool(('a', 'b', false, 'c', 2)); // `false` |
| 13 | +@debug get.bool(('a', 'b', true, 'c', 2)); // `true` |
| 14 | +@debug get.bool(('a', 'b', 'c', (true, '5', (6,)))); // `null` |
| 15 | +@debug get.bool(('a', 'b', true, 'c', 2), any); // `true` |
| 16 | +@debug get.bool(('a', 'b', true, 'c', 2), first); // `true` |
| 17 | +@debug get.bool(('a', 'b', false, 'c', 2, true), any); // `false` |
| 18 | +@debug get.bool(('a', 'b', false, 'c', 2, true), last); // `true` |
| 19 | +@debug get.bool(('a', 'b', false, 'c', 2, true), first); // `false` |
| 20 | + |
| 21 | + |
| 22 | +// Examples `list`. |
| 23 | +@debug get.list(('a', 'b', 'c')); // `null` |
| 24 | + |
| 25 | +// fist/any |
| 26 | +@debug get.list(('a', 'b', 'c', ('d', 'e', 'f'))); // ("d", "e", "f") |
| 27 | +@debug get.list(('a', 'b', 'c', ('d', 'e', 'f'), 132, ('a', 'd', 'f')), any); // "d", "e", "f" |
| 28 | + |
| 29 | +// all |
| 30 | +@debug get.list(('a', 'b', 'c', ('d', 'e', 'f'), 'g', 'h', (1, 2, 3)), all); // ("d", "e", "f"), (1, 2, 3) |
| 31 | +@debug get.list(('a', 'b', 'c', ('d', (1, 2, 3, (4, 5, 6)), 'e', 'f')), all); // ("d", (1, 2, 3, (4, 5, 6)), "e", "f") |
| 32 | + |
| 33 | +// last |
| 34 | +@debug get.list(('a', 'b', 'c', ('d', 'e', 'f'), 132, ('a', 'd', 'f')), last); // "a", "d", "f" |
| 35 | + |
| 36 | + |
| 37 | +// Examples `map`. |
| 38 | +// none |
| 39 | +@debug get.map(('a', 'b', 'c')); // null |
| 40 | + |
| 41 | +// first |
| 42 | +@debug get.map(('a', 'b', 'c', ('d': 1, 'e': 2, 'f': 3))); // ("d": 1, "e": 2, "f": 3) |
| 43 | +@debug get.map(('a', 'b', 'c', (('d': 1, 'e': 2, 'f': 3), 'g'), 'h')); // null |
| 44 | +@debug get.map(('a', ('d': 1, 'e': 2, 'f': 3), 'b', 'c', ('d', ('g': 1, 'h': 2, 'i': 3), (1, 2, 3, (4, 5, 6)), 'e', 'f'))); // ("d": 1, "e": 2, "f": 3) |
| 45 | + |
| 46 | +// all |
| 47 | +@debug get.map(('a', (test: 2, test3: 45), 'b', 'c', ('d': 1, 'e': 2, 'f': 3)), all); // (test: 2, test3: 45), ("d": 1, "e": 2, "f": 3) |
| 48 | +@debug get.map(('a', 'b', 'c', ('d': 1, 'e': 2, 'f': 3), 'g', 'h', ('1': 'd', '2': 'e', '3': 'f')), all); // ("d": 1, "e": 2, "f": 3), ("1": "d", "2": "e", "3": "f") |
| 49 | + |
| 50 | +// last |
| 51 | +@debug get.map(('a', (test: 2, test3: 45), 'b', 'c', ('d': 1, 'e': 2, 'f': 3)), last); // ("d": 1, "e": 2, "f": 3) |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +// Examples `number`. |
| 56 | +// occurrence: first by default |
| 57 | +@debug get.number(('a', 'b', 'c', 2)); // `2` |
| 58 | +@debug get.number(('a', 'b', 'c', 2), first); // `2` |
| 59 | + |
| 60 | +// occurrence: any |
| 61 | +@debug get.number(('a', 'b', 'c', (3))); // `3` |
| 62 | +@debug get.number(('a', 'b', 'c', (4, ))); // `null` |
| 63 | +@debug get.number(('a', 'b', 'c', ('5', (6,)))); // `null` |
| 64 | + |
| 65 | +// occurrence: last |
| 66 | +@debug get.number(('a', 5, 'b', 2, 'c', (4, ))); // 5 |
| 67 | + |
| 68 | +// occurrence: all |
| 69 | +@debug get.number((3, 'a', 0, 'b', 1, 'c', 2), all); // 3, 0, 1, 2 |
| 70 | +@debug get.number(('a', 5, 'b', 2, 'c', (4, )), all); // 5, 2 |
| 71 | +@debug get.number(('a', 3, 'b', 2, 4, 2, 7, 2, 'b', 'c', 2), all); // 3, 2, 4, 2, 7, 2, 2 |
| 72 | +@debug get.number(('a', 3, 'b', 2, 4, 8, 2, 7, 2, 'b', 'c', 2), all); // 3, 2, 4, 8, 2, 7, 2, 2 |
| 73 | +@debug get.number(('a', 3, 'b', 2, 4, 8, 2, 7, 2, 'b', 'c', 2), first); // 3 |
| 74 | +@debug get.number(('a', 3, 'b', 2, 4, 8, 2, 7, 2, 'b', 'c', 2), last); // 2 |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +// Examples `string`. |
| 79 | +// occurrence: first by default |
| 80 | +@debug get.string((1, 'a', 'b', 'c', 2)); // a |
| 81 | +@debug get.string((1, 2, 3, 'a', 'b', 'c', 2), first); // a |
| 82 | +@debug get.string(('a', 3, 'b', 2, 4, 8, 2, 7, 2, 'b', 'c', 2), first); // a |
| 83 | + |
| 84 | +// occurrence: any |
| 85 | +@debug get.string((1, 2, 3, 'a', 'b', 'c', (3)), any); // a |
| 86 | + |
| 87 | +// occurrence: last |
| 88 | +@debug get.string(('a', 5, 'b', 2, 'c', (4, )), last); // c |
| 89 | +@debug get.string(('a', 3, 'b', 2, 4, 8, 2, 7, 2, 'b', 'c', 2), last); // c |
| 90 | + |
| 91 | +// occurrence: all |
| 92 | +@debug get.string((3, 'a', 0, 'b', 1, 'c', 2), all); // "a", "b", "c" |
| 93 | +@debug get.string(('a', 'the', 5, 'sun', 'b', 2, 'c', (4, )), all); // "a", "the", "sun", "b", "c" |
| 94 | +@debug get.string(('a', 3, 'b', 2, 4, 8, 2, 7, 2, 'b', 'c', 2), all); // "a", "b", "b", "c" |
| 95 | +@debug get.string(('a', 3, 'b', 2, 'c', 4, 2, 7, 2, 'b', 'c', 2), all); // "a", "b", "c", "b", "c" |
| 96 | +@debug get.string(('a', 3, 'b', 2, 'c', 4, 'd', 8, 'e', 2, 7, 2, 'b', 'c', 2), all); // "a", "b", "c", "d", "e", "b", "c" |
0 commit comments