@appscode/ui-builder
Version:
## Motivation
7 lines • 3.53 kB
JavaScript
import{s as e,_ as t,d as n,v as r,p as o,u as a,x as s,a as i,y as u,t as c,z as p,A as v,B as d,C as l,g as f,D as h,E as w,F as g,G as b,H as m,P as y,I as E}from"./wrapper-5d451278.js";var k=r.includes;t({target:"Array",proto:!0,forced:!e("indexOf",{ACCESSORS:!0,1:0})},{includes:function(e){return k(this,e,arguments.length>1?arguments[1]:void 0)}}),n("includes");var A=a.map,L=o("map"),j=e("map");t({target:"Array",proto:!0,forced:!L||!j},{map:function(e){return A(this,e,arguments.length>1?arguments[1]:void 0)}});var x=function(e){return function(t,n,r,o){s(n);var a=i(t),p=u(a),v=c(a.length),d=e?v-1:0,l=e?-1:1;if(r<2)for(;;){if(d in p){o=p[d],d+=l;break}if(d+=l,e?d<0:v<=d)throw TypeError("Reduce of empty array with no initial value")}for(;e?d>=0:v>d;d+=l)d in p&&(o=n(o,p[d],d,a));return o}},O={left:x(!1),right:x(!0)}.left,S=p("reduce"),C=e("reduce",{1:0});t({target:"Array",proto:!0,forced:!S||!C},{reduce:function(e){return O(this,e,arguments.length,arguments.length>1?arguments[1]:void 0)}}),t({target:"String",proto:!0,forced:!v("includes")},{includes:function(e){return!!~String(d(this)).indexOf(l(e),arguments.length>1?arguments[1]:void 0)}});
/*!
* https://github.com/Starcounter-Jack/JSON-Patch
* (c) 2017 Joachim Wester
* MIT license
*/
var _=new WeakMap,P=function(e){this.observers=new Map,this.obj=e},T=function(e,t){this.callback=e,this.observer=t};function J(e,t){void 0===t&&(t=!1);var n=_.get(e.object);z(n.value,e.object,e.patches,"",t),e.patches.length&&h(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function z(e,t,n,r,o){if(t!==e){"function"==typeof t.toJSON&&(t=t.toJSON());for(var a=w(t),s=w(e),i=!1,u=s.length-1;u>=0;u--){var c=e[v=s[u]];if(!g(t,v)||void 0===t[v]&&void 0!==c&&!1===Array.isArray(t))Array.isArray(e)===Array.isArray(t)?(o&&n.push({op:"test",path:r+"/"+b(v),value:f(c)}),n.push({op:"remove",path:r+"/"+b(v)}),i=!0):(o&&n.push({op:"test",path:r,value:e}),n.push({op:"replace",path:r,value:t}));else{var p=t[v];"object"==typeof c&&null!=c&&"object"==typeof p&&null!=p?z(c,p,n,r+"/"+b(v),o):c!==p&&(o&&n.push({op:"test",path:r+"/"+b(v),value:f(c)}),n.push({op:"replace",path:r+"/"+b(v),value:f(p)}))}}if(i||a.length!=s.length)for(u=0;u<a.length;u++){var v=a[u];g(e,v)||void 0===t[v]||n.push({op:"add",path:r+"/"+b(v),value:f(t[v])})}}}function M(e,t,n){void 0===n&&(n=!1);var r=[];return z(e,t,r,"",n),r}var N=Object.freeze({__proto__:null,unobserve:function(e,t){t.unobserve()},observe:function(e,t){var n,r=function(e){return _.get(e)}(e);if(r){var o=function(e,t){return e.observers.get(t)}(r,t);n=o&&o.observer}else r=new P(e),_.set(e,r);if(n)return n;if(n={},r.value=f(e),t){n.callback=t,n.next=null;var a=function(){J(n)},s=function(){clearTimeout(n.next),n.next=setTimeout(a)};"undefined"!=typeof window&&(window.addEventListener("mouseup",s),window.addEventListener("keyup",s),window.addEventListener("mousedown",s),window.addEventListener("keydown",s),window.addEventListener("change",s))}return n.patches=[],n.object=e,n.unobserve=function(){J(n),clearTimeout(n.next),function(e,t){e.observers.delete(t.callback)}(r,n),"undefined"!=typeof window&&(window.removeEventListener("mouseup",s),window.removeEventListener("keyup",s),window.removeEventListener("mousedown",s),window.removeEventListener("keydown",s),window.removeEventListener("change",s))},r.observers.set(t,new T(t,n)),n},generate:J,compare:M});Object.assign({},m,N,{JsonPatchError:y,deepClone:f,escapePathComponent:b,unescapePathComponent:E});export{M as c};