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

difftreelog

source

crates/jrsonnet-stdlib/src/std.jsonnet1.4 KiBsourcehistory
1{2  local std = self,34  thisFile:: error 'std.thisFile is deprecated, to enable its support in jrsonnet - recompile it with "legacy-this-file" support.\nThis will slow down stdlib caching a bit, though',56  mapWithKey(func, obj)::7    if !std.isFunction(func) then8      error ('std.mapWithKey first param must be function, got ' + std.type(func))9    else if !std.isObject(obj) then10      error ('std.mapWithKey second param must be object, got ' + std.type(obj))11    else12      { [k]: func(k, obj[k]) for k in std.objectFields(obj) },1314  mergePatch(target, patch)::15    if std.isObject(patch) then16      local target_object =17        if std.isObject(target) then target else {};1819      local target_fields =20        if std.isObject(target_object) then std.objectFields(target_object) else [];2122      local null_fields = [k for k in std.objectFields(patch) if patch[k] == null];23      local both_fields = std.setUnion(target_fields, std.objectFields(patch));2425      {26        [k]:27          if !std.objectHas(patch, k) then28            target_object[k]29          else if !std.objectHas(target_object, k) then30            std.mergePatch(null, patch[k]) tailstrict31          else32            std.mergePatch(target_object[k], patch[k]) tailstrict33        for k in std.setDiff(both_fields, null_fields)34      }35    else36      patch,3738  resolvePath(f, r)::39    local arr = std.split(f, '/');40    std.join('/', std.makeArray(std.length(arr) - 1, function(i) arr[i]) + [r]),41}