https://github.com/tpkn/collapse
A small module that helps to collapses a sorted slice of numbers or dates into ranges.
https://github.com/tpkn/collapse
collapse date number range
Last synced: 11 months ago
JSON representation
A small module that helps to collapses a sorted slice of numbers or dates into ranges.
- Host: GitHub
- URL: https://github.com/tpkn/collapse
- Owner: tpkn
- License: mit
- Created: 2025-01-19T10:15:22.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-16T23:49:48.000Z (over 1 year ago)
- Last Synced: 2025-02-26T08:38:08.147Z (over 1 year ago)
- Topics: collapse, date, number, range
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Collapse
A small module that helps to collapse a sorted slice of numbers or dates into `{{start, end}, {...}}` format.
## Numbers
```go
collapse.Numbers([]int{1,2,3,6,8,9})
// => [
// [1, 3],
// [6, 6],
// [8, 9]
// ]
```
### arg1
**Type**: `[]int`
Sorted slice of integers
### @return
**Type**: `[][]int`
## Dates
```go
collapse.DatesOnly([]string{"2025-01-01", "2025-01-02", "2025-01-04", "2025-01-06", "2025-01-07"})
// => [
// ["2025-01-01", "2025-01-02"],
// ["2025-01-04", "2025-01-04"],
// ["2025-01-06", "2025-01-07"]
// ]
```
### arg1
**Type**: `[]string`
Sorted slice of strings
### @return
**Type**: `[][]string`