UNPKG

sugar

Version:

A Javascript utility library for working with native objects.

15 lines (12 loc) 342 B
'use strict'; var DateUnits = require('../var/DateUnits'), getLowerUnitIndex = require('./getLowerUnitIndex'); function walkUnitDown(unitIndex, fn) { while (unitIndex >= 0) { if (fn(DateUnits[unitIndex], unitIndex) === false) { break; } unitIndex = getLowerUnitIndex(unitIndex); } } module.exports = walkUnitDown;