
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
angular-toarrayfilter
Advanced tools
An angular filter to convert objects to arrays for easy filtering and sorting
Although AngularJS 1.x supports iterating over an object (keys and values), it is
not the preferred way of doing things. Moreover, filters like filter and orderBy
just don't work with objects; they are designed to work with arrays.
This filter can convert your objects into stable arrays that can then be filtered and sorted using the standard AngularJS filters.
The easiest way to install is using bower:
bower install --save angular-toArrayFilter
Alternatively you can download from the GitHub project: https://github.com/petebacondarwin/angular-toArrayFilter
Load the toArrayFilter.js file into your web app after loading angular.js
<html>
...
<head>
...
<script src="angular.js"></script>
<script src="bower_components/angular-toArrayFilter/toArrayFilter.js"></script>
...
</head>
...
</html>
Make sure that your AngularJS application references the angular-toArrayFilter module:
angular.module('myApp', ['angular-toArrayFilter']);
Now if you have an object that you wish to repeat over, just slip the toArray filter in
before you try sorting or filtering:
<div ng-repeat="item in itemObj | toArray | orderBy : 'someProp'">
{{ item.$key }} - {{ item.someProp }}
</div>
The filter iterates over the object's keys and creates an array containing the value of each
property. By default, the filter also attaches a new property $key to the value containing
the original key that was used in the object we are iterating over to reference the property.
$key propertyIf you don't want the $key property to be attached to each of the property values, you simply
put an additional parameter on the toArray filter:
<div ng-repeat="item in itemObj | toArray : false | orderBy : 'someProp'">
{{ item.someProp }} (no $key available now)
</div>
$key with non-objectsNon-objects such as strings and numbers cannot have a new $key property attached to them.
If the object properties you are iterating over are not objects then you must either disable
the $key property or the filter will replace the non-object with a new object of the form:
{ $key: key, $value: value }.
There are always issues when trying to iterate over properties in JavaScript and the toArray
filter has its own set of things to be aware of when using it:
$key property.Object.keys and Object.defineProperty which
don't work well or at all in Internet Explorer 8 (IE8).Here is a fuller example of using the toArray filter on an object, to allow sorting and filtering
by a date property on each property of the original object. It also demonstrates how you can easily
update the original object and the array will stay in sync.
Check out the Live Demo
index.html:
<div ng-app="app">
<div ng:controller="Main">
<div ng:repeat="item in items | toArray | orderBy: 'date'">
{{item.$key}}: {{item.date | date}}
<button ng-click="remove(item)">Remove</button>
</div>
<button ng-click="add()">Add</button>
</div>
</div>
app.js
angular.module('app', [])
.controller('Main', function Main($scope) {
$scope.nextKey = 4;
$scope.items = {
0: {date: new Date('12/23/2013')},
1: {date: new Date('12/23/2011')},
2: {date: new Date('12/23/2010')},
3: {date: new Date('12/23/2015')}
};
$scope.remove = function(item) {
delete $scope.items[item.$key];
};
$scope.add = function() {
$scope.items[$scope.nextKey] = { date: new Date() };
$scope.nextKey += 1;
};
});
FAQs
An angular filter to convert objects to arrays for easy filtering and sorting
The npm package angular-toarrayfilter receives a total of 135 weekly downloads. As such, angular-toarrayfilter popularity was classified as not popular.
We found that angular-toarrayfilter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.