LocalCDN-Firefox-Chrome-Brave/resources/knockout.mapping/2.4.1/knockout.mapping.min.jsm

1 line
10 KiB
JavaScript
Raw Normal View History

2022-11-23 06:14:29 +01:00
(function(a){if(typeof require==="function"&&typeof exports==="object"&&typeof module==="object"){a(require("knockout"),exports)}else{if(typeof define==="function"&&define.amd){define(["knockout","exports"],a)}else{a(ko,ko.mapping={})}}}(function(b,B){var d=true;var n="__ko_mapping__";var i=b.dependentObservable;var q=0;var m;var v;var a=["create","update","key","arrayChanged"];var r={};var h={include:["_destroy"],ignore:[],copy:[],observe:[]};var w=h;function o(C,H){var G={};for(var F=C.length-1;F>=0;--F){G[C[F]]=C[F]}for(var F=H.length-1;F>=0;--F){G[H[F]]=H[F]}var E=[];for(var D in G){E.push(G[D])}return E}function p(C,F){var G;for(var D in F){if(F.hasOwnProperty(D)&&F[D]){G=B.getType(C[D]);if(D&&C[D]&&G!=="array"&&G!=="string"){p(C[D],F[D])}else{var E=B.getType(C[D])==="array"&&B.getType(F[D])==="array";if(E){C[D]=o(C[D],F[D])}else{C[D]=F[D]}}}}}function g(E,D){var C={};p(C,E);p(C,D);return C}B.isMapped=function(D){var C=b.utils.unwrapObservable(D);return C&&C[n]};B.fromJS=function(D){if(arguments.length==0){throw new Error("When calling ko.fromJS, pass the object you want to convert.")}try{if(!q++){m=[];v=new c()}var F;var H;if(arguments.length==2){if(arguments[1][n]){H=arguments[1]}else{F=arguments[1]}}if(arguments.length==3){F=arguments[1];H=arguments[2]}if(H){F=g(F,H[n])}F=s(F);var C=x(H,D,F);if(H){C=H}if(!--q){while(m.length){var E=m.pop();if(E){E();E.__DO.throttleEvaluation=E.throttleEvaluation}}}C[n]=g(C[n],F);return C}catch(G){q=0;throw G}};B.fromJSON=function(D){var C=b.utils.parseJson(D);arguments[0]=C;return B.fromJS.apply(this,arguments)};B.updateFromJS=function(C){throw new Error("ko.mapping.updateFromJS, use ko.mapping.fromJS instead. Please note that the order of parameters is different!")};B.updateFromJSON=function(C){throw new Error("ko.mapping.updateFromJSON, use ko.mapping.fromJSON instead. Please note that the order of parameters is different!")};B.toJS=function(D,C){if(!w){B.resetDefaultOptions()}if(arguments.length==0){throw new Error("When calling ko.mapping.toJS, pass the object you want to convert.")}if(B.getType(w.ignore)!=="array"){throw new Error("ko.mapping.defaultOptions().ignore should be an array.")}if(B.getType(w.include)!=="array"){throw new Error("ko.mapping.defaultOptions().include should be an array.")}if(B.getType(w.copy)!=="array"){throw new Error("ko.mapping.defaultOptions().copy should be an array.")}C=s(C,D[n]);return B.visitModel(D,function(E){return b.utils.unwrapObservable(E)},C)};B.toJSON=function(E,C){var D=B.toJS(E,C);return b.utils.stringifyJson(D)};B.defaultOptions=function(){if(arguments.length>0){w=arguments[0]}else{return w}};B.resetDefaultOptions=function(){w={include:h.include.slice(0),ignore:h.ignore.slice(0),copy:h.copy.slice(0)}};B.getType=function(C){if((C)&&(typeof(C)==="object")){if(C.constructor===Date){return"date"}if(C.constructor===Array){return"array"}}return typeof C};function s(F,C){var D=g({},F);for(var E=a.length-1;E>=0;E--){var G=a[E];if(!D[G]){continue}if(!(D[""] instanceof Object)){D[""]={}}D[""][G]=D[G];delete D[G]}if(C){D.ignore=k(C.ignore,D.ignore);D.include=k(C.include,D.include);D.copy=k(C.copy,D.copy);D.observe=k(C.observe,D.observe)}D.ignore=k(D.ignore,w.ignore);D.include=k(D.include,w.include);D.copy=k(D.copy,w.copy);D.observe=k(D.observe,w.observe);D.mappedProperties=D.mappedProperties||{};D.copiedProperties=D.copiedProperties||{};return D}function k(D,C){if(B.getType(D)!=="array"){if(B.getType(D)==="undefined"){D=[]}else{D=[D]}}if(B.getType(C)!=="array"){if(B.getType(C)==="undefined"){C=[]}else{C=[C]}}return b.utils.arrayGetDistinctValues(D.concat(C))}function f(D,F){var E=b.dependentObservable;b.dependentObservable=function(M,G,J){J=J||{};if(M&&typeof M=="object"){J=M}var I=J.deferEvaluation;var H=false;var L=function(N){var P=b.dependentObservable;b.dependentObservable=i;var Q=b.isWriteableObservable(N);b.dependentObservable=P;var O=i({read:function(){if(!H){b.utils.arrayRemoveItem(D,N);H=true}return N.apply(N,arguments)},write:Q&&function(R){return N(R)},deferEvaluation:true});if(d){O._wrapper=true}O.__DO=N;return O};J.deferEvaluati