1.0.2 • Published 3 years ago

number_array_to_string v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

NumberArrayConverter

Converts an array of numbers to a string using the example:

1,2,3,4,5,6,7,8 -> "1-8"

1,3,4,5,6,7,8 -> "1,3-8"

1,3,4,5,6,7,8,10,11,12 -> "1,3-8,10-12"

1,2,3 -> "1-3"

1,2 -> "1,2"

1,2,4 -> "1,2,4"

1,2,4,5,6 -> "1,2,4-6"

1,2,3,7,8,9,15,17,19,20,21 -> "1-3,7-9,15,17,19-21"

1,2,3,4,5,6,100,1091,1999,2000,2001,2002 -> "1-6,100,1091,1999-2002"

1 -> "1"

1,3,5,7,9,11 -> "1,3,5,7,9,11"

The numbers in the array are always integers, positive and sorted in ascending order.