MCPcopy
hub / github.com/winjs/winjs / createTestDataAdapter

Function createTestDataAdapter

tests/TestLib/TestDataSource.ts:22–741  ·  view source on GitHub ↗
(objects, controller, abilities)

Source from the content-addressed store, hash-verified

20 }
21
22 function createTestDataAdapter(objects, controller, abilities) {
23
24 // Private members
25 var listDataNotificationHandler,
26 array = [],
27 keyToIndexMap = {},
28 nextAvailableKey = 0,
29 requests = [],
30 countBeforeDelta,
31 countAfterDelta,
32 countBeforeOverride,
33 countAfterOverride,
34 dataSourceAccessed = false,
35 editsInProgress = false,
36 requestFulfilledSynchronously = false;
37
38 function directivesForMethod(method, args) {
39 if (controller && controller.directivesForMethod) {
40 return controller.directivesForMethod(method, args);
41 } else {
42 return null;
43 }
44 }
45
46 function getDataLength() {
47 return typeof controller.returnCount === 'undefined' ? array.length : Math.min(controller.returnCount, array.length);
48 }
49 function item(key, data) {
50 return { key: key.toString(), data: data };
51 }
52
53 function setItem(index, key, data) {
54 array[index] = item(key, data);
55 keyToIndexMap[key] = index;
56 }
57
58 function updateKeyToIndexMap(first) {
59 // Update the key map entries for all indices that changed
60 for (var i = first; i < array.length; i++) {
61 keyToIndexMap[array[i].key] = i;
62
63 }
64 }
65
66 function keyFromIndex(index) {
67 return (index < 0 || index >= array.length ? null : array[index].key);
68 }
69
70 function indexIfSupported(index) {
71 return (abilities && !abilities.itemsFromIndex ? undefined : index);
72 }
73
74 function itemsFromIndexImplementation(complete, error, index, countBefore, countAfter, returnAbsoluteIndex, maxLength) {
75 if (controller.communicationFailure) {
76 error(new WinJS.ErrorFromName(UI.FetchError.noResponse.toString()));
77 } else {
78 var directives = directivesForMethod("itemsFromIndex", [index, countBefore, countAfter]);
79

Callers 1

TestDataSource.tsFile · 0.85

Calls 15

setItemFunction · 0.85
getDataLengthFunction · 0.85
createPromiseFunction · 0.85
errorFunction · 0.85
insertFunction · 0.85
keyValidFunction · 0.85
moveFunction · 0.85
insertionIndexFunction · 0.85
updateKeyToIndexMapFunction · 0.85
implementRequestFunction · 0.85

Tested by

no test coverage detected