git.delta.rocks / jrsonnet / refs/commits / d696e7b504bb

difftreelog

fix add missing stdlib functions

Yaroslav Bolyukin2022-12-08parent: #4c3faa0.patch.diff
in: master

1 file changed

modifiedcrates/jrsonnet-stdlib/src/std.jsonnetdiffbeforeafterboth
25 stringChars(str)::25 stringChars(str)::
26 std.makeArray(std.length(str), function(i) str[i]),26 std.makeArray(std.length(str), function(i) str[i]),
2727
28 splitLimitR(str, c, maxsplits)::
29 if maxsplits == -1 then
30 std.splitLimit(str, c, -1)
31 else
32 local revStr(str) = std.join('', std.reverse(std.stringChars(str)));
33 std.map(function(e) revStr(e), std.reverse(std.splitLimit(revStr(str), revStr(c), maxsplits))),
34
28 split(str, c):: std.splitLimit(str, c, -1),35 split(str, c):: std.splitLimit(str, c, -1),
2936
30 mapWithIndex(func, arr)::37 mapWithIndex(func, arr)::
121 ch;128 ch;
122 std.foldl(function(a, b) a + trans(b), std.stringChars(str), ''),129 std.foldl(function(a, b) a + trans(b), std.stringChars(str), ''),
123130
131 local xml_escapes = {
132 '<': '&lt;',
133 '>': '&gt;',
134 '&': '&amp;',
135 '"': '&quot;',
136 "'": '&apos;',
137 },
138
139 escapeStringXML(str_)::
140 local str = std.toString(str_);
141 std.join('', [std.get(xml_escapes, ch, ch) for ch in std.stringChars(str)]),
142
124 manifestJson(value):: std.manifestJsonEx(value, ' ') tailstrict,143 manifestJson(value):: std.manifestJsonEx(value, ' ') tailstrict,
125144
126 manifestJsonMinified(value):: std.manifestJsonEx(value, '', '', ':'),145 manifestJsonMinified(value):: std.manifestJsonEx(value, '', '', ':'),
127146
128 manifestYamlStream(value, indent_array_in_object=false, c_document_end=true)::147 manifestYamlStream(value, indent_array_in_object=false, c_document_end=true, quote_keys=true)::
129 if !std.isArray(value) then148 if !std.isArray(value) then
130 error 'manifestYamlStream only takes arrays, got ' + std.type(value)149 error 'manifestYamlStream only takes arrays, got ' + std.type(value)
131 else150 else
132 '---\n' + std.join(151 '---\n' + std.join(
133 '\n---\n', [std.manifestYamlDoc(e, indent_array_in_object) for e in value]152 '\n---\n', [std.manifestYamlDoc(e, indent_array_in_object, quote_keys) for e in value]
134 ) + if c_document_end then '\n...\n' else '\n',153 ) + if c_document_end then '\n...\n' else '\n',
135
136154
137 manifestPython(v)::155 manifestPython(v)::
138 if std.isObject(v) then156 if std.isObject(v) then