10 examples of 'angularjs map array' in JavaScript

Every line of 'angularjs map array' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
69function arrayToMap(array, mapKey) {
70 var mapObj = {};
71 mapKey = mapKey || 'id';
72 array.forEach(function(item) {
73 mapObj[item[mapKey]] = item;
74 });
75 return mapObj;
76}
17export function mapMapArray ( map : Map, mapper : ( value : V, key : K ) => U ) : Map {
18 return mapMap( map, ( array, key ) => array.map( value => mapper( value, key ) ) );
19}
20function arrayMap(array, callback) {
21 var index = -1,
22 length = array ? array.length >>> 0 : 0,
23 result = Array(length);
24
25 while (++index < length) {
26 result[index] = callback(array[index], index, array);
27 }
28 return result;
29}
73export function map(map: MapFunc) { return new Map(map); }
10function map (data) {
11 var proj = data.projections,
12 current = {},
13 currentTime = new Date(),
14 i = 0,
15 length = proj.length,
16 item,
17 eventProcessed,
18 elapsedTime,
19 last,
20 name;
21
22 proj.sort(function (a, b) {
23 return a.name.localeCompare(b.name);
24 });
25
26 for(; i < length; i++) {
27 item = proj[i];
28 name = item.name;
29 last = lastRequest[name];
30 current[name] = item;
31
32 if(last !== undefined && lastTimestamp) {
33 eventProcessed = item.eventsProcessedAfterRestart - last.eventsProcessedAfterRestart;
34 elapsedTime = currentTime - lastTimestamp;
35 item.eventsPerSecond = (1000.0 * eventProcessed / elapsedTime).toFixed(1);
36 }
37
38 item.location = encodeURIComponent(item.statusUrl);
39 proj[i] = item;
40 }
41
42 lastRequest = current;
43 lastTimestamp = currentTime;
44
45 return proj;
46 }
20function map( array, fn ) { var result
21 result = Array( array.length )
22 forEach( array, function ( val, i, array ) {
23 result[i] = fn( val, i, array )
24 })
25 return result
26}
70function arrayToJSON(array, previousLevel) {
71 var res = {};
72 if (previousLevel === undefined) {
73 previousLevel = -1;
74 }
75
76 for (var i = 0 ; i < array.length ; i++) {
77 var currentLevel = array[i].level;
78 var key = array[i].key;
79 var val = array[i].value;
80 var subarray = [];
81
82 // only deal with objects one level below. Other levels are being handled by recursion
83 if (currentLevel === previousLevel + 1) {
84 // if the current object is an array
85 if (val === undefined) {
86 var j = i + 1;
87 while (j < array.length && array[j].level > currentLevel) {
88 subarray.push(array[j]);
89 j++;
90 }
91 res[key] = arrayToJSON(subarray, currentLevel);
92 } else {
93 res[key] = val;
94 }
95 }
96 }
97
98 return res;
99}
60function map(array, callback) {
61 return times(array.length, function (i) {
62 return callback(array[i]);
63 });
64}
39function map(v, k){ var o = this.o, tmp, u; // iterate over each key/value.
40 if(o.map){
41 tmp = o.map.call(this.as, v, ''+k, o.node);
42 if(u === tmp){
43 obj_del(o.node, k);
44 } else
45 if(o.node){ o.node[k] = tmp }
46 return;
47 }
48 if(Val.is(v)){
49 o.node[k] = v;
50 }
51}
32function toJSON(value) {
33 return angular.toJson(value, 2);
34}

Related snippets