nextperiod

0.3.3 • Public • Published

Build Status

nextperiod

Use this package to easily get the next time period in a series.

Install

npm install nextperiod --save
const series = {
  MORNING: 10,
  AFTERNOON: 15,
  EVENING: 19
}
 
const nextperiod = require('nextperiod')

Examples

nextperiod(series, 10)        // 15
nextperiod(series, 19)        // 10
nextperiod(series, 'MORNING') // 'AFTERNOON'
nextperiod(series, 'evening') // 'MORNING'
nextperiod(series, { MORNING: 10 }) // 'AFTERNOON'

Pretty Output

nextperiod(series, 'afternoon', { pretty: true }) // 'Evening'
nextperiod(series, 15, { pretty: true })          // 'Evening'

Custom Wrapping

nextperiod(series, 19, { wrap: false }) // false
nextperiod(series, 15, { wrap: false }) // 19
nextperiod(series, 'MORNING', { wrap: false }) // 'AFTERNOON'

Return an Object

nextperiod(series, 19, { object: true }) // { MORNING: 10 }
nextperiod(series, 15, { object: true }) // { EVENING: 19 }
nextperiod(series, 'MORNING', { object: true }) // { AFTERNOON: 15 }

Defaults

nextperiod([], 'NOT_IN_SERIES') // false
nextperiod([], '', { pretty: true, wrap: true, object: false }) // false

Features

  • Works both in Node.js and in the browser

Readme

Keywords

none

Package Sidebar

Install

npm i nextperiod

Weekly Downloads

0

Version

0.3.3

License

MIT

Last publish

Collaborators

  • harrymt