-
Notifications
You must be signed in to change notification settings - Fork 10
/
sprout.min.js
1 lines (1 loc) · 1.91 KB
/
sprout.min.js
1
var sprout=function(r){"use strict";var n=Array.prototype.slice;function t(r){return null!==r&&"[object Object]"===Object.prototype.toString.call(r)}function e(r){if(Array.isArray(r))return r.slice();var n={};for(var t in r)n[t]=r[t];return n}function i(r,n,t){return function(r){return"object"==typeof r}(r)&&null!==r&&n in r?r[n]:t}function u(r,n,t){var e=n[0],a=n.slice(1);return i(r,e)&&a.length?u(r[e],a,t):i(r,e,t)}function a(r,n,t){if(r[n]===t)return r;var i=e(r);return i[n]=t,i}function c(r,n,t){if(u(r,n)===t)return r;var i=n[0],a=n.slice(1),o=e(r);return a.length?o[i]=c(i in o?o[i]:{},a,t):o[i]=t,o}function o(r,n){if(!(n in r))return r;var t=e(r);return delete t[n],t}function f(r,n){if(!function r(n,t){var e=t[0],i=t.slice(1);return i.length?e in n&&r(n[e],i):e in n}(r,n))return r;var t=n[0],i=n.slice(1),u=e(r);return 0!==i.length?(u[t]=f(r[t],i),0===Object.keys(u[t]).length&&delete u[t]):delete u[t],u}function l(r,n){for(var i,u,c=Object.keys(n),o=c.length,f=-1,s=r;++f<o;){var y=t(i=n[u=c[f]]),v=i;(y||Array.isArray(i))&&(v=u in s&&t(s[u])&&y?l(s[u],i):e(i)),s=a(s,u,v)}return s}return r.assoc=function(r){for(var n,t,e=arguments,i=arguments.length,u=r,o=1;o<i;o+=2)n=e[o],t=e[o+1],u=Array.isArray(n)?c(u,n,t):a(u,n,t);return u},r.deepMerge=function(){for(var r=arguments,n=arguments.length,t=0,e=arguments[0];++t<n;)e=l(e,r[t]);return e},r.dissoc=function(r){for(var n,t=arguments,e=arguments.length,i=0,u=r;++i<e;)n=t[i],u=Array.isArray(n)?f(u,n):o(u,n);return u},r.get=function(r,n,t){return Array.isArray(n)?u(r,n,t):i(r,n,t)},r.merge=function(){for(var r,n=arguments,t=arguments.length,e=0,i=arguments[0];++e<t;)for(var u in r=n[e])i=a(i,u,r[u]);return i},r.update=function(r,t){return Array.isArray(t)?function(r,t,e){var i=u(r,t);return c(r,t,e.apply(i,[i].concat(n.call(arguments,3))))}.apply(this,arguments):function(r,t,e){var u=i(r,t);return a(r,t,e.apply(u,[u].concat(n.call(arguments,3))))}.apply(this,arguments)},r}({});