diff --git a/src/html/knockout/knockout-mapping.js b/src/html/knockout/knockout-mapping.js index 08fc029..b6b9ff4 100644 --- a/src/html/knockout/knockout-mapping.js +++ b/src/html/knockout/knockout-mapping.js @@ -1,1671 +1,799 @@ - - - - - - - - - knockout.mapping/build/output/knockout.mapping-latest.debug.js at master · SteveSanderson/knockout.mapping · GitHub - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
-
- - - GitHub - GitHub - - - - - - - - -
-
- - - - - - - -
-
- -
-
-
- - - - - -

- public - - - / - knockout.mapping -

-
- - - - - -
- - - - - - -
- - -
- - - branch: - master - - -
- -
-
- Switch branches/tags - -
- -
-
- -
-
- -
-
- -
- - - -
- - arrayperf -
- -
- - master -
- -
- - revert -
- -
Nothing to show
-
- - - - -
-
-
- -
- - - -
- - - - - - - -
-
- -
- - - - - - -
-
- - - - - - - -
- - - - - -
-

2 contributors

- - - - -
- -
- - -
- -
-
- -
-
-
-
- - file - 800 lines (673 sloc) - 26.916 kb -
- - -
-
- - - - - -
-
1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-74
-75
-76
-77
-78
-79
-80
-81
-82
-83
-84
-85
-86
-87
-88
-89
-90
-91
-92
-93
-94
-95
-96
-97
-98
-99
-100
-101
-102
-103
-104
-105
-106
-107
-108
-109
-110
-111
-112
-113
-114
-115
-116
-117
-118
-119
-120
-121
-122
-123
-124
-125
-126
-127
-128
-129
-130
-131
-132
-133
-134
-135
-136
-137
-138
-139
-140
-141
-142
-143
-144
-145
-146
-147
-148
-149
-150
-151
-152
-153
-154
-155
-156
-157
-158
-159
-160
-161
-162
-163
-164
-165
-166
-167
-168
-169
-170
-171
-172
-173
-174
-175
-176
-177
-178
-179
-180
-181
-182
-183
-184
-185
-186
-187
-188
-189
-190
-191
-192
-193
-194
-195
-196
-197
-198
-199
-200
-201
-202
-203
-204
-205
-206
-207
-208
-209
-210
-211
-212
-213
-214
-215
-216
-217
-218
-219
-220
-221
-222
-223
-224
-225
-226
-227
-228
-229
-230
-231
-232
-233
-234
-235
-236
-237
-238
-239
-240
-241
-242
-243
-244
-245
-246
-247
-248
-249
-250
-251
-252
-253
-254
-255
-256
-257
-258
-259
-260
-261
-262
-263
-264
-265
-266
-267
-268
-269
-270
-271
-272
-273
-274
-275
-276
-277
-278
-279
-280
-281
-282
-283
-284
-285
-286
-287
-288
-289
-290
-291
-292
-293
-294
-295
-296
-297
-298
-299
-300
-301
-302
-303
-304
-305
-306
-307
-308
-309
-310
-311
-312
-313
-314
-315
-316
-317
-318
-319
-320
-321
-322
-323
-324
-325
-326
-327
-328
-329
-330
-331
-332
-333
-334
-335
-336
-337
-338
-339
-340
-341
-342
-343
-344
-345
-346
-347
-348
-349
-350
-351
-352
-353
-354
-355
-356
-357
-358
-359
-360
-361
-362
-363
-364
-365
-366
-367
-368
-369
-370
-371
-372
-373
-374
-375
-376
-377
-378
-379
-380
-381
-382
-383
-384
-385
-386
-387
-388
-389
-390
-391
-392
-393
-394
-395
-396
-397
-398
-399
-400
-401
-402
-403
-404
-405
-406
-407
-408
-409
-410
-411
-412
-413
-414
-415
-416
-417
-418
-419
-420
-421
-422
-423
-424
-425
-426
-427
-428
-429
-430
-431
-432
-433
-434
-435
-436
-437
-438
-439
-440
-441
-442
-443
-444
-445
-446
-447
-448
-449
-450
-451
-452
-453
-454
-455
-456
-457
-458
-459
-460
-461
-462
-463
-464
-465
-466
-467
-468
-469
-470
-471
-472
-473
-474
-475
-476
-477
-478
-479
-480
-481
-482
-483
-484
-485
-486
-487
-488
-489
-490
-491
-492
-493
-494
-495
-496
-497
-498
-499
-500
-501
-502
-503
-504
-505
-506
-507
-508
-509
-510
-511
-512
-513
-514
-515
-516
-517
-518
-519
-520
-521
-522
-523
-524
-525
-526
-527
-528
-529
-530
-531
-532
-533
-534
-535
-536
-537
-538
-539
-540
-541
-542
-543
-544
-545
-546
-547
-548
-549
-550
-551
-552
-553
-554
-555
-556
-557
-558
-559
-560
-561
-562
-563
-564
-565
-566
-567
-568
-569
-570
-571
-572
-573
-574
-575
-576
-577
-578
-579
-580
-581
-582
-583
-584
-585
-586
-587
-588
-589
-590
-591
-592
-593
-594
-595
-596
-597
-598
-599
-600
-601
-602
-603
-604
-605
-606
-607
-608
-609
-610
-611
-612
-613
-614
-615
-616
-617
-618
-619
-620
-621
-622
-623
-624
-625
-626
-627
-628
-629
-630
-631
-632
-633
-634
-635
-636
-637
-638
-639
-640
-641
-642
-643
-644
-645
-646
-647
-648
-649
-650
-651
-652
-653
-654
-655
-656
-657
-658
-659
-660
-661
-662
-663
-664
-665
-666
-667
-668
-669
-670
-671
-672
-673
-674
-675
-676
-677
-678
-679
-680
-681
-682
-683
-684
-685
-686
-687
-688
-689
-690
-691
-692
-693
-694
-695
-696
-697
-698
-699
-700
-701
-702
-703
-704
-705
-706
-707
-708
-709
-710
-711
-712
-713
-714
-715
-716
-717
-718
-719
-720
-721
-722
-723
-724
-725
-726
-727
-728
-729
-730
-731
-732
-733
-734
-735
-736
-737
-738
-739
-740
-741
-742
-743
-744
-745
-746
-747
-748
-749
-750
-751
-752
-753
-754
-755
-756
-757
-758
-759
-760
-761
-762
-763
-764
-765
-766
-767
-768
-769
-770
-771
-772
-773
-774
-775
-776
-777
-778
-779
-780
-781
-782
-783
-784
-785
-786
-787
-788
-789
-790
-791
-792
-793
-794
-795
-796
-797
-798
-799
-
-
-
/// Knockout Mapping plugin v2.3.5
/// (c) 2012 Steven Sanderson, Roy Jacobs - http://knockoutjs.com/
/// License: MIT (http://www.opensource.org/licenses/mit-license.php)
(function (factory) {
// Module systems magic dance.

if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
// CommonJS or Node: hard-coded dependency on "knockout"
factory(require("knockout"), exports);
} else if (typeof define === "function" && define["amd"]) {
// AMD anonymous module with hard-coded dependency on "knockout"
define(["knockout", "exports"], factory);
} else {
// <script> tag: use the global `ko` object, attaching a `mapping` property
factory(ko, ko.mapping = {});
}
}(function (ko, exports) {
var DEBUG=true;
var mappingProperty = "__ko_mapping__";
var realKoDependentObservable = ko.dependentObservable;
var mappingNesting = 0;
var dependentObservables;
var visitedObjects;
var recognizedRootProperties = ["create", "update", "key", "arrayChanged"];
var emptyReturn = {};

var _defaultOptions = {
include: ["_destroy"],
ignore: [],
copy: [],
observe: []
};
var defaultOptions = _defaultOptions;

// Author: KennyTM @ StackOverflow
function unionArrays (x, y) {
var obj = {};
for (var i = x.length - 1; i >= 0; -- i) obj[x[i]] = x[i];
for (var i = y.length - 1; i >= 0; -- i) obj[y[i]] = y[i];
var res = [];

for (var k in obj) {
res.push(obj[k]);
};

return res;
}

function extendObject(destination, source) {
var destType;

for (var key in source) {
if (source.hasOwnProperty(key) && source[key]) {
destType = exports.getType(destination[key]);
if (key && destination[key] && destType !== "array" && destType !== "string") {
extendObject(destination[key], source[key]);
} else {
var bothArrays = exports.getType(destination[key]) === "array" && exports.getType(source[key]) === "array";
if (bothArrays) {
destination[key] = unionArrays(destination[key], source[key]);
} else {
destination[key] = source[key];
}
}
}
}
}

function merge(obj1, obj2) {
var merged = {};
extendObject(merged, obj1);
extendObject(merged, obj2);

return merged;
}

exports.isMapped = function (viewModel) {
var unwrapped = ko.utils.unwrapObservable(viewModel);
return unwrapped && unwrapped[mappingProperty];
}

exports.fromJS = function (jsObject /*, inputOptions, target*/ ) {
if (arguments.length == 0) throw new Error("When calling ko.fromJS, pass the object you want to convert.");

// When mapping is completed, even with an exception, reset the nesting level
window.setTimeout(function () {
mappingNesting = 0;
}, 0);

if (!mappingNesting++) {
dependentObservables = [];
visitedObjects = new objectLookup();
}

var options;
var target;

if (arguments.length == 2) {
if (arguments[1][mappingProperty]) {
target = arguments[1];
} else {
options = arguments[1];
}
}
if (arguments.length == 3) {
options = arguments[1];
target = arguments[2];
}

if (target) {
options = merge(options, target[mappingProperty]);
}
options = fillOptions(options);

var result = updateViewModel(target, jsObject, options);
if (target) {
result = target;
}

// Evaluate any dependent observables that were proxied.
// Do this in a timeout to defer execution. Basically, any user code that explicitly looks up the DO will perform the first evaluation. Otherwise,
// it will be done by this code.
if (!--mappingNesting) {
window.setTimeout(function () {
while (dependentObservables.length) {
var DO = dependentObservables.pop();
if (DO) DO();
}
}, 0);
}

// Save any new mapping options in the view model, so that updateFromJS can use them later.
result[mappingProperty] = merge(result[mappingProperty], options);

return result;
};

exports.fromJSON = function (jsonString /*, options, target*/ ) {
var parsed = ko.utils.parseJson(jsonString);
arguments[0] = parsed;
return exports.fromJS.apply(this, arguments);
};

exports.updateFromJS = function (viewModel) {
throw new Error("ko.mapping.updateFromJS, use ko.mapping.fromJS instead. Please note that the order of parameters is different!");
};

exports.updateFromJSON = function (viewModel) {
throw new Error("ko.mapping.updateFromJSON, use ko.mapping.fromJSON instead. Please note that the order of parameters is different!");
};

exports.toJS = function (rootObject, options) {
if (!defaultOptions) exports.resetDefaultOptions();

if (arguments.length == 0) throw new Error("When calling ko.mapping.toJS, pass the object you want to convert.");
if (exports.getType(defaultOptions.ignore) !== "array") throw new Error("ko.mapping.defaultOptions().ignore should be an array.");
if (exports.getType(defaultOptions.include) !== "array") throw new Error("ko.mapping.defaultOptions().include should be an array.");
if (exports.getType(defaultOptions.copy) !== "array") throw new Error("ko.mapping.defaultOptions().copy should be an array.");

// Merge in the options used in fromJS
options = fillOptions(options, rootObject[mappingProperty]);

// We just unwrap everything at every level in the object graph
return exports.visitModel(rootObject, function (x) {
return ko.utils.unwrapObservable(x)
}, options);
};

exports.toJSON = function (rootObject, options) {
var plainJavaScriptObject = exports.toJS(rootObject, options);
return ko.utils.stringifyJson(plainJavaScriptObject);
};

exports.defaultOptions = function () {
if (arguments.length > 0) {
defaultOptions = arguments[0];
} else {
return defaultOptions;
}
};

exports.resetDefaultOptions = function () {
defaultOptions = {
include: _defaultOptions.include.slice(0),
ignore: _defaultOptions.ignore.slice(0),
copy: _defaultOptions.copy.slice(0)
};
};

exports.getType = function(x) {
if ((x) && (typeof (x) === "object")) {
if (x.constructor == (new Date).constructor) return "date";
if (Object.prototype.toString.call(x) === "[object Array]") return "array";
}
return typeof x;
}

function fillOptions(rawOptions, otherOptions) {
var options = merge({}, rawOptions);

// Move recognized root-level properties into a root namespace
for (var i = recognizedRootProperties.length - 1; i >= 0; i--) {
var property = recognizedRootProperties[i];

// Carry on, unless this property is present
if (!options[property]) continue;

// Move the property into the root namespace
if (!(options[""] instanceof Object)) options[""] = {};
options[""][property] = options[property];
delete options[property];
}

if (otherOptions) {
options.ignore = mergeArrays(otherOptions.ignore, options.ignore);
options.include = mergeArrays(otherOptions.include, options.include);
options.copy = mergeArrays(otherOptions.copy, options.copy);
options.observe = mergeArrays(otherOptions.observe, options.observe);
}
options.ignore = mergeArrays(options.ignore, defaultOptions.ignore);
options.include = mergeArrays(options.include, defaultOptions.include);
options.copy = mergeArrays(options.copy, defaultOptions.copy);
options.observe = mergeArrays(options.observe, defaultOptions.observe);

options.mappedProperties = options.mappedProperties || {};
options.copiedProperties = options.copiedProperties || {};
return options;
}

function mergeArrays(a, b) {
if (exports.getType(a) !== "array") {
if (exports.getType(a) === "undefined") a = [];
else a = [a];
}
if (exports.getType(b) !== "array") {
if (exports.getType(b) === "undefined") b = [];
else b = [b];
}

return ko.utils.arrayGetDistinctValues(a.concat(b));
}

// When using a 'create' callback, we proxy the dependent observable so that it doesn't immediately evaluate on creation.
// The reason is that the dependent observables in the user-specified callback may contain references to properties that have not been mapped yet.
function withProxyDependentObservable(dependentObservables, callback) {
var localDO = ko.dependentObservable;
ko.dependentObservable = function (read, owner, options) {
options = options || {};

if (read && typeof read == "object") { // mirrors condition in knockout implementation of DO's
options = read;
}

var realDeferEvaluation = options.deferEvaluation;

var isRemoved = false;

// We wrap the original dependent observable so that we can remove it from the 'dependentObservables' list we need to evaluate after mapping has
// completed if the user already evaluated the DO themselves in the meantime.
var wrap = function (DO) {
// Temporarily revert ko.dependentObservable, since it is used in ko.isWriteableObservable
var tmp = ko.dependentObservable;
ko.dependentObservable = realKoDependentObservable;
var isWriteable = ko.isWriteableObservable(DO);
ko.dependentObservable = tmp;

var wrapped = realKoDependentObservable({
read: function () {
if (!isRemoved) {
ko.utils.arrayRemoveItem(dependentObservables, DO);
isRemoved = true;
}
return DO.apply(DO, arguments);
},
write: isWriteable && function (val) {
return DO(val);
},
deferEvaluation: true
});
if (DEBUG) wrapped._wrapper = true;
return wrapped;
};

options.deferEvaluation = true; // will either set for just options, or both read/options.
var realDependentObservable = new realKoDependentObservable(read, owner, options);

if (!realDeferEvaluation) {
realDependentObservable = wrap(realDependentObservable);
dependentObservables.push(realDependentObservable);
}

return realDependentObservable;
}
ko.dependentObservable.fn = realKoDependentObservable.fn;
ko.computed = ko.dependentObservable;
var result = callback();
ko.dependentObservable = localDO;
ko.computed = ko.dependentObservable;
return result;
}

function updateViewModel(mappedRootObject, rootObject, options, parentName, parent, parentPropertyName, mappedParent) {
var isArray = exports.getType(ko.utils.unwrapObservable(rootObject)) === "array";

parentPropertyName = parentPropertyName || "";

// If this object was already mapped previously, take the options from there and merge them with our existing ones.
if (exports.isMapped(mappedRootObject)) {
var previousMapping = ko.utils.unwrapObservable(mappedRootObject)[mappingProperty];
options = merge(previousMapping, options);
}

var callbackParams = {
data: rootObject,
parent: mappedParent || parent
};

var hasCreateCallback = function () {
return options[parentName] && options[parentName].create instanceof Function;
};

var createCallback = function (data) {
return withProxyDependentObservable(dependentObservables, function () {

if (ko.utils.unwrapObservable(parent) instanceof Array) {
return options[parentName].create({
data: data || callbackParams.data,
parent: callbackParams.parent,
skip: emptyReturn
});
} else {
return options[parentName].create({
data: data || callbackParams.data,
parent: callbackParams.parent
});
}
});
};

var hasUpdateCallback = function () {
return options[parentName] && options[parentName].update instanceof Function;
};

var updateCallback = function (obj, data) {
var params = {
data: data || callbackParams.data,
parent: callbackParams.parent,
target: ko.utils.unwrapObservable(obj)
};

if (ko.isWriteableObservable(obj)) {
params.observable = obj;
}

return options[parentName].update(params);
}

var alreadyMapped = visitedObjects.get(rootObject);
if (alreadyMapped) {
return alreadyMapped;
}

parentName = parentName || "";

if (!isArray) {
// For atomic types, do a direct update on the observable
if (!canHaveProperties(rootObject)) {
switch (exports.getType(rootObject)) {
case "function":
if (hasUpdateCallback()) {
if (ko.isWriteableObservable(rootObject)) {
rootObject(updateCallback(rootObject));
mappedRootObject = rootObject;
} else {
mappedRootObject = updateCallback(rootObject);
}
} else {
mappedRootObject = rootObject;
}
break;
default:
if (ko.isWriteableObservable(mappedRootObject)) {
if (hasUpdateCallback()) {
var valueToWrite = updateCallback(mappedRootObject);
mappedRootObject(valueToWrite);
return valueToWrite;
} else {
var valueToWrite = ko.utils.unwrapObservable(rootObject);
mappedRootObject(valueToWrite);
return valueToWrite;
}
} else {
var hasCreateOrUpdateCallback = hasCreateCallback() || hasUpdateCallback();

if (hasCreateCallback()) {
mappedRootObject = createCallback();
} else {
mappedRootObject = ko.observable(ko.utils.unwrapObservable(rootObject));
}

if (hasUpdateCallback()) {
mappedRootObject(updateCallback(mappedRootObject));
}

if (hasCreateOrUpdateCallback) return mappedRootObject;
}
}

} else {
mappedRootObject = ko.utils.unwrapObservable(mappedRootObject);
if (!mappedRootObject) {
if (hasCreateCallback()) {
var result = createCallback();

if (hasUpdateCallback()) {
result = updateCallback(result);
}

return result;
} else {
if (hasUpdateCallback()) {
return updateCallback(result);
}

mappedRootObject = {};
}
}

if (hasUpdateCallback()) {
mappedRootObject = updateCallback(mappedRootObject);
}

visitedObjects.save(rootObject, mappedRootObject);
if (hasUpdateCallback()) return mappedRootObject;

// For non-atomic types, visit all properties and update recursively
visitPropertiesOrArrayEntries(rootObject, function (indexer) {
var fullPropertyName = parentPropertyName.length ? parentPropertyName + "." + indexer : indexer;

if (ko.utils.arrayIndexOf(options.ignore, fullPropertyName) != -1) {
return;
}

if (ko.utils.arrayIndexOf(options.copy, fullPropertyName) != -1) {
mappedRootObject[indexer] = rootObject[indexer];
return;
}

if(typeof rootObject[indexer] != "object" && typeof rootObject[indexer] != "array" && options.observe.length > 0 && ko.utils.arrayIndexOf(options.observe, fullPropertyName) == -1)
{
mappedRootObject[indexer] = rootObject[indexer];
options.copiedProperties[fullPropertyName] = true;
return;
}

// In case we are adding an already mapped property, fill it with the previously mapped property value to prevent recursion.
// If this is a property that was generated by fromJS, we should use the options specified there
var prevMappedProperty = visitedObjects.get(rootObject[indexer]);
var retval = updateViewModel(mappedRootObject[indexer], rootObject[indexer], options, indexer, mappedRootObject, fullPropertyName, mappedRootObject);
var value = prevMappedProperty || retval;

if(options.observe.length > 0 && ko.utils.arrayIndexOf(options.observe, fullPropertyName) == -1)
{
mappedRootObject[indexer] = value();
options.copiedProperties[fullPropertyName] = true;
return;
}

if (ko.isWriteableObservable(mappedRootObject[indexer])) {
mappedRootObject[indexer](ko.utils.unwrapObservable(value));
} else {
value = mappedRootObject[indexer] === undefined ? value : ko.utils.unwrapObservable(value);
mappedRootObject[indexer] = value;
}

options.mappedProperties[fullPropertyName] = true;
});
}
} else { //mappedRootObject is an array
var changes = [];

var hasKeyCallback = false;
var keyCallback = function (x) {
return x;
}
if (options[parentName] && options[parentName].key) {
keyCallback = options[parentName].key;
hasKeyCallback = true;
}

if (!ko.isObservable(mappedRootObject)) {
// When creating the new observable array, also add a bunch of utility functions that take the 'key' of the array items into account.
mappedRootObject = ko.observableArray([]);

mappedRootObject.mappedRemove = function (valueOrPredicate) {
var predicate = typeof valueOrPredicate == "function" ? valueOrPredicate : function (value) {
return value === keyCallback(valueOrPredicate);
};
return mappedRootObject.remove(function (item) {
return predicate(keyCallback(item));
});
}

mappedRootObject.mappedRemoveAll = function (arrayOfValues) {
var arrayOfKeys = filterArrayByKey(arrayOfValues, keyCallback);
return mappedRootObject.remove(function (item) {
return ko.utils.arrayIndexOf(arrayOfKeys, keyCallback(item)) != -1;
});
}

mappedRootObject.mappedDestroy = function (valueOrPredicate) {
var predicate = typeof valueOrPredicate == "function" ? valueOrPredicate : function (value) {
return value === keyCallback(valueOrPredicate);
};
return mappedRootObject.destroy(function (item) {
return predicate(keyCallback(item));
});
}

mappedRootObject.mappedDestroyAll = function (arrayOfValues) {
var arrayOfKeys = filterArrayByKey(arrayOfValues, keyCallback);
return mappedRootObject.destroy(function (item) {
return ko.utils.arrayIndexOf(arrayOfKeys, keyCallback(item)) != -1;
});
}

mappedRootObject.mappedIndexOf = function (item) {
var keys = filterArrayByKey(mappedRootObject(), keyCallback);
var key = keyCallback(item);
return ko.utils.arrayIndexOf(keys, key);
}

mappedRootObject.mappedCreate = function (value) {
if (mappedRootObject.mappedIndexOf(value) !== -1) {
throw new Error("There already is an object with the key that you specified.");
}

var item = hasCreateCallback() ? createCallback(value) : value;
if (hasUpdateCallback()) {
var newValue = updateCallback(item, value);
if (ko.isWriteableObservable(item)) {
item(newValue);
} else {
item = newValue;
}
}
mappedRootObject.push(item);
return item;
}
}

var currentArrayKeys = filterArrayByKey(ko.utils.unwrapObservable(mappedRootObject), keyCallback).sort();
var newArrayKeys = filterArrayByKey(rootObject, keyCallback);
if (hasKeyCallback) newArrayKeys.sort();
var editScript = ko.utils.compareArrays(currentArrayKeys, newArrayKeys);

var ignoreIndexOf = {};

var i, j;

var unwrappedRootObject = ko.utils.unwrapObservable(rootObject);
var itemsByKey = {};
var optimizedKeys = true;
for (i = 0, j = unwrappedRootObject.length; i < j; i++) {
var key = keyCallback(unwrappedRootObject[i]);
if (key === undefined || key instanceof Object) {
optimizedKeys = false;
break;
}
itemsByKey[key] = unwrappedRootObject[i];
}

var newContents = [];
var passedOver = 0;
for (i = 0, j = editScript.length; i < j; i++) {
var key = editScript[i];
var mappedItem;
var fullPropertyName = parentPropertyName + "[" + i + "]";
switch (key.status) {
case "added":
var item = optimizedKeys ? itemsByKey[key.value] : getItemByKey(ko.utils.unwrapObservable(rootObject), key.value, keyCallback);
mappedItem = updateViewModel(undefined, item, options, parentName, mappedRootObject, fullPropertyName, parent);
if(!hasCreateCallback()) {
mappedItem = ko.utils.unwrapObservable(mappedItem);
}

var index = ignorableIndexOf(ko.utils.unwrapObservable(rootObject), item, ignoreIndexOf);

if (mappedItem === emptyReturn) {
passedOver++;
} else {
newContents[index - passedOver] = mappedItem;
}

ignoreIndexOf[index] = true;
break;
case "retained":
var item = optimizedKeys ? itemsByKey[key.value] : getItemByKey(ko.utils.unwrapObservable(rootObject), key.value, keyCallback);
mappedItem = getItemByKey(mappedRootObject, key.value, keyCallback);
updateViewModel(mappedItem, item, options, parentName, mappedRootObject, fullPropertyName, parent);

var index = ignorableIndexOf(ko.utils.unwrapObservable(rootObject), item, ignoreIndexOf);
newContents[index] = mappedItem;
ignoreIndexOf[index] = true;
break;
case "deleted":
mappedItem = getItemByKey(mappedRootObject, key.value, keyCallback);
break;
}

changes.push({
event: key.status,
item: mappedItem
});
}

mappedRootObject(newContents);

if (options[parentName] && options[parentName].arrayChanged) {
ko.utils.arrayForEach(changes, function (change) {
options[parentName].arrayChanged(change.event, change.item);
});
}
}

return mappedRootObject;
}

function ignorableIndexOf(array, item, ignoreIndices) {
for (var i = 0, j = array.length; i < j; i++) {
if (ignoreIndices[i] === true) continue;
if (array[i] === item) return i;
}
return null;
}

function mapKey(item, callback) {
var mappedItem;
if (callback) mappedItem = callback(item);
if (exports.getType(mappedItem) === "undefined") mappedItem = item;

return ko.utils.unwrapObservable(mappedItem);
}

function getItemByKey(array, key, callback) {
array = ko.utils.unwrapObservable(array);
for (var i = 0, j = array.length; i < j; i++) {
var item = array[i];
if (mapKey(item, callback) === key) return item;
}

throw new Error("When calling ko.update*, the key '" + key + "' was not found!");
}

function filterArrayByKey(array, callback) {
return ko.utils.arrayMap(ko.utils.unwrapObservable(array), function (item) {
if (callback) {
return mapKey(item, callback);
} else {
return item;
}
});
}

function visitPropertiesOrArrayEntries(rootObject, visitorCallback) {
if (exports.getType(rootObject) === "array") {
for (var i = 0; i < rootObject.length; i++)
visitorCallback(i);
} else {
for (var propertyName in rootObject)
visitorCallback(propertyName);
}
};

function canHaveProperties(object) {
var type = exports.getType(object);
return ((type === "object") || (type === "array")) && (object !== null);
}

// Based on the parentName, this creates a fully classified name of a property

function getPropertyName(parentName, parent, indexer) {
var propertyName = parentName || "";
if (exports.getType(parent) === "array") {
if (parentName) {
propertyName += "[" + indexer + "]";
}
} else {
if (parentName) {
propertyName += ".";
}
propertyName += indexer;
}
return propertyName;
}

exports.visitModel = function (rootObject, callback, options) {
options = options || {};
options.visitedObjects = options.visitedObjects || new objectLookup();

var mappedRootObject;
var unwrappedRootObject = ko.utils.unwrapObservable(rootObject);

if (!canHaveProperties(unwrappedRootObject)) {
return callback(rootObject, options.parentName);
} else {
options = fillOptions(options, unwrappedRootObject[mappingProperty]);

// Only do a callback, but ignore the results
callback(rootObject, options.parentName);
mappedRootObject = exports.getType(unwrappedRootObject) === "array" ? [] : {};
}

options.visitedObjects.save(rootObject, mappedRootObject);

var parentName = options.parentName;
visitPropertiesOrArrayEntries(unwrappedRootObject, function (indexer) {
if (options.ignore && ko.utils.arrayIndexOf(options.ignore, indexer) != -1) return;

var propertyValue = unwrappedRootObject[indexer];
options.parentName = getPropertyName(parentName, unwrappedRootObject, indexer);

// If we don't want to explicitly copy the unmapped property...
if (ko.utils.arrayIndexOf(options.copy, indexer) === -1) {
// ...find out if it's a property we want to explicitly include
if (ko.utils.arrayIndexOf(options.include, indexer) === -1) {
// The mapped properties object contains all the properties that were part of the original object.
// If a property does not exist, and it is not because it is part of an array (e.g. "myProp[3]"), then it should not be unmapped.
if (unwrappedRootObject[mappingProperty]
&& unwrappedRootObject[mappingProperty].mappedProperties && !unwrappedRootObject[mappingProperty].mappedProperties[indexer]
&& unwrappedRootObject[mappingProperty].copiedProperties && !unwrappedRootObject[mappingProperty].copiedProperties[indexer]
&& !(exports.getType(unwrappedRootObject) === "array")) {
return;
}
}
}

var outputProperty;
switch (exports.getType(ko.utils.unwrapObservable(propertyValue))) {
case "object":
case "array":
case "undefined":
var previouslyMappedValue = options.visitedObjects.get(propertyValue);
mappedRootObject[indexer] = (exports.getType(previouslyMappedValue) !== "undefined") ? previouslyMappedValue : exports.visitModel(propertyValue, callback, options);
break;
default:
mappedRootObject[indexer] = callback(propertyValue, options.parentName);
}
});

return mappedRootObject;
}

function simpleObjectLookup() {
var keys = [];
var values = [];
this.save = function (key, value) {
var existingIndex = ko.utils.arrayIndexOf(keys, key);
if (existingIndex >= 0) values[existingIndex] = value;
else {
keys.push(key);
values.push(value);
}
};
this.get = function (key) {
var existingIndex = ko.utils.arrayIndexOf(keys, key);
var value = (existingIndex >= 0) ? values[existingIndex] : undefined;
return value;
};
};

function objectLookup() {
var buckets = {};

var findBucket = function(key) {
var bucketKey;
try {
bucketKey = key;//JSON.stringify(key);
}
catch (e) {
bucketKey = "$$$";
}

var bucket = buckets[bucketKey];
if (bucket === undefined) {
bucket = new simpleObjectLookup();
buckets[bucketKey] = bucket;
}
return bucket;
};

this.save = function (key, value) {
findBucket(key).save(key, value);
};
this.get = function (key) {
return findBucket(key).get(key);
};
};
}));
-
-
- -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
- - - - - - - - - - - -
-

Markdown Cheat Sheet

- -
- -
-
-

Format Text

-

Headers

-
-# This is an <h1> tag
-## This is an <h2> tag
-###### This is an <h6> tag
-

Text styles

-
-*This text will be italic*
-_This will also be italic_
-**This text will be bold**
-__This will also be bold__
-
-*You **can** combine them*
-
-
-
-

Lists

-

Unordered

-
-* Item 1
-* Item 2
-  * Item 2a
-  * Item 2b
-

Ordered

-
-1. Item 1
-2. Item 2
-3. Item 3
-   * Item 3a
-   * Item 3b
-
-
-

Miscellaneous

-

Images

-
-![GitHub Logo](/images/logo.png)
-Format: ![Alt Text](url)
-
-

Links

-
-http://github.com - automatic!
-[GitHub](http://github.com)
-

Blockquotes

-
-As Kanye West said:
-
-> We're living the future so
-> the present is our past.
-
-
-
-
- -

Code Examples in Markdown

-
-

Syntax highlighting with GFM

-
-```javascript
-function fancyAlert(arg) {
-  if(arg) {
-    $.facebox({div:'#foo'})
-  }
-}
-```
-
-
-

Or, indent your code 4 spaces

-
-Here is a Python code example
-without syntax highlighting:
-
-    def foo:
-      if not bar:
-        return true
-
-
-

Inline code for comments

-
-I think you should use an
-`<addr>` element here instead.
-
-
- -
- - - -
- - Something went wrong with that request. Please try again. - -
- - - - - - - - +/// Knockout Mapping plugin v2.3.5 +/// (c) 2012 Steven Sanderson, Roy Jacobs - http://knockoutjs.com/ +/// License: MIT (http://www.opensource.org/licenses/mit-license.php) +(function (factory) { + // Module systems magic dance. + + if (typeof require === "function" && typeof exports === "object" && typeof module === "object") { + // CommonJS or Node: hard-coded dependency on "knockout" + factory(require("knockout"), exports); + } else if (typeof define === "function" && define["amd"]) { + // AMD anonymous module with hard-coded dependency on "knockout" + define(["knockout", "exports"], factory); + } else { + // - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - -
-
- - - GitHub - GitHub - - - - - - - - -
-
- - - - - - - -
-
- -
-
-
- - - - - -

- public - - - / - knockout.mapping -

-
- - - - - -
- - - - - - -
- - -
- - - branch: - master - - -
- -
-
- Switch branches/tags - -
- -
-
- -
-
- -
-
- -
- - - -
- - arrayperf -
- -
- - master -
- -
- - revert -
- -
Nothing to show
-
- - - - -
-
-
- -
- - - -
- - - - - - - -
-
- -
- - - - - - -
-
- - - - - - - -
- - - - - -
-

3 contributors

- - - - - -
- -
- - -
- -
-
- -
-
-
-
- - file - 22 lines (21 sloc) - 9.474 kb -
- - -
-
- - - - - -
-
1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-
-
-
/// Knockout Mapping plugin v2.3.5
/// (c) 2012 Steven Sanderson, Roy Jacobs - http://knockoutjs.com/
/// License: MIT (http://www.opensource.org/licenses/mit-license.php)
(function(e){"function"===typeof require&&"object"===typeof exports&&"object"===typeof module?e(require("knockout"),exports):"function"===typeof define&&define.amd?define(["knockout","exports"],e):e(ko,ko.mapping={})})(function(e,f){function x(b,c){var a,d;for(d in c)if(c.hasOwnProperty(d)&&c[d])if(a=f.getType(b[d]),d&&b[d]&&"array"!==a&&"string"!==a)x(b[d],c[d]);else if("array"===f.getType(b[d])&&"array"===f.getType(c[d])){a=b;for(var e=d,k=b[d],m=c[d],s={},g=k.length-1;0<=g;--g)s[k[g]]=k[g];for(g=
m.length-1;0<=g;--g)s[m[g]]=m[g];k=[];m=void 0;for(m in s)k.push(s[m]);a[e]=k}else b[d]=c[d]}function D(b,c){var a={};x(a,b);x(a,c);return a}function y(b,c){for(var a=D({},b),e=K.length-1;0<=e;e--){var f=K[e];a[f]&&(a[""]instanceof Object||(a[""]={}),a[""][f]=a[f],delete a[f])}c&&(a.ignore=h(c.ignore,a.ignore),a.include=h(c.include,a.include),a.copy=h(c.copy,a.copy),a.observe=h(c.observe,a.observe));a.ignore=h(a.ignore,i.ignore);a.include=h(a.include,i.include);a.copy=h(a.copy,i.copy);a.observe=h(a.observe,
i.observe);a.mappedProperties=a.mappedProperties||{};a.copiedProperties=a.copiedProperties||{};return a}function h(b,c){"array"!==f.getType(b)&&(b="undefined"===f.getType(b)?[]:[b]);"array"!==f.getType(c)&&(c="undefined"===f.getType(c)?[]:[c]);return e.utils.arrayGetDistinctValues(b.concat(c))}function E(b,c,a,d,j,k,m){var s="array"===f.getType(e.utils.unwrapObservable(c)),k=k||"";if(f.isMapped(b))var g=e.utils.unwrapObservable(b)[n],a=D(g,a);var i=m||j,h=function(){return a[d]&&a[d].create instanceof
Function},w=function(b){var f=F,g=e.dependentObservable;e.dependentObservable=function(a,b,c){c=c||{};a&&"object"==typeof a&&(c=a);var d=c.deferEvaluation,L=!1;c.deferEvaluation=!0;a=new G(a,b,c);if(!d){var g=a,d=e.dependentObservable;e.dependentObservable=G;a=e.isWriteableObservable(g);e.dependentObservable=d;a=G({read:function(){L||(e.utils.arrayRemoveItem(f,g),L=!0);return g.apply(g,arguments)},write:a&&function(a){return g(a)},deferEvaluation:!0});f.push(a)}return a};e.dependentObservable.fn=
G.fn;e.computed=e.dependentObservable;b=e.utils.unwrapObservable(j)instanceof Array?a[d].create({data:b||c,parent:i,skip:M}):a[d].create({data:b||c,parent:i});e.dependentObservable=g;e.computed=e.dependentObservable;return b},t=function(){return a[d]&&a[d].update instanceof Function},u=function(b,f){var g={data:f||c,parent:i,target:e.utils.unwrapObservable(b)};e.isWriteableObservable(b)&&(g.observable=b);return a[d].update(g)};if(m=H.get(c))return m;d=d||"";if(s){var s=[],r=!1,l=function(a){return a};
a[d]&&a[d].key&&(l=a[d].key,r=!0);e.isObservable(b)||(b=e.observableArray([]),b.mappedRemove=function(a){var c="function"==typeof a?a:function(b){return b===l(a)};return b.remove(function(a){return c(l(a))})},b.mappedRemoveAll=function(a){var c=B(a,l);return b.remove(function(a){return-1!=e.utils.arrayIndexOf(c,l(a))})},b.mappedDestroy=function(a){var c="function"==typeof a?a:function(b){return b===l(a)};return b.destroy(function(a){return c(l(a))})},b.mappedDestroyAll=function(a){var c=B(a,l);return b.destroy(function(a){return-1!=
e.utils.arrayIndexOf(c,l(a))})},b.mappedIndexOf=function(a){var c=B(b(),l),a=l(a);return e.utils.arrayIndexOf(c,a)},b.mappedCreate=function(a){if(-1!==b.mappedIndexOf(a))throw Error("There already is an object with the key that you specified.");var c=h()?w(a):a;t()&&(a=u(c,a),e.isWriteableObservable(c)?c(a):c=a);b.push(c);return c});m=B(e.utils.unwrapObservable(b),l).sort();g=B(c,l);r&&g.sort();var r=e.utils.compareArrays(m,g),m={},I,z=e.utils.unwrapObservable(c),x={},y=!0,g=0;for(I=z.length;g<I;g++){var q=
l(z[g]);if(void 0===q||q instanceof Object){y=!1;break}x[q]=z[g]}var z=[],A=0,g=0;for(I=r.length;g<I;g++){var q=r[g],p,v=k+"["+g+"]";switch(q.status){case "added":var C=y?x[q.value]:J(e.utils.unwrapObservable(c),q.value,l);p=E(void 0,C,a,d,b,v,j);h()||(p=e.utils.unwrapObservable(p));v=N(e.utils.unwrapObservable(c),C,m);p===M?A++:z[v-A]=p;m[v]=!0;break;case "retained":C=y?x[q.value]:J(e.utils.unwrapObservable(c),q.value,l);p=J(b,q.value,l);E(p,C,a,d,b,v,j);v=N(e.utils.unwrapObservable(c),C,m);z[v]=
p;m[v]=!0;break;case "deleted":p=J(b,q.value,l)}s.push({event:q.status,item:p})}b(z);a[d]&&a[d].arrayChanged&&e.utils.arrayForEach(s,function(b){a[d].arrayChanged(b.event,b.item)})}else if(O(c)){b=e.utils.unwrapObservable(b);if(!b){if(h())return r=w(),t()&&(r=u(r)),r;if(t())return u(r);b={}}t()&&(b=u(b));H.save(c,b);if(t())return b;P(c,function(d){var f=k.length?k+"."+d:d;if(-1==e.utils.arrayIndexOf(a.ignore,f))if(-1!=e.utils.arrayIndexOf(a.copy,f))b[d]=c[d];else if("object"!=typeof c[d]&&"array"!=
typeof c[d]&&0<a.observe.length&&-1==e.utils.arrayIndexOf(a.observe,f))b[d]=c[d],a.copiedProperties[f]=!0;else{var g=H.get(c[d]),j=E(b[d],c[d],a,d,b,f,b),g=g||j;if(0<a.observe.length&&-1==e.utils.arrayIndexOf(a.observe,f))b[d]=g(),a.copiedProperties[f]=!0;else{if(e.isWriteableObservable(b[d]))b[d](e.utils.unwrapObservable(g));else g=void 0===b[d]?g:e.utils.unwrapObservable(g),b[d]=g;a.mappedProperties[f]=!0}}})}else switch(f.getType(c)){case "function":t()?e.isWriteableObservable(c)?(c(u(c)),b=c):
b=u(c):b=c;break;default:if(e.isWriteableObservable(b))return p=t()?u(b):e.utils.unwrapObservable(c),b(p),p;h()||t();b=h()?w():e.observable(e.utils.unwrapObservable(c));t()&&b(u(b))}return b}function N(b,c,a){for(var d=0,e=b.length;d<e;d++)if(!0!==a[d]&&b[d]===c)return d;return null}function Q(b,c){var a;c&&(a=c(b));"undefined"===f.getType(a)&&(a=b);return e.utils.unwrapObservable(a)}function J(b,c,a){for(var b=e.utils.unwrapObservable(b),d=0,f=b.length;d<f;d++){var k=b[d];if(Q(k,a)===c)return k}throw Error("When calling ko.update*, the key '"+
c+"' was not found!");}function B(b,c){return e.utils.arrayMap(e.utils.unwrapObservable(b),function(a){return c?Q(a,c):a})}function P(b,c){if("array"===f.getType(b))for(var a=0;a<b.length;a++)c(a);else for(a in b)c(a)}function O(b){var c=f.getType(b);return("object"===c||"array"===c)&&null!==b}function S(){var b=[],c=[];this.save=function(a,d){var f=e.utils.arrayIndexOf(b,a);0<=f?c[f]=d:(b.push(a),c.push(d))};this.get=function(a){a=e.utils.arrayIndexOf(b,a);return 0<=a?c[a]:void 0}}function R(){var b=
{},c=function(a){var c;try{c=a}catch(e){c="$$$"}a=b[c];void 0===a&&(a=new S,b[c]=a);return a};this.save=function(a,b){c(a).save(a,b)};this.get=function(a){return c(a).get(a)}}var n="__ko_mapping__",G=e.dependentObservable,A=0,F,H,K=["create","update","key","arrayChanged"],M={},w={include:["_destroy"],ignore:[],copy:[],observe:[]},i=w;f.isMapped=function(b){return(b=e.utils.unwrapObservable(b))&&b[n]};f.fromJS=function(b){if(0==arguments.length)throw Error("When calling ko.fromJS, pass the object you want to convert.");
window.setTimeout(function(){A=0},0);A++||(F=[],H=new R);var c,a;2==arguments.length&&(arguments[1][n]?a=arguments[1]:c=arguments[1]);3==arguments.length&&(c=arguments[1],a=arguments[2]);a&&(c=D(c,a[n]));c=y(c);var d=E(a,b,c);a&&(d=a);--A||window.setTimeout(function(){for(;F.length;){var a=F.pop();a&&a()}},0);d[n]=D(d[n],c);return d};f.fromJSON=function(b){var c=e.utils.parseJson(b);arguments[0]=c;return f.fromJS.apply(this,arguments)};f.updateFromJS=function(){throw Error("ko.mapping.updateFromJS, use ko.mapping.fromJS instead. Please note that the order of parameters is different!");
};f.updateFromJSON=function(){throw Error("ko.mapping.updateFromJSON, use ko.mapping.fromJSON instead. Please note that the order of parameters is different!");};f.toJS=function(b,c){i||f.resetDefaultOptions();if(0==arguments.length)throw Error("When calling ko.mapping.toJS, pass the object you want to convert.");if("array"!==f.getType(i.ignore))throw Error("ko.mapping.defaultOptions().ignore should be an array.");if("array"!==f.getType(i.include))throw Error("ko.mapping.defaultOptions().include should be an array.");
if("array"!==f.getType(i.copy))throw Error("ko.mapping.defaultOptions().copy should be an array.");c=y(c,b[n]);return f.visitModel(b,function(a){return e.utils.unwrapObservable(a)},c)};f.toJSON=function(b,c){var a=f.toJS(b,c);return e.utils.stringifyJson(a)};f.defaultOptions=function(){if(0<arguments.length)i=arguments[0];else return i};f.resetDefaultOptions=function(){i={include:w.include.slice(0),ignore:w.ignore.slice(0),copy:w.copy.slice(0)}};f.getType=function(b){if(b&&"object"===typeof b){if(b.constructor==
(new Date).constructor)return"date";if("[object Array]"===Object.prototype.toString.call(b))return"array"}return typeof b};f.visitModel=function(b,c,a){a=a||{};a.visitedObjects=a.visitedObjects||new R;var d,j=e.utils.unwrapObservable(b);if(O(j))a=y(a,j[n]),c(b,a.parentName),d="array"===f.getType(j)?[]:{};else return c(b,a.parentName);a.visitedObjects.save(b,d);var k=a.parentName;P(j,function(b){if(!(a.ignore&&-1!=e.utils.arrayIndexOf(a.ignore,b))){var i=j[b],g=a,h=k||"";"array"===f.getType(j)?k&&
(h+="["+b+"]"):(k&&(h+="."),h+=b);g.parentName=h;if(!(-1===e.utils.arrayIndexOf(a.copy,b)&&-1===e.utils.arrayIndexOf(a.include,b)&&j[n]&&j[n].mappedProperties&&!j[n].mappedProperties[b]&&j[n].copiedProperties&&!j[n].copiedProperties[b]&&"array"!==f.getType(j)))switch(f.getType(e.utils.unwrapObservable(i))){case "object":case "array":case "undefined":g=a.visitedObjects.get(i);d[b]="undefined"!==f.getType(g)?g:f.visitModel(i,c,a);break;default:d[b]=c(i,a.parentName)}}});return d}});
-
-
- -
-
- - - - -
-
-
- - - - -
-
-
-
- - -
- - - - - - - - - - - -
-

Markdown Cheat Sheet

- -
- -
-
-

Format Text

-

Headers

-
-# This is an <h1> tag
-## This is an <h2> tag
-###### This is an <h6> tag
-

Text styles

-
-*This text will be italic*
-_This will also be italic_
-**This text will be bold**
-__This will also be bold__
-
-*You **can** combine them*
-
-
-
-

Lists

-

Unordered

-
-* Item 1
-* Item 2
-  * Item 2a
-  * Item 2b
-

Ordered

-
-1. Item 1
-2. Item 2
-3. Item 3
-   * Item 3a
-   * Item 3b
-
-
-

Miscellaneous

-

Images

-
-![GitHub Logo](/images/logo.png)
-Format: ![Alt Text](url)
-
-

Links

-
-http://github.com - automatic!
-[GitHub](http://github.com)
-

Blockquotes

-
-As Kanye West said:
-
-> We're living the future so
-> the present is our past.
-
-
-
-
- -

Code Examples in Markdown

-
-

Syntax highlighting with GFM

-
-```javascript
-function fancyAlert(arg) {
-  if(arg) {
-    $.facebox({div:'#foo'})
-  }
-}
-```
-
-
-

Or, indent your code 4 spaces

-
-Here is a Python code example
-without syntax highlighting:
-
-    def foo:
-      if not bar:
-        return true
-
-
-

Inline code for comments

-
-I think you should use an
-`<addr>` element here instead.
-
-
- -
- - - -
- - Something went wrong with that request. Please try again. - -
- - - - - - - - +/// Knockout Mapping plugin v2.3.5 +/// (c) 2012 Steven Sanderson, Roy Jacobs - http://knockoutjs.com/ +/// License: MIT (http://www.opensource.org/licenses/mit-license.php) +(function(e){"function"===typeof require&&"object"===typeof exports&&"object"===typeof module?e(require("knockout"),exports):"function"===typeof define&&define.amd?define(["knockout","exports"],e):e(ko,ko.mapping={})})(function(e,f){function x(b,c){var a,d;for(d in c)if(c.hasOwnProperty(d)&&c[d])if(a=f.getType(b[d]),d&&b[d]&&"array"!==a&&"string"!==a)x(b[d],c[d]);else if("array"===f.getType(b[d])&&"array"===f.getType(c[d])){a=b;for(var e=d,k=b[d],m=c[d],s={},g=k.length-1;0<=g;--g)s[k[g]]=k[g];for(g= +m.length-1;0<=g;--g)s[m[g]]=m[g];k=[];m=void 0;for(m in s)k.push(s[m]);a[e]=k}else b[d]=c[d]}function D(b,c){var a={};x(a,b);x(a,c);return a}function y(b,c){for(var a=D({},b),e=K.length-1;0<=e;e--){var f=K[e];a[f]&&(a[""]instanceof Object||(a[""]={}),a[""][f]=a[f],delete a[f])}c&&(a.ignore=h(c.ignore,a.ignore),a.include=h(c.include,a.include),a.copy=h(c.copy,a.copy),a.observe=h(c.observe,a.observe));a.ignore=h(a.ignore,i.ignore);a.include=h(a.include,i.include);a.copy=h(a.copy,i.copy);a.observe=h(a.observe, +i.observe);a.mappedProperties=a.mappedProperties||{};a.copiedProperties=a.copiedProperties||{};return a}function h(b,c){"array"!==f.getType(b)&&(b="undefined"===f.getType(b)?[]:[b]);"array"!==f.getType(c)&&(c="undefined"===f.getType(c)?[]:[c]);return e.utils.arrayGetDistinctValues(b.concat(c))}function E(b,c,a,d,j,k,m){var s="array"===f.getType(e.utils.unwrapObservable(c)),k=k||"";if(f.isMapped(b))var g=e.utils.unwrapObservable(b)[n],a=D(g,a);var i=m||j,h=function(){return a[d]&&a[d].create instanceof +Function},w=function(b){var f=F,g=e.dependentObservable;e.dependentObservable=function(a,b,c){c=c||{};a&&"object"==typeof a&&(c=a);var d=c.deferEvaluation,L=!1;c.deferEvaluation=!0;a=new G(a,b,c);if(!d){var g=a,d=e.dependentObservable;e.dependentObservable=G;a=e.isWriteableObservable(g);e.dependentObservable=d;a=G({read:function(){L||(e.utils.arrayRemoveItem(f,g),L=!0);return g.apply(g,arguments)},write:a&&function(a){return g(a)},deferEvaluation:!0});f.push(a)}return a};e.dependentObservable.fn= +G.fn;e.computed=e.dependentObservable;b=e.utils.unwrapObservable(j)instanceof Array?a[d].create({data:b||c,parent:i,skip:M}):a[d].create({data:b||c,parent:i});e.dependentObservable=g;e.computed=e.dependentObservable;return b},t=function(){return a[d]&&a[d].update instanceof Function},u=function(b,f){var g={data:f||c,parent:i,target:e.utils.unwrapObservable(b)};e.isWriteableObservable(b)&&(g.observable=b);return a[d].update(g)};if(m=H.get(c))return m;d=d||"";if(s){var s=[],r=!1,l=function(a){return a}; +a[d]&&a[d].key&&(l=a[d].key,r=!0);e.isObservable(b)||(b=e.observableArray([]),b.mappedRemove=function(a){var c="function"==typeof a?a:function(b){return b===l(a)};return b.remove(function(a){return c(l(a))})},b.mappedRemoveAll=function(a){var c=B(a,l);return b.remove(function(a){return-1!=e.utils.arrayIndexOf(c,l(a))})},b.mappedDestroy=function(a){var c="function"==typeof a?a:function(b){return b===l(a)};return b.destroy(function(a){return c(l(a))})},b.mappedDestroyAll=function(a){var c=B(a,l);return b.destroy(function(a){return-1!= +e.utils.arrayIndexOf(c,l(a))})},b.mappedIndexOf=function(a){var c=B(b(),l),a=l(a);return e.utils.arrayIndexOf(c,a)},b.mappedCreate=function(a){if(-1!==b.mappedIndexOf(a))throw Error("There already is an object with the key that you specified.");var c=h()?w(a):a;t()&&(a=u(c,a),e.isWriteableObservable(c)?c(a):c=a);b.push(c);return c});m=B(e.utils.unwrapObservable(b),l).sort();g=B(c,l);r&&g.sort();var r=e.utils.compareArrays(m,g),m={},I,z=e.utils.unwrapObservable(c),x={},y=!0,g=0;for(I=z.length;g