https://github.com/qodesmith/slimarray
Filters redundant elements from arrays and returns them in an optional order.
https://github.com/qodesmith/slimarray
Last synced: over 1 year ago
JSON representation
Filters redundant elements from arrays and returns them in an optional order.
- Host: GitHub
- URL: https://github.com/qodesmith/slimarray
- Owner: qodesmith
- Created: 2015-05-04T01:18:00.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-11-04T03:15:32.000Z (over 10 years ago)
- Last Synced: 2025-01-24T22:42:49.800Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 188 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# slimArray
Filters redundant / duplicate elements from arrays and returns them in an optional order.
####Usage:####
`slimArray([array], 'order');`
[array] is an array of numbers or strings.
'order' is optional and can be one of two options, both of which are strings:
1. *asc:* - sorts the array in ascending order
2. *desc:* - sorts the array in descending order
####Examples:####
```
numbers = [3, 1, 10, 3, 10, 2, 100];
slimArray(numbers) // [3, 1, 10, 2, 100]
slimArray(numbers, 'asc') // [1, 2, 3, 10, 100]
slimArray(numbers, 'desc') // [100, 10, 3, 2, 1]
names = ['Larry', 'Moe', 'Curly', 'Moe', 'Curly'];
slimArray(names) // ["Larry", "Moe", "Curly"]
slimArray(names, 'asc') // ["Curly", "Larry", "Moe"]
slimArray(names, 'desc') // ["Moe", "Larry", "Curly"]
```