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

difftreelog

feat add std.objectRemoveKey

Paweł Bęza2023-07-14parent: #3e814e5.patch.diff
in: master
Upstream issue: https://github.com/google/go-jsonnet/pull/686

2 files changed

modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -139,6 +139,7 @@
 		// Objects
 		("objectFieldsEx", builtin_object_fields_ex::INST),
 		("objectHasEx", builtin_object_has_ex::INST),
+		("objectRemoveKey", builtin_object_remove_key::INST),
 		// Manifest
 		("escapeStringJson", builtin_escape_string_json::INST),
 		("manifestJsonEx", builtin_manifest_json_ex::INST),
modifiedcrates/jrsonnet-stdlib/src/objects.rsdiffbeforeafterboth
before · crates/jrsonnet-stdlib/src/objects.rs
1use jrsonnet_evaluator::{2	function::builtin,3	val::{StrValue, Val},4	IStr, ObjValue,5};67#[builtin]8pub fn builtin_object_fields_ex(9	obj: ObjValue,10	hidden: bool,11	#[cfg(feature = "exp-preserve-order")] preserve_order: Option<bool>,12) -> Vec<Val> {13	#[cfg(feature = "exp-preserve-order")]14	let preserve_order = preserve_order.unwrap_or(false);15	let out = obj.fields_ex(16		hidden,17		#[cfg(feature = "exp-preserve-order")]18		preserve_order,19	);20	out.into_iter()21		.map(StrValue::Flat)22		.map(Val::Str)23		.collect::<Vec<_>>()24}2526#[builtin]27pub fn builtin_object_has_ex(obj: ObjValue, fname: IStr, hidden: bool) -> bool {28	obj.has_field_ex(fname, hidden)29}