UNPKG

object-translate

Version:
2 lines (1 loc) 933 B
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t():"function"==typeof define&&define.amd?define(t):t()}(0,function(){"use strict";var e=require("object-path"),t=require("traverse");module.exports=function(r,o){var n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).defaultPath,i=void 0===n?"$default":n;return o=o||{},function(n){return t(r).map(function(t){var r="get",a=t,u=function(e){return e};if(!this.isLeaf){var f="[object Object]"===Object.prototype.toString.apply(t),c=f&&Array.isArray(t.alternatives),p=f&&"function"==typeof t.processor;if(!c&&!p)return;if(c&&(a=t.alternatives,r="coalesce"),p){if(!c&&!t.path)return console.warn("You have provided a processor func. without path or alternatives. Null will be returned"),null;a=c?a:t.path,u=t.processor}}var s=e[r](n,a),d=u(s=void 0===s?function(t,r,o,n){var i=e[t](r,o);return void 0===i?e[t](r,n):i}(r,o,a,i):s,n);this.update(d,!0)})}}});