PageSourceSearch

https://springfieldyellowcab.com/wp-content/plugins/limolabs-icabb…ert-key-value-object-to-array.js?ver=0.2.83

js springfieldyellowcab.com collected 2026-10-08 22:00:46 UTC 1,195 bytes, 50 lines download raw bytes

1/**
2 * Sort and convert key value object to array of objects Example:
3 * 
4 * var obj = { "US" : "United States, "AT" : "Austria" };
5 * 
6 * var arr = [{ key : "US", value : "United states" },{ key : "AT", value : "Austria" }]
7 * 
8 * Also sorting is done
9 * 
10 */
11LimoLabsIcabbiApp.filter('sortConvertKeyValueObjectToArray', function($filter) {
12    var cache = new Array();
13    var cache_sorted = new Array();
14
15    return function(obj, orderBy, reverse) {
16
17        if (!obj) {
18            return null;
19        }
20
21        if (cache.indexOf(obj) != -1) {
22            return cache_sorted[cache.indexOf(obj)];
23        }
24
25        var arr = new Array();
26
27        for ( var key in obj) {
28            var value = obj[key];
29
30            arr.push({
31                key : key,
32                value : value
33            });
34        }
35
36        var sorted = $filter('orderBy')(arr, function(obj) {
37            if (!orderBy) {
38                return obj.value;
39            } else {
40                return obj[orderBy];
41            }
42        }, reverse);
43
44        cache.push(obj);
45        cache_sorted[cache.indexOf(obj)] = sorted;
46
47        return sorted;
48
49    }
50})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.