k-12
v0.1.1
Published
A module to help working with K-12 style grade ranges.
Downloads
2
Maintainers
Readme
k12
k12.gradeRangeToArray(gradeRange, [returnNumbers]) ⇒ Array
Returns an array of grades when provided a range (including sparse ranges).
Kind: static method of k12
See: arrayToGradeRange for the reverse of this function.
Important: The output when using returnsNumber=true
is not valid input for arrayToGradeRange
| Param | Type | Default | | --- | --- | --- | | gradeRange | String | | | [returnNumbers] | Boolean | false |
Example
// returns [ 'PK', 'K', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12' ]
gradeRangeToArray('PK-2,3-5,6-8,9-12')
Example
// returns [ 'K', '1', '2', '3', '4', '5', '6', '7', '8' ]
gradeRangeToArray('K-8')
Example
// returns [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]
gradeRangeToArray('P-2,3-5,6-8,9-12', true)
k12.arrayToGradeRange(input, [pkStr]) ⇒ String
Returns a grade range as a string (including sparse ranges).
Kind: static method of k12
See: gradeRangeToArray for the reverse of this function.
| Param | Type | Default | Description | | --- | --- | --- | --- | | input | Array | | | | [pkStr] | String | P | the abbreviation to use for Pre-Kindergarten |
Example
// returns 'PK-2,3-5,6-8,9-12'
arrayToGradeRange([ 'PK', 'K', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12' ], 'PK')
Example
// returns 'K-8'
arrayToGradeRange([ 'K', '1', '2', '3', '4', '5', '6', '7', '8' ])