Skip to content

Instantly share code, notes, and snippets.

@xavi-
Last active December 26, 2015 07:18
Show Gist options
  • Save xavi-/7113797 to your computer and use it in GitHub Desktop.
Save xavi-/7113797 to your computer and use it in GitHub Desktop.
var original = {
_id: "3f369ef",
_rev: "rev-23421-12",
brand: "bran and ed",
sizes: [
{ sku: "3925", US: 10, UK: 11 },
{ sku: "4635", US: 9, UK: 10 }
]
};
var tmpl = {
id: "@._id",
brand: "@.brand",
sizes: "@.sizes[].US"
};
var sanitized = magic(original, tmpl);
sanitized === {
id: "3f369ef",
brand: "bran and ed",
sizes: [ 10, 9 ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment