Type: Package
Title: A Flexible and Robust Sys.sleep() Replacement
Version: 1.3.1
Date: 2025-04-07
Description: Provides a near drop-in replacement for base::Sys.sleep() that allows more types of input to produce delays in the execution of code and can silence/prevent typical sources of error.
License: GPL-2
Imports: methods, lubridate
Suggests: testthat, covr
URL: https://github.com/russellpierce/naptime
BugReports: https://github.com/russellpierce/naptime/issues
RoxygenNote: 7.3.2
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2025-04-07 20:52:52 UTC; russell
Author: Russell S. Pierce [aut, cre], Timothy Gann [aut]
Maintainer: Russell S. Pierce <russell.s.pierce@gmail.com>
Repository: CRAN
Date/Publication: 2025-04-07 21:10:02 UTC

Safe sleep function

Description

Acceptable inputs:

Usage

naptime(time, permissive = getOption("naptime.permissive", permissive_default))

## S4 method for signature 'numeric'
naptime(time, permissive = getOption("naptime.permissive", permissive_default))

## S4 method for signature 'Period'
naptime(time, permissive = getOption("naptime.permissive", permissive_default))

## S4 method for signature 'POSIXct'
naptime(time, permissive = getOption("naptime.permissive", permissive_default))

## S4 method for signature 'difftime'
naptime(time, permissive = getOption("naptime.permissive", permissive_default))

## S4 method for signature 'logical'
naptime(time, permissive = getOption("naptime.permissive", permissive_default))

## S4 method for signature 'NULL'
naptime(time, permissive = getOption("naptime.permissive", permissive_default))

## S4 method for signature 'character'
naptime(time, permissive = getOption("naptime.permissive", permissive_default))

Arguments

time

Time to sleep, polymorphic type inputs, leaning towards units as 'seconds'

permissive

An optional argument to override the naptime.permissive option for this call of the naptime function

Details

The default duration is set with a numeric for the option naptime.default_delay in seconds (default: 0.1) Whether a generic input is accepted is determined by the option naptime.permissive (default: FALSE)

Value

NULL; A side effect of a pause in program execution

Examples

## Not run: 
naptime(1)
naptime(difftime("2016-01-01 00:00:01", "2016-01-01 00:00:00"))

## End(Not run)